aboutsummaryrefslogtreecommitdiff
path: root/xmpp/extensions/extensions.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-11-25 01:20:07 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-11-25 01:20:07 +0300
commitd6f6207ebb3d5256256a7810a3d3d0bdc8ba04a5 (patch)
treed52c3e2f4c7b4a46505b882782d850d28988ca11 /xmpp/extensions/extensions.go
parent653b1bde94b89d91862007a18b8730ff58673f59 (diff)
Refactoring: move SendPresence to xmpp/gateway package
Diffstat (limited to 'xmpp/extensions/extensions.go')
-rw-r--r--xmpp/extensions/extensions.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/xmpp/extensions/extensions.go b/xmpp/extensions/extensions.go
new file mode 100644
index 0000000..ec94837
--- /dev/null
+++ b/xmpp/extensions/extensions.go
@@ -0,0 +1,49 @@
+package extensions
+
+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{})
+}