From bdfa8c7bb19f3eafd31c3197a9929f0b01b55880 Mon Sep 17 00:00:00 2001 From: ycc Date: Fri, 29 Mar 2024 16:18:24 +0100 Subject: [PATCH] ReadMessage fix --- client/helpers/backgroundHelper.go | 61 ++++++++++++++---------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/client/helpers/backgroundHelper.go b/client/helpers/backgroundHelper.go index 0f27375..9d6f16a 100644 --- a/client/helpers/backgroundHelper.go +++ b/client/helpers/backgroundHelper.go @@ -167,7 +167,7 @@ func ReadMessage(messageFilename string, detachFilesStoragePath string) ([]strin } } - return messagesOverview, filenames, "", nil + } // fmt.Println("have read fromServerMessage, will unmarshal packed") @@ -180,40 +180,35 @@ func ReadMessage(messageFilename string, detachFilesStoragePath string) ([]strin // fmt.Println("Destination:", packedMessage.Destination) // fmt.Println("Payload lengh:", len(packedMessage.Pay ""load)) // server invitation finalize or more ? -/* - if fromServerMessage.Invitation != nil { - fmt.Println("Invitation from:", fromServerMessage.Invitation.From) - // find the peer with that lookup key - // todo get from invitation id - //! FOLOWING statement is WRONG ! - peer := client.GetConfig().GetIdentity().Peers.GetFromPublicKey(fromServerMessage.Invitation.From) - if peer == nil { - return nil, nil, "ReadMessage: GetFromPublicKey", errors.New("no visible peer for that message") - } - peer.ContactPublicKey = fromServerMessage.Invitation.From - str, _ := json.Marshal(peer) - fmt.Println("Peer:", string(str)) - // invitation message - var receivedContactCard meowlib.ContactCard - err := proto.Unmarshal(fromServerMessage.Invitation.Payload, &receivedContactCard) - if err != nil { - return "", "ReadMessage: Unmarshal ContactCard", err - } - err = client.GetConfig().GetIdentity().FinalizeInvitation(&receivedContactCard) - if err != nil { - return "", "ReadMessage: FinalizeInvitation", err - } - result["invitation finalized"] = peer.Name - */ + /* + if fromServerMessage.Invitation != nil { + fmt.Println("Invitation from:", fromServerMessage.Invitation.From) + // find the peer with that lookup key + // todo get from invitation id + //! FOLOWING statement is WRONG ! + peer := client.GetConfig().GetIdentity().Peers.GetFromPublicKey(fromServerMessage.Invitation.From) + if peer == nil { + return nil, nil, "ReadMessage: GetFromPublicKey", errors.New("no visible peer for that message") + } + peer.ContactPublicKey = fromServerMessage.Invitation.From + str, _ := json.Marshal(peer) + fmt.Println("Peer:", string(str)) + // invitation message + var receivedContactCard meowlib.ContactCard + err := proto.Unmarshal(fromServerMessage.Invitation.Payload, &receivedContactCard) + if err != nil { + return "", "ReadMessage: Unmarshal ContactCard", err + } + err = client.GetConfig().GetIdentity().FinalizeInvitation(&receivedContactCard) + if err != nil { + return "", "ReadMessage: FinalizeInvitation", err + } + result["invitation finalized"] = peer.Name - } + + }*/ // message // including list of detached files - val, err := json.Marshal(result) - if err != nil { - return "", "ReadMessage: json.Marshal", err - } - os.Remove(messageFilename) - return string(val), "", nil + return messagesOverview, filenames, "", nil }