diff options
author | Wim <wim@42.be> | 2020-04-18 20:58:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-18 20:58:55 +0200 |
commit | 8a87a71927d8560ccd993a986be4e7eb34ad46da (patch) | |
tree | 52ca770695db4b0f220d31b17a1835b58929d94d /vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go | |
parent | 0047e6f52370d4581c53276e67828b075091ead8 (diff) | |
download | matterbridge-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/github.com/matterbridge/go-xmpp/xmpp_disco.go')
-rw-r--r-- | vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go | 99 |
1 files changed, 99 insertions, 0 deletions
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 +} |