summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-04-18 20:58:55 +0200
committerGitHub <noreply@github.com>2020-04-18 20:58:55 +0200
commit8a87a71927d8560ccd993a986be4e7eb34ad46da (patch)
tree52ca770695db4b0f220d31b17a1835b58929d94d /vendor
parent0047e6f52370d4581c53276e67828b075091ead8 (diff)
downloadmatterbridge-msglm-8a87a71927d8560ccd993a986be4e7eb34ad46da.tar.gz
matterbridge-msglm-8a87a71927d8560ccd993a986be4e7eb34ad46da.tar.bz2
matterbridge-msglm-8a87a71927d8560ccd993a986be4e7eb34ad46da.zip
Update matterbridge/go-xmpp to add PEP-0030 support (#1095)
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp.go49
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go99
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go20
-rw-r--r--vendor/modules.txt2
4 files changed, 158 insertions, 12 deletions
diff --git a/vendor/github.com/matterbridge/go-xmpp/xmpp.go b/vendor/github.com/matterbridge/go-xmpp/xmpp.go
index bb1438e9..3d2f8bf9 100644
--- a/vendor/github.com/matterbridge/go-xmpp/xmpp.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp.go
@@ -713,15 +713,44 @@ func (c *Client) Recv() (stanza interface{}, err error) {
Errors: errsStr,
}, nil
}
- case v.Type == "result" && v.ID == "unsub1":
- // Unsubscribing MAY contain a pubsub element. But it does
- // not have to
- return PubsubUnsubscription{
- SubID: "",
- JID: v.From,
- Node: "",
- Errors: nil,
- }, nil
+ case v.Type == "result":
+ switch v.ID {
+ case "unsub1":
+ // Unsubscribing MAY contain a pubsub element. But it does
+ // not have to
+ return PubsubUnsubscription{
+ SubID: "",
+ JID: v.From,
+ Node: "",
+ Errors: nil,
+ }, nil
+ case "info1":
+ if v.Query.XMLName.Space == XMPPNS_DISCO_ITEMS {
+ var itemsQuery clientDiscoItemsQuery
+ err := xml.Unmarshal(v.InnerXML, &itemsQuery)
+ if err != nil {
+ return []DiscoItem{}, err
+ }
+
+ return DiscoItems{
+ Jid: v.From,
+ Items: clientDiscoItemsToReturn(itemsQuery.Items),
+ }, nil
+ }
+ case "info3":
+ if v.Query.XMLName.Space == XMPPNS_DISCO_INFO {
+ var disco clientDiscoQuery
+ err := xml.Unmarshal(v.InnerXML, &disco)
+ if err != nil {
+ return DiscoResult{}, err
+ }
+
+ return DiscoResult{
+ Features: clientFeaturesToReturn(disco.Features),
+ Identities: clientIdentitiesToReturn(disco.Identities),
+ }, nil
+ }
+ }
case v.Query.XMLName.Local == "pubsub":
switch v.ID {
case "sub1":
@@ -1049,6 +1078,8 @@ type clientIQ struct {
Query XMLElement `xml:",any"`
Error clientError
Bind bindBind
+
+ InnerXML []byte `xml:",innerxml"`
}
type clientError struct {
diff --git a/vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go b/vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go
new file mode 100644
index 00000000..0bca664a
--- /dev/null
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go
@@ -0,0 +1,99 @@
+package xmpp
+
+import (
+ "encoding/xml"
+)
+
+const (
+ XMPPNS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
+ XMPPNS_DISCO_INFO = "http://jabber.org/protocol/disco#info"
+)
+
+type clientDiscoFeature struct {
+ XMLName xml.Name `xml:"feature"`
+ Var string `xml:"var,attr"`
+}
+
+type clientDiscoIdentity struct {
+ XMLName xml.Name `xml:"identity"`
+ Category string `xml:"category,attr"`
+ Type string `xml:"type,attr"`
+ Name string `xml:"name,attr"`
+}
+
+type clientDiscoQuery struct {
+ XMLName xml.Name `xml:"query"`
+ Features []clientDiscoFeature `xml:"feature"`
+ Identities []clientDiscoIdentity `xml:"identity"`
+}
+
+type clientDiscoItem struct {
+ XMLName xml.Name `xml:"item"`
+ Jid string `xml:"jid,attr"`
+ Node string `xml:"node,attr"`
+ Name string `xml:"name,attr"`
+}
+
+type clientDiscoItemsQuery struct {
+ XMLName xml.Name `xml:"query"`
+ Items []clientDiscoItem `xml:"item"`
+}
+
+type DiscoIdentity struct {
+ Category string
+ Type string
+ Name string
+}
+
+type DiscoItem struct {
+ Jid string
+ Name string
+ Node string
+}
+
+type DiscoResult struct {
+ Features []string
+ Identities []DiscoIdentity
+}
+
+type DiscoItems struct {
+ Jid string
+ Items []DiscoItem
+}
+
+func clientFeaturesToReturn(features []clientDiscoFeature) []string {
+ var ret []string
+
+ for _, feature := range features {
+ ret = append(ret, feature.Var)
+ }
+
+ return ret
+}
+
+func clientIdentitiesToReturn(identities []clientDiscoIdentity) []DiscoIdentity {
+ var ret []DiscoIdentity
+
+ for _, id := range identities {
+ ret = append(ret, DiscoIdentity{
+ Category: id.Category,
+ Type: id.Type,
+ Name: id.Name,
+ })
+ }
+
+ return ret
+}
+
+func clientDiscoItemsToReturn(items []clientDiscoItem) []DiscoItem {
+ var ret []DiscoItem
+ for _, item := range items {
+ ret = append(ret, DiscoItem{
+ Jid: item.Jid,
+ Name: item.Name,
+ Node: item.Node,
+ })
+ }
+
+ return ret
+}
diff --git a/vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go b/vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
index 2a699222..15114c9f 100644
--- a/vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
@@ -10,10 +10,26 @@ const IQTypeSet = "set"
const IQTypeResult = "result"
func (c *Client) Discovery() (string, error) {
- const namespace = "http://jabber.org/protocol/disco#items"
// use getCookie for a pseudo random id.
reqID := strconv.FormatUint(uint64(getCookie()), 10)
- return c.RawInformationQuery(c.jid, c.domain, reqID, IQTypeGet, namespace, "")
+ return c.RawInformationQuery(c.jid, c.domain, reqID, IQTypeGet, XMPPNS_DISCO_ITEMS, "")
+}
+
+// Discover information about a node
+func (c *Client) DiscoverNodeInfo(node string) (string, error) {
+ query := fmt.Sprintf("<query xmlns='%s' node='%s'/>", XMPPNS_DISCO_INFO, node)
+ return c.RawInformation(c.jid, c.domain, "info3", IQTypeGet, query)
+}
+
+// Discover items that the server exposes
+func (c *Client) DiscoverServerItems() (string, error) {
+ return c.DiscoverEntityItems(c.domain)
+}
+
+// Discover items that an entity exposes
+func (c *Client) DiscoverEntityItems(jid string) (string, error) {
+ query := fmt.Sprintf("<query xmlns='%s'/>", XMPPNS_DISCO_ITEMS)
+ return c.RawInformation(c.jid, jid, "info1", IQTypeGet, query)
}
// RawInformationQuery sends an information query request to the server.
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 6e33ec3c..7877b634 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -103,7 +103,7 @@ github.com/matterbridge/Rocket.Chat.Go.SDK/rest
github.com/matterbridge/discordgo
# github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
github.com/matterbridge/emoji
-# github.com/matterbridge/go-xmpp v0.0.0-20200329150250-5812999b292b
+# github.com/matterbridge/go-xmpp v0.0.0-20200418162626-e69b0b8696ef
github.com/matterbridge/go-xmpp
# github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6
github.com/matterbridge/gomatrix