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:
@ -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
|
||||
//
|
||||
|
Reference in New Issue
Block a user