Add Wipe function to Identity
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc 2024-03-30 22:44:59 +01:00
parent 13cfda928d
commit 54b932e9c1
2 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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
}