addressing comments on #38
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
erinn 2021-05-11 15:35:58 -07:00
parent 33c42f32d2
commit 54c2048f58
1 changed files with 10 additions and 7 deletions

17
lib.go
View File

@ -41,6 +41,12 @@ var acnQueue event.Queue
var contactEventsQueue event.Queue
var globalACN connectivity.ACN
// ChatMessage API currently not officially documented, see
// https://git.openprivacy.ca/cwtch.im/secure-development-handbook/issues/3
// for latest updates for now
//
// A ChatMessage is the application-layer Cwtch message, delivered to the UI
// as serialized json.
type ChatMessage struct {
O int `json:"o"`
D string `json:"d"`
@ -529,6 +535,9 @@ func c_SendInvitation(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char
SendInvitation(profile, handle, target)
}
// Send an invitation from `profileOnion` to contact `handle` (peer or group)
// asking them to add the contact `target` (also peer or group).
// For groups, the profile must already have `target` as a contact.
func SendInvitation(profileOnion, handle, target string) {
profile := application.GetPeer(profileOnion)
ph := utils.NewPeerHelper(profile)
@ -547,14 +556,8 @@ func SendInvitation(profileOnion, handle, target string) {
inviteBytes, err := json.Marshal(invite)
if err != nil {
log.Errorf("malformed invite: %v", err)
} else if ph.IsGroup(handle) {
groupHandler, groupHandlerErr := groups.ExperimentGate(utils.ReadGlobalSettings().Experiments)
if groupHandlerErr == nil {
groupHandler.SendMessage(profile, handle, string(inviteBytes))
}
} else {
contactHandler, _ := contact.FunctionalityGate(utils.ReadGlobalSettings().Experiments)
contactHandler.SendMessage(profile, handle, string(inviteBytes))
SendMessage(profileOnion, handle, string(inviteBytes))
}
}