From f99f4f6acc6734ecbd0da80015285e6b3d39fdd8 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sun, 17 Sep 2023 23:21:57 -0400 Subject: Send memberlist on MUC join, suppress PM statuses for MUC JIDs --- xmpp/gateway/gateway.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'xmpp/gateway/gateway.go') 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" +} -- cgit v1.2.3