34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package messages
|
|
|
|
import (
|
|
"forge.redroom.link/yves/meowlib"
|
|
"forge.redroom.link/yves/meowlib/client"
|
|
)
|
|
|
|
// Step2InviteeCreatesInitiatorAndEncryptedContactCard creates the invitee's peer entry
|
|
// from an InvitationInitPayload, then builds the invitee's ContactCard and returns it
|
|
// as a PackedUserMessage asymmetrically encrypted with the initiator's temporary public
|
|
// key. The packed message is ready to be transmitted to the initiator via any transport
|
|
// (file, QR, server…); Step3InitiatorFinalizesInviteeAndCreatesContactCard on the
|
|
// initiator side will decrypt and process it.
|
|
func Step2InviteeCreatesInitiatorAndEncryptedContactCard(payload *meowlib.InvitationInitPayload, nickname string, myNickname string, serverUids []string) (*meowlib.PackedUserMessage, *client.Peer, error) {
|
|
mynick := myNickname
|
|
if mynick == "" {
|
|
mynick = client.GetConfig().GetIdentity().Nickname
|
|
}
|
|
peer, err := client.GetConfig().GetIdentity().InvitationStep2(mynick, nickname, serverUids, payload)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
usermsg, err := peer.BuildInvitationStep2Message(peer.GetMyContact())
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
packed, err := peer.ProcessOutboundUserMessage(usermsg)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
client.GetConfig().GetIdentity().Save()
|
|
return packed, peer, nil
|
|
}
|