aboutsummaryrefslogtreecommitdiff
path: root/xmpp/gateway
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-08-03 00:08:06 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-08-03 00:08:06 +0300
commitc03ccfdfb713d4fcb089600d9fd91f03e469daca (patch)
treed759d1fe9b227f3f2887411d579c51561996c0e9 /xmpp/gateway
parent608f67551297a14e2e23603413bbce66f6ad5cd9 (diff)
Support urn:xmpp:privilege:2v1.7.4
Diffstat (limited to 'xmpp/gateway')
-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)