diff options
Diffstat (limited to 'xmpp/gateway/gateway.go')
-rw-r--r-- | xmpp/gateway/gateway.go | 24 |
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" +} |