Invitation process store my server card+ server invitation fields
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc
2023-12-31 10:24:15 +01:00
parent 922668e2a3
commit 0998845817
2 changed files with 16 additions and 14 deletions

View File

@ -43,34 +43,33 @@ func CreateIdentity(nickname string) *Identity {
}
// Creates an invitation for a peer, returns the peer containing
func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerIdxs []int) (*Peer, *meowlib.ContactCard, error) {
func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerIdxs []int) (*Peer, error) {
var peer Peer
var myContactCard meowlib.ContactCard
peer.MyIdentity = meowlib.NewKeyPair()
peer.MyEncryptionKp = meowlib.NewKeyPair()
peer.MyLookupKp = meowlib.NewKeyPair()
peer.Name = ContactName
peer.InvitationId = uuid.New().String()
peer.InvitationId = uuid.New().String() // todo as param to identify then update url
if id.MessageServers.Servers == nil {
return nil, nil, errors.New("no message servers defined in your identity")
return nil, errors.New("no message servers defined in your identity")
}
for _, i := range MessageServerIdxs {
if i > len(id.MessageServers.Servers)-1 {
return nil, nil, errors.New("requested server out of range of defined message servers")
return nil, errors.New("requested server out of range of defined message servers")
}
}
for _, i := range MessageServerIdxs {
srv := &id.MessageServers.Servers[i].ServerData
myContactCard.PullServers = append(myContactCard.PullServers, srv)
peer.MyContact.PullServers = append(peer.MyContact.PullServers, srv)
}
myContactCard.Name = MyName
myContactCard.ContactPublicKey = peer.MyIdentity.Public
myContactCard.EncryptionPublicKey = peer.MyEncryptionKp.Public
myContactCard.LookupPublicKey = peer.MyLookupKp.Public
myContactCard.InvitationId = peer.InvitationId
peer.MyContact.Name = MyName
peer.MyContact.ContactPublicKey = peer.MyIdentity.Public
peer.MyContact.EncryptionPublicKey = peer.MyEncryptionKp.Public
peer.MyContact.LookupPublicKey = peer.MyLookupKp.Public
peer.MyContact.InvitationId = peer.InvitationId
id.Peers = append(id.Peers, peer)
return &peer, &myContactCard, nil
return &peer, nil
}
func (id *Identity) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string) {