[PD2] some anotations on what to change in client

This commit is contained in:
Tiago Sousa 2024-05-30 15:49:49 +01:00
parent 8f29d75d27
commit 247d2e73dc
Signed by: tiago
SSH key fingerprint: SHA256:rOmjD81ZIhKdCkFWS9UIKdBi4UByF5x3hRH/0YeXsPI

View file

@ -32,7 +32,7 @@ func Run() {
switch command { switch command {
case "send": case "send":
if flag.NArg() != 3 { if flag.NArg() != 3 {
printError("MSG SERVICE: command error!") printError("MSG SERVICE: command error!")
showHelp() showHelp()
os.Exit(1) os.Exit(1)
} }
@ -46,7 +46,7 @@ func Run() {
case "askqueue": case "askqueue":
if flag.NArg() > 3 { if flag.NArg() > 3 {
printError("MSG SERVICE: command error!") printError("MSG SERVICE: command error!")
showHelp() showHelp()
os.Exit(1) os.Exit(1)
} }
@ -72,7 +72,7 @@ func Run() {
case "getmsg": case "getmsg":
if flag.NArg() < 2 { if flag.NArg() < 2 {
printError("MSG SERVICE: command error!") printError("MSG SERVICE: command error!")
showHelp() showHelp()
os.Exit(1) os.Exit(1)
} }
@ -83,14 +83,14 @@ func Run() {
} }
err = getMsgCommand(clientKeyStore, num) err = getMsgCommand(clientKeyStore, num)
if err != nil { if err != nil {
printError(err.Error()) printError(err.Error())
} }
case "help": case "help":
showHelp() showHelp()
default: default:
printError("MSG SERVICE: command error!") printError("MSG SERVICE: command error!")
showHelp() showHelp()
} }
@ -107,6 +107,7 @@ func sendCommand(clientKeyStore cryptoUtils.KeyStore, plainSubject, plainBody, u
return err return err
} }
// FIX: adapt to api
cl, err := networking.NewClient[protocol.Packet](&clientKeyStore) cl, err := networking.NewClient[protocol.Packet](&clientKeyStore)
if err != nil { if err != nil {
return err return err
@ -117,14 +118,17 @@ func sendCommand(clientKeyStore cryptoUtils.KeyStore, plainSubject, plainBody, u
if err != nil { if err != nil {
return err return err
} }
subject, err := clientKeyStore.EncryptMessageContent(receiverCert, plainSubjectBytes) // NOTE: this will stay the same
subject, err := clientKeyStore.EncryptMessageContent(receiverCert, uid, plainSubjectBytes)
if err != nil { if err != nil {
return err return err
} }
body, err := clientKeyStore.EncryptMessageContent(receiverCert, plainBodyBytes) body, err := clientKeyStore.EncryptMessageContent(receiverCert, uid, plainBodyBytes)
if err != nil { if err != nil {
return err return err
} }
// FIX: adapt to api
sendMsgPacket := protocol.NewSendMsgPacket(uid, subject, body) sendMsgPacket := protocol.NewSendMsgPacket(uid, subject, body)
if err := cl.Connection.Send(sendMsgPacket); err != nil { if err := cl.Connection.Send(sendMsgPacket); err != nil {
return err return err