From 54b932e9c1c8bf7b419c78ac78dd7b899a471ead Mon Sep 17 00:00:00 2001 From: ycc Date: Sat, 30 Mar 2024 22:44:59 +0100 Subject: [PATCH] Add Wipe function to Identity --- client/identity.go | 8 ++++++++ server/router.go | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client/identity.go b/client/identity.go index 783f7eb..3f3a8e4 100644 --- a/client/identity.go +++ b/client/identity.go @@ -58,6 +58,14 @@ func (id *Identity) CreateFolder() error { return nil } +func (id *Identity) Wipe() error { + err := os.RemoveAll(filepath.Join(GetConfig().StoragePath, id.Uuid)) + if err != nil { + return err + } + return nil +} + // Creates an invitation for a peer, returns the newly created peer including infos to provide a ContactCard func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerUids []string, InvitationMessage string) (*Peer, error) { var peer Peer diff --git a/server/router.go b/server/router.go index 0f4b2c1..f835011 100644 --- a/server/router.go +++ b/server/router.go @@ -43,7 +43,7 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe if err != nil { panic(err) } - // user message + // user message => store if len(msg.Messages) > 0 { // update messages counter err := r.Client.Incr("statistics:messages:usermessages").Err() @@ -62,6 +62,7 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe } // check for messages if len(msg.PullRequest) > 0 { + //dataFound := false // update messages counter err := r.Client.Incr("statistics:messages:messagelookups").Err() if err != nil { @@ -96,13 +97,15 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe if msgcnt == 0 { // get invitation answer var answer meowlib.Invitation - storedAanswer, err := r.GetAnswerToInvitation(rq.LookupKey) + storedAnswer, err := r.GetAnswerToInvitation(rq.LookupKey) if err != nil { - err := proto.Unmarshal(storedAanswer, &answer) + err := proto.Unmarshal(storedAnswer, &answer) if err != nil { from_server.Invitation.Payload = []byte("invitation answer corrupted") } from_server.Invitation = &answer + // exit loop if invitation found, cannot store several in a message + break } // add invitation answer to the response }