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 }