aboutsummaryrefslogtreecommitdiff
path: root/xmpp/gateway/gateway.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/gateway/gateway.go')
-rw-r--r--xmpp/gateway/gateway.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go
index 1be2fca..7a2500e 100644
--- a/xmpp/gateway/gateway.go
+++ b/xmpp/gateway/gateway.go
@@ -38,8 +38,8 @@ var IdsDB badger.IdsDB
// were changed and need to be re-flushed to the YamlDB
var DirtySessions = false
-// MessageOutgoingPermission allows to fake outgoing messages by foreign JIDs
-var MessageOutgoingPermission = false
+// MessageOutgoingPermissionVersion contains a XEP-0356 version to fake outgoing messages by foreign JIDs
+var MessageOutgoingPermissionVersion = 0
// SendMessage creates and sends a message stanza
func SendMessage(to string, from string, body string, id string, component *xmpp.Component, reply *Reply, isCarbon bool) {
@@ -142,11 +142,19 @@ func sendMessageWrapper(to string, from string, body string, id string, componen
To: toJid.Domain,
},
}
- privilegeMessage.Extensions = append(privilegeMessage.Extensions, extensions.ComponentPrivilege{
- Forwarded: stanza.Forwarded{
- Stanza: carbonMessage,
- },
- })
+ if MessageOutgoingPermissionVersion == 2 {
+ privilegeMessage.Extensions = append(privilegeMessage.Extensions, extensions.ComponentPrivilege2{
+ Forwarded: stanza.Forwarded{
+ Stanza: carbonMessage,
+ },
+ })
+ } else {
+ privilegeMessage.Extensions = append(privilegeMessage.Extensions, extensions.ComponentPrivilege1{
+ Forwarded: stanza.Forwarded{
+ Stanza: carbonMessage,
+ },
+ })
+ }
sendMessage(&privilegeMessage, component)
} else {
sendMessage(&message, component)