mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-24 03:32:02 -08:00
Update matterbridge/go-xmpp to add PEP-0030 support (#1095)
This commit is contained in:
parent
0047e6f523
commit
8a87a71927
2
go.mod
2
go.mod
@ -24,7 +24,7 @@ require (
|
|||||||
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048
|
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048
|
||||||
github.com/matterbridge/discordgo v0.18.1-0.20200308151012-aa40f01cbcc3
|
github.com/matterbridge/discordgo v0.18.1-0.20200308151012-aa40f01cbcc3
|
||||||
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
||||||
github.com/matterbridge/go-xmpp v0.0.0-20200329150250-5812999b292b
|
github.com/matterbridge/go-xmpp v0.0.0-20200418162626-e69b0b8696ef
|
||||||
github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6
|
github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6
|
||||||
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18
|
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18
|
||||||
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61
|
github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61
|
||||||
|
4
go.sum
4
go.sum
@ -130,8 +130,8 @@ github.com/matterbridge/discordgo v0.18.1-0.20200308151012-aa40f01cbcc3 h1:VP/DN
|
|||||||
github.com/matterbridge/discordgo v0.18.1-0.20200308151012-aa40f01cbcc3/go.mod h1:5a1bHtG/38ofcx9cgwM5eTW/Pl4SpbQksNDnTRcGA2Y=
|
github.com/matterbridge/discordgo v0.18.1-0.20200308151012-aa40f01cbcc3/go.mod h1:5a1bHtG/38ofcx9cgwM5eTW/Pl4SpbQksNDnTRcGA2Y=
|
||||||
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible h1:oaOqwbg5HxHRxvAbd84ks0Okwoc1ISyUZ87EiVJFhGI=
|
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible h1:oaOqwbg5HxHRxvAbd84ks0Okwoc1ISyUZ87EiVJFhGI=
|
||||||
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible/go.mod h1:igE6rUAn3jai2wCdsjFHfhUoekjrFthoEjFObKKwSb4=
|
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible/go.mod h1:igE6rUAn3jai2wCdsjFHfhUoekjrFthoEjFObKKwSb4=
|
||||||
github.com/matterbridge/go-xmpp v0.0.0-20200329150250-5812999b292b h1:ZYI2HCj9zPzI4Si1ouSOi/ImA2xSQLUCJPQsLWr8FE0=
|
github.com/matterbridge/go-xmpp v0.0.0-20200418162626-e69b0b8696ef h1:CDIIh3ZViXddwWh9vctOmOOQPXhWeuHdGnwNkPc5JtE=
|
||||||
github.com/matterbridge/go-xmpp v0.0.0-20200329150250-5812999b292b/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
|
github.com/matterbridge/go-xmpp v0.0.0-20200418162626-e69b0b8696ef/go.mod h1:ECDRehsR9TYTKCAsRS8/wLeOk6UUqDydw47ln7wG41Q=
|
||||||
github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6 h1:Kl65VJv38HjYFnnwH+MP6Z8hcJT5UHuSpHVU5vW1HH0=
|
github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6 h1:Kl65VJv38HjYFnnwH+MP6Z8hcJT5UHuSpHVU5vW1HH0=
|
||||||
github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6/go.mod h1:+jWeaaUtXQbBRdKYWfjW6JDDYiI2XXE+3NnTjW5kg8g=
|
github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6/go.mod h1:+jWeaaUtXQbBRdKYWfjW6JDDYiI2XXE+3NnTjW5kg8g=
|
||||||
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18 h1:fLhwXtWGtfTgZVxHG1lcKjv+re7dRwyyuYFNu69xdho=
|
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18 h1:fLhwXtWGtfTgZVxHG1lcKjv+re7dRwyyuYFNu69xdho=
|
||||||
|
49
vendor/github.com/matterbridge/go-xmpp/xmpp.go
generated
vendored
49
vendor/github.com/matterbridge/go-xmpp/xmpp.go
generated
vendored
@ -713,15 +713,44 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
|||||||
Errors: errsStr,
|
Errors: errsStr,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
case v.Type == "result" && v.ID == "unsub1":
|
case v.Type == "result":
|
||||||
// Unsubscribing MAY contain a pubsub element. But it does
|
switch v.ID {
|
||||||
// not have to
|
case "unsub1":
|
||||||
return PubsubUnsubscription{
|
// Unsubscribing MAY contain a pubsub element. But it does
|
||||||
SubID: "",
|
// not have to
|
||||||
JID: v.From,
|
return PubsubUnsubscription{
|
||||||
Node: "",
|
SubID: "",
|
||||||
Errors: nil,
|
JID: v.From,
|
||||||
}, nil
|
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":
|
case v.Query.XMLName.Local == "pubsub":
|
||||||
switch v.ID {
|
switch v.ID {
|
||||||
case "sub1":
|
case "sub1":
|
||||||
@ -1049,6 +1078,8 @@ type clientIQ struct {
|
|||||||
Query XMLElement `xml:",any"`
|
Query XMLElement `xml:",any"`
|
||||||
Error clientError
|
Error clientError
|
||||||
Bind bindBind
|
Bind bindBind
|
||||||
|
|
||||||
|
InnerXML []byte `xml:",innerxml"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientError struct {
|
type clientError struct {
|
||||||
|
99
vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go
generated
vendored
Normal file
99
vendor/github.com/matterbridge/go-xmpp/xmpp_disco.go
generated
vendored
Normal file
@ -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
|
||||||
|
}
|
20
vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
generated
vendored
20
vendor/github.com/matterbridge/go-xmpp/xmpp_information_query.go
generated
vendored
@ -10,10 +10,26 @@ const IQTypeSet = "set"
|
|||||||
const IQTypeResult = "result"
|
const IQTypeResult = "result"
|
||||||
|
|
||||||
func (c *Client) Discovery() (string, error) {
|
func (c *Client) Discovery() (string, error) {
|
||||||
const namespace = "http://jabber.org/protocol/disco#items"
|
|
||||||
// use getCookie for a pseudo random id.
|
// use getCookie for a pseudo random id.
|
||||||
reqID := strconv.FormatUint(uint64(getCookie()), 10)
|
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.
|
// RawInformationQuery sends an information query request to the server.
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -103,7 +103,7 @@ github.com/matterbridge/Rocket.Chat.Go.SDK/rest
|
|||||||
github.com/matterbridge/discordgo
|
github.com/matterbridge/discordgo
|
||||||
# github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
# github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
|
||||||
github.com/matterbridge/emoji
|
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/go-xmpp
|
||||||
# github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6
|
# github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6
|
||||||
github.com/matterbridge/gomatrix
|
github.com/matterbridge/gomatrix
|
||||||
|
Loading…
Reference in New Issue
Block a user