aboutsummaryrefslogtreecommitdiff
path: root/xmpp/extensions/extensions.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-08-03 00:08:06 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-08-03 00:08:06 +0300
commitc03ccfdfb713d4fcb089600d9fd91f03e469daca (patch)
treed759d1fe9b227f3f2887411d579c51561996c0e9 /xmpp/extensions/extensions.go
parent608f67551297a14e2e23603413bbce66f6ad5cd9 (diff)
Support urn:xmpp:privilege:2v1.7.4
Diffstat (limited to 'xmpp/extensions/extensions.go')
-rw-r--r--xmpp/extensions/extensions.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/xmpp/extensions/extensions.go b/xmpp/extensions/extensions.go
index 2d547af..192b630 100644
--- a/xmpp/extensions/extensions.go
+++ b/xmpp/extensions/extensions.go
@@ -154,12 +154,19 @@ type CarbonSent struct {
}
// ComponentPrivilege is from XEP-0356
-type ComponentPrivilege struct {
+type ComponentPrivilege1 struct {
XMLName xml.Name `xml:"urn:xmpp:privilege:1 privilege"`
Perms []ComponentPerm `xml:"perm"`
Forwarded stanza.Forwarded `xml:"urn:xmpp:forward:0 forwarded"`
}
+// ComponentPrivilege is from XEP-0356
+type ComponentPrivilege2 struct {
+ XMLName xml.Name `xml:"urn:xmpp:privilege:2 privilege"`
+ Perms []ComponentPerm `xml:"perm"`
+ Forwarded stanza.Forwarded `xml:"urn:xmpp:forward:0 forwarded"`
+}
+
// ComponentPerm is from XEP-0356
type ComponentPerm struct {
XMLName xml.Name `xml:"perm"`
@@ -227,7 +234,12 @@ func (c CarbonSent) Namespace() string {
}
// Namespace is a namespace!
-func (c ComponentPrivilege) Namespace() string {
+func (c ComponentPrivilege1) Namespace() string {
+ return c.XMLName.Space
+}
+
+// Namespace is a namespace!
+func (c ComponentPrivilege2) Namespace() string {
return c.XMLName.Space
}
@@ -297,11 +309,17 @@ func init() {
"sent",
}, CarbonSent{})
- // component privilege
+ // component privilege v1
stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{
"urn:xmpp:privilege:1",
"privilege",
- }, ComponentPrivilege{})
+ }, ComponentPrivilege1{})
+
+ // component privilege v2
+ stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{
+ "urn:xmpp:privilege:2",
+ "privilege",
+ }, ComponentPrivilege2{})
// message edit
stanza.TypeRegistry.MapExtension(stanza.PKTMessage, xml.Name{