aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/extensions/extensions.go11
-rw-r--r--xmpp/gateway/gateway.go16
2 files changed, 23 insertions, 4 deletions
diff --git a/xmpp/extensions/extensions.go b/xmpp/extensions/extensions.go
index 0b7269f..1c32fcd 100644
--- a/xmpp/extensions/extensions.go
+++ b/xmpp/extensions/extensions.go
@@ -215,8 +215,9 @@ type QueryRegisterRemove struct {
// PresenceXMucUserExtension is from XEP-0045
type PresenceXMucUserExtension struct {
- XMLName xml.Name `xml:"http://jabber.org/protocol/muc#user x"`
- Item PresenceXMucUserItem
+ XMLName xml.Name `xml:"http://jabber.org/protocol/muc#user x"`
+ Item PresenceXMucUserItem
+ Statuses []PresenceXMucUserStatus
}
// PresenceXMucUserItem is from XEP-0045
@@ -226,6 +227,12 @@ type PresenceXMucUserItem struct {
Role string `xml:"role,attr"`
}
+// PresenceXMucUserStatus is from XEP-0045
+type PresenceXMucUserStatus struct {
+ XMLName xml.Name `xml:"status"`
+ Code uint16 `xml:"code,attr"`
+}
+
// Namespace is a namespace!
func (c PresenceNickExtension) Namespace() string {
return c.XMLName.Space
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go
index c09a061..e4a1be7 100644
--- a/xmpp/gateway/gateway.go
+++ b/xmpp/gateway/gateway.go
@@ -243,6 +243,9 @@ var SPImmed = args.NewBool(args.Default(true))
// SPAffiliation is a XEP-0045 MUC affiliation
var SPAffiliation = args.NewString()
+// SPMUCStatusCodes is a set of XEP-0045 MUC status codes
+var SPMUCStatusCodes = args.New()
+
func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
var presenceFrom string
if SPFrom.IsSet(args) {
@@ -301,12 +304,21 @@ 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{
+ userExt := extensions.PresenceXMucUserExtension{
Item: extensions.PresenceXMucUserItem{
Affiliation: affiliation,
Role: affilationToRole(affiliation),
},
- })
+ }
+ if SPMUCStatusCodes.IsSet(args) {
+ statusCodes := SPMUCStatusCodes.Get(args).([]uint16)
+ for _, statusCode := range statusCodes {
+ userExt.Statuses = append(userExt.Statuses, extensions.PresenceXMucUserStatus{
+ Code: statusCode,
+ })
+ }
+ }
+ presence.Extensions = append(presence.Extensions, userExt)
}
}