diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-11-14 23:11:04 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-11-14 23:11:04 +0300 |
commit | 736abcb5bc3a7e2c0f1f1dfd3052cb6153b60d02 (patch) | |
tree | d98db15053f0889f999ae60e0fd67be8c3a963f9 /xmpp/extensions.go | |
parent | 47cf94ad01b4db8749c55c1a1dca50c9b94daf02 (diff) |
Send presence for recovered sessions
Diffstat (limited to 'xmpp/extensions.go')
-rw-r--r-- | xmpp/extensions.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/xmpp/extensions.go b/xmpp/extensions.go new file mode 100644 index 0000000..2270431 --- /dev/null +++ b/xmpp/extensions.go @@ -0,0 +1,49 @@ +package xmpp + +import ( + "encoding/xml" + + "gosrc.io/xmpp/stanza" +) + +// PresenceNickExtension is from XEP-0172 +type PresenceNickExtension struct { + XMLName xml.Name `xml:"http://jabber.org/protocol/nick nick"` + Text string `xml:",chardata"` +} + +// PresenceXVCardUpdateExtension is from XEP-0153 +type PresenceXVCardUpdateExtension struct { + XMLName xml.Name `xml:"vcard-temp:x:update x"` + Photo PresenceXVCardUpdatePhoto +} + +// PresenceXVCardUpdatePhoto is from XEP-0153 +type PresenceXVCardUpdatePhoto struct { + XMLName xml.Name `xml:"photo"` + Text string `xml:",chardata"` +} + +// Namespace is a namespace! +func (c PresenceNickExtension) Namespace() string { + return c.XMLName.Space +} + +// Namespace is a namespace! +func (c PresenceXVCardUpdateExtension) Namespace() string { + return c.XMLName.Space +} + +func init() { + // presence nick + stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{ + "http://jabber.org/protocol/nick", + "nick", + }, PresenceNickExtension{}) + + // presence vcard update + stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{ + "vcard-temp:x:update", + "x", + }, PresenceXVCardUpdateExtension{}) +} |