Files
meowlib/client/invitation/messages/step2.go

34 lines
1.3 KiB
Go
Raw Normal View History

2026-04-11 22:05:30 +02:00
package messages
import (
"forge.redroom.link/yves/meowlib"
"forge.redroom.link/yves/meowlib/client"
)
// Step2InviteeCreatesInitiatorAndEncryptedContactCard creates the invitee's peer entry
2026-04-12 13:38:15 +02:00
// 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) {
2026-04-11 22:05:30 +02:00
mynick := myNickname
if mynick == "" {
mynick = client.GetConfig().GetIdentity().Nickname
}
peer, err := client.GetConfig().GetIdentity().InvitationStep2(mynick, nickname, serverUids, payload)
if err != nil {
2026-04-12 13:38:15 +02:00
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
2026-04-11 22:05:30 +02:00
}
client.GetConfig().GetIdentity().Save()
2026-04-12 13:38:15 +02:00
return packed, peer, nil
2026-04-11 22:05:30 +02:00
}