Server invitation process functions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ycc
2023-11-14 16:32:50 +01:00
parent 65f9ee2e07
commit 432f449558
8 changed files with 134 additions and 85 deletions

View File

@ -44,7 +44,8 @@ func CreateIdentity(nickname string) *Identity {
return &id
}
func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerIdxs []int) (*meowlib.ContactCard, error) {
// Creates an invitation for a peer, returns the peer containing
func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerIdxs []int) (*Peer, *meowlib.ContactCard, error) {
var peer Peer
var myContactCard meowlib.ContactCard
peer.MyIdentity = meowlib.NewKeyPair()
@ -53,11 +54,11 @@ func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerI
peer.Name = ContactName
peer.InvitationId = uuid.New().String()
if id.MessageServers.Servers == nil {
return nil, errors.New("no message servers defined in your identity")
return nil, nil, errors.New("no message servers defined in your identity")
}
for _, i := range MessageServerIdxs {
if i > len(id.MessageServers.Servers)-1 {
return nil, errors.New("requested server out of range of defined message servers")
return nil, nil, errors.New("requested server out of range of defined message servers")
}
}
for _, i := range MessageServerIdxs {
@ -71,7 +72,7 @@ func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerI
myContactCard.InvitationId = peer.InvitationId
id.Peers = append(id.Peers, peer)
return &myContactCard, nil
return &peer, &myContactCard, nil
}
func (id *Identity) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string) {