package helpers import ( "forge.redroom.link/yves/meowlib" "forge.redroom.link/yves/meowlib/client" "google.golang.org/protobuf/proto" ) // InvitationGetAnswer // Called by the invitation initiator // invitationId: the id of the invitation // serverUid: the uid of the server holding the invitation answer func InvitationGetAnswer(invitationId string, serverUid string) ([]byte, string, error) { // check if already in msg servers srv, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(serverUid) if err != nil { return nil, "InvitationGetAnswer: LoadServer", err } // buildserver message toSrvMsg, err := srv.BuildToServerMessageInvitationAnswerRequest(invitationId) if err != nil { return nil, "InvitationGetAnswer: BuildToServerMessageInvitationRequest", err } // processoutbound bytemsg, err := srv.ProcessOutboundMessage(toSrvMsg) if err != nil { return nil, "InvitationGetAnswer: ProcessOutboundMessage", err } return bytemsg, "", nil } // InvitationGetAnswerReadResponse // Called by the invitation initiator // invitationAnswerData: the data received from the server // invitationServerUid: the uid of the server holding the invitation func InvitationGetAnswerReadResponse(invitationAnswerData []byte, invitationServerUid string) (string, error) { server, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(invitationServerUid) if err != nil { return "InvitationGetAnswerReadResponse: LoadServer", err } // Server inbound processing : get the invitation server serverMsg, err := server.ProcessInboundServerResponse(invitationAnswerData) if err != nil { return "InvitationGetAnswerReadResponse: ProcessInboundServerResponse", err } // fmt.Println("Inbound OK, Invitation Step: ", serverMsg.Invitation.Step, len(serverMsg.Invitation.Payload)) // fmt.Println("Invitation Check") // fmt.Println(hex.EncodeToString(serverMsg.Invitation.Payload)) // contactCard decode // decode the payload var invitationAnswer meowlib.PackedUserMessage err = proto.Unmarshal(serverMsg.Invitation.Payload, &invitationAnswer) if err != nil { return "InvitationGetAnswerReadResponse: Unmarshal", err } // retreive user public key to check usermessage signature //contactPublikKey := serverMsg.Invitation.From // process the packed user message // finalize the invitation // id := client.GetConfig().GetIdentity() // cc, err := id.FinalizeInvitation(serverMsg.Invitation.) return "", nil }