aboutsummaryrefslogtreecommitdiff
path: root/xmpp/gateway/gateway.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/gateway/gateway.go')
-rw-r--r--xmpp/gateway/gateway.go43
1 files changed, 29 insertions, 14 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go
index 11f68c1..be1f6a3 100644
--- a/xmpp/gateway/gateway.go
+++ b/xmpp/gateway/gateway.go
@@ -13,7 +13,7 @@ import (
)
// Queue stores presences to send later
-type Queue map[string]*stanza.Presence
+var Queue = make(map[string]*stanza.Presence)
// Jid stores the component's JID object
var Jid *xmpp.Jid
@@ -101,32 +101,47 @@ func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
}}
if SPType.IsSet(args) {
- presence.Attrs.Type = stanza.StanzaType(SPType.Get(args))
+ t := SPType.Get(args)
+ if t != "" {
+ presence.Attrs.Type = stanza.StanzaType(t)
+ }
}
if SPShow.IsSet(args) {
- presence.Show = stanza.PresenceShow(SPShow.Get(args))
+ show := SPShow.Get(args)
+ if show != "" {
+ presence.Show = stanza.PresenceShow(show)
+ }
}
if SPStatus.IsSet(args) {
- presence.Status = SPStatus.Get(args)
+ status := SPStatus.Get(args)
+ if status != "" {
+ presence.Status = status
+ }
}
if SPNickname.IsSet(args) {
- presence.Extensions = append(presence.Extensions, extensions.PresenceNickExtension{
- Text: SPNickname.Get(args),
- })
+ nickname := SPNickname.Get(args)
+ if nickname != "" {
+ presence.Extensions = append(presence.Extensions, extensions.PresenceNickExtension{
+ Text: nickname,
+ })
+ }
}
if SPPhoto.IsSet(args) {
- presence.Extensions = append(presence.Extensions, extensions.PresenceXVCardUpdateExtension{
- Photo: extensions.PresenceXVCardUpdatePhoto{
- Text: SPPhoto.Get(args),
- },
- })
+ photo := SPPhoto.Get(args)
+ if photo != "" {
+ presence.Extensions = append(presence.Extensions, extensions.PresenceXVCardUpdateExtension{
+ Photo: extensions.PresenceXVCardUpdatePhoto{
+ Text: photo,
+ },
+ })
+ }
}
return presence
}
// SendPresence creates and sends a presence stanza
-func SendPresence(component *xmpp.Component, queue Queue, to string, args ...args.V) error {
+func SendPresence(component *xmpp.Component, to string, args ...args.V) error {
var logFrom string
bareJid := Jid.Bare()
if SPFrom.IsSet(args) {
@@ -161,7 +176,7 @@ func SendPresence(component *xmpp.Component, queue Queue, to string, args ...arg
return err
}
} else {
- queue[presence.From+presence.To] = &presence
+ Queue[presence.From+presence.To] = &presence
}
return nil