[PD2] Code almost all done. Need to add logout and change help message

Co-authored-by: tsousa111 <tiagao2001@hotmail.com>
This commit is contained in:
Afonso Franco 2024-05-31 19:23:41 +01:00
parent e2c3d75223
commit 6f8219d991
Signed by: afonso
SSH key fingerprint: SHA256:PQTRDHPH3yALEGtHXnXBp3Orfcn21pK20t0tS1kHg54
12 changed files with 123 additions and 212 deletions

View file

@ -80,7 +80,7 @@ func (ds DataStore) CreateTables() error {
func (ds DataStore) GetMessage(toUID string, position int) (*protocol.AnswerGetMsg, error) {
var serverMessage protocol.AnswerGetMsg
serverMessage := new(protocol.AnswerGetMsg)
query := `
SELECT fromUID, toUID, subject, body, timestamp
FROM messages
@ -189,7 +189,7 @@ func (ds DataStore) AddMessageToQueue(fromUID string, message protocol.SendMsg)
return nil
}
func (ds DataStore) GetUserCertificate(uid string) (protocol.AnswerGetUserCert,error) {
func (ds DataStore) GetUserCertificate(uid string) (protocol.AnswerGetUserCert, error) {
query := `
SELECT userCert
FROM users
@ -202,9 +202,9 @@ func (ds DataStore) GetUserCertificate(uid string) (protocol.AnswerGetUserCert,e
if err == sql.ErrNoRows {
errorMessage := fmt.Sprintf("No certificate for UID %v found in the database", uid)
log.Println(errorMessage)
return protocol.AnswerGetUserCert{},errors.New(errorMessage)
return protocol.AnswerGetUserCert{}, errors.New(errorMessage)
}
return protocol.NewAnswerGetUserCert(uid, userCertBytes),nil
return protocol.NewAnswerGetUserCert(uid, userCertBytes), nil
}
func (ds DataStore) userExists(uid string) bool {