This commit is contained in:
parent
33c42f32d2
commit
54c2048f58
17
lib.go
17
lib.go
|
@ -41,6 +41,12 @@ var acnQueue event.Queue
|
||||||
var contactEventsQueue event.Queue
|
var contactEventsQueue event.Queue
|
||||||
var globalACN connectivity.ACN
|
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 {
|
type ChatMessage struct {
|
||||||
O int `json:"o"`
|
O int `json:"o"`
|
||||||
D string `json:"d"`
|
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)
|
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) {
|
func SendInvitation(profileOnion, handle, target string) {
|
||||||
profile := application.GetPeer(profileOnion)
|
profile := application.GetPeer(profileOnion)
|
||||||
ph := utils.NewPeerHelper(profile)
|
ph := utils.NewPeerHelper(profile)
|
||||||
|
@ -547,14 +556,8 @@ func SendInvitation(profileOnion, handle, target string) {
|
||||||
inviteBytes, err := json.Marshal(invite)
|
inviteBytes, err := json.Marshal(invite)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("malformed invite: %v", err)
|
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 {
|
} else {
|
||||||
contactHandler, _ := contact.FunctionalityGate(utils.ReadGlobalSettings().Experiments)
|
SendMessage(profileOnion, handle, string(inviteBytes))
|
||||||
contactHandler.SendMessage(profile, handle, string(inviteBytes))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue