store fix + add peer invitationPending Check
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
c4b61e16c5
commit
4b3d7548bd
@ -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
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
}
|
||||
|
@ -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
|
||||
//
|
||||
|
7
doc/sq_inv.puml
Normal file
7
doc/sq_inv.puml
Normal file
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user