diff --git a/client/identity.go b/client/identity.go index fc0c63a..5bc38ff 100644 --- a/client/identity.go +++ b/client/identity.go @@ -78,11 +78,14 @@ func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerU // Checks if the received contact card is an answer to an invitation, returns true if it is, and the proposed and received nicknames func (id *Identity) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string, invitationMessage string) { + // invitation Id found, this is an answer to an invitation for _, p := range id.Peers { if p.InvitationId == ReceivedContact.InvitationId { return true, p.Name, ReceivedContact.Name, ReceivedContact.InvitationMessage } } + + // it's an invitation return false, "", ReceivedContact.Name, ReceivedContact.InvitationMessage } diff --git a/client/messagestorage.go b/client/messagestorage.go index 710bc45..1246c9a 100644 --- a/client/messagestorage.go +++ b/client/messagestorage.go @@ -18,6 +18,8 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, password string) // TODO : if file size > X new db if len(peer.DbIds) == 0 { dbid = uuid.NewString() + peer.DbIds = []string{dbid} + GetConfig().me.Save() file, err := os.Create(filepath.Join(GetConfig().StoragePath, dbid+GetConfig().DbSuffix)) if err != nil { return err @@ -30,7 +32,6 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, password string) return err } sqliteDatabase.Close() - GetConfig().me.Save() } else { dbid = peer.DbIds[len(peer.DbIds)-1] } diff --git a/client/peer.go b/client/peer.go index 1412470..c039467 100644 --- a/client/peer.go +++ b/client/peer.go @@ -85,6 +85,13 @@ func (p *Peer) GetContact() *meowlib.ContactCard { return &c } +func (p *Peer) InvitationPending() bool { + if p.ContactPublicKey == "" { + return true + } + return false +} + // // Messages building // diff --git a/doc/sq_inv.puml b/doc/sq_inv.puml new file mode 100644 index 0000000..c228355 --- /dev/null +++ b/doc/sq_inv.puml @@ -0,0 +1,7 @@ +@startuml Server Invitation Step 01 +Bob -> MeowBob: Create invitation for alice +Bob -> Alice: Send invitation +Alice -> MeowAlice: Accept Invitation and create answer +Alice -> Bob: Send answer +Bob -> MeowBob: Review Answer, invitation finalize +@enduml \ No newline at end of file diff --git a/doc/sq_srvinv04.puml b/doc/sq_srvinv04.puml index 2a85d36..460cbed 100644 --- a/doc/sq_srvinv04.puml +++ b/doc/sq_srvinv04.puml @@ -1,9 +1,8 @@ @startuml Server Invitation Step 03 Bastet -> NativeLib : periodic message check -Bastet -> NativeLib : build accept message -NativeLib -> Bastet : invitationGetMessage -Bastet -> Server : send accept message +NativeLib -> Server : get new messages +Server -> NativeLib : send invitation message Server -> Redis : store accept message Server -> Bastet : accept message ok Bastet -> User : msg sent