aboutsummaryrefslogtreecommitdiff
path: root/xmpp/gateway
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-09-18 06:21:57 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-09-18 06:21:57 +0300
commitf99f4f6acc6734ecbd0da80015285e6b3d39fdd8 (patch)
tree1edb75e85dab67337cc4d795cb66677242df1d55 /xmpp/gateway
parent776993894ad780f1500c139aff85378c8a1d22f5 (diff)
Send memberlist on MUC join, suppress PM statuses for MUC JIDs
Diffstat (limited to 'xmpp/gateway')
-rw-r--r--xmpp/gateway/gateway.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go
index dfe2ebf..c09a061 100644
--- a/xmpp/gateway/gateway.go
+++ b/xmpp/gateway/gateway.go
@@ -240,6 +240,9 @@ var SPResource = args.NewString()
// SPImmed skips queueing
var SPImmed = args.NewBool(args.Default(true))
+// SPAffiliation is a XEP-0045 MUC affiliation
+var SPAffiliation = args.NewString()
+
func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
var presenceFrom string
if SPFrom.IsSet(args) {
@@ -295,6 +298,17 @@ func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
})
}
}
+ if SPAffiliation.IsSet(args) {
+ affiliation := SPAffiliation.Get(args)
+ if affiliation != "" {
+ presence.Extensions = append(presence.Extensions, extensions.PresenceXMucUserExtension{
+ Item: extensions.PresenceXMucUserItem{
+ Affiliation: affiliation,
+ Role: affilationToRole(affiliation),
+ },
+ })
+ }
+ }
return presence
}
@@ -377,3 +391,13 @@ func SplitJID(from string) (string, string, bool) {
}
return fromJid.Bare(), fromJid.Resource, true
}
+
+func affilationToRole(affilation string) string {
+ switch affilation {
+ case "owner", "admin":
+ return "moderator"
+ case "member":
+ return "participant"
+ }
+ return "none"
+}