summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/matterbridge/go-xmpp/xmpp.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-03-29 17:35:40 +0200
committerGitHub <noreply@github.com>2020-03-29 17:35:40 +0200
commita18807f19e98c1f2cafddc28ab3f838b44b68fa1 (patch)
treec73f54b24d561b1712f1fa4e0b0b117e07d3976a /vendor/github.com/matterbridge/go-xmpp/xmpp.go
parent29f658fd3cda71aec88e5eb3fb59b30b19be5508 (diff)
downloadmatterbridge-msglm-a18807f19e98c1f2cafddc28ab3f838b44b68fa1.tar.gz
matterbridge-msglm-a18807f19e98c1f2cafddc28ab3f838b44b68fa1.tar.bz2
matterbridge-msglm-a18807f19e98c1f2cafddc28ab3f838b44b68fa1.zip
Update matterbridge/go-xmpp to add xmpp avatar support (#1070)
Diffstat (limited to 'vendor/github.com/matterbridge/go-xmpp/xmpp.go')
-rw-r--r--vendor/github.com/matterbridge/go-xmpp/xmpp.go54
1 files changed, 49 insertions, 5 deletions
diff --git a/vendor/github.com/matterbridge/go-xmpp/xmpp.go b/vendor/github.com/matterbridge/go-xmpp/xmpp.go
index cc13218e..bb1438e9 100644
--- a/vendor/github.com/matterbridge/go-xmpp/xmpp.go
+++ b/vendor/github.com/matterbridge/go-xmpp/xmpp.go
@@ -644,7 +644,20 @@ func (c *Client) Recv() (stanza interface{}, err error) {
case *clientMessage:
if v.Event.XMLNS == XMPPNS_PUBSUB_EVENT {
// Handle Pubsub notifications
- return pubsubClientToReturn(v.Event), nil
+ switch v.Event.Items.Node {
+ case XMPPNS_AVATAR_PEP_METADATA:
+ return handleAvatarMetadata(v.Event.Items.Items[0].Body,
+ v.From)
+ // I am not sure whether this can even happen.
+ // XEP-0084 only specifies a subscription to
+ // the metadata node.
+ /*case XMPPNS_AVATAR_PEP_DATA:
+ return handleAvatarData(v.Event.Items.Items[0].Body,
+ v.From,
+ v.Event.Items.Items[0].ID)*/
+ default:
+ return pubsubClientToReturn(v.Event), nil
+ }
}
stamp, _ := time.Parse(
@@ -745,10 +758,41 @@ func (c *Client) Recv() (stanza interface{}, err error) {
return PubsubItems{}, err
}
- return PubsubItems{
- p.Node,
- pubsubItemsToReturn(p.Items),
- }, nil
+ switch p.Node {
+ case XMPPNS_AVATAR_PEP_DATA:
+ return handleAvatarData(p.Items[0].Body,
+ v.From,
+ p.Items[0].ID)
+ case XMPPNS_AVATAR_PEP_METADATA:
+ return handleAvatarMetadata(p.Items[0].Body,
+ v.From)
+ default:
+ return PubsubItems{
+ p.Node,
+ pubsubItemsToReturn(p.Items),
+ }, nil
+ }
+ // Note: XEP-0084 states that metadata and data
+ // should be fetched with an id of retrieve1.
+ // Since we already have PubSub implemented, we
+ // can just use items1 and items3 to do the same
+ // as an Avatar node is just a PEP (PubSub) node.
+ /*case "retrieve1":
+ var p clientPubsubItems
+ err := xml.Unmarshal([]byte(v.Query.InnerXML), &p)
+ if err != nil {
+ return PubsubItems{}, err
+ }
+
+ switch p.Node {
+ case XMPPNS_AVATAR_PEP_DATA:
+ return handleAvatarData(p.Items[0].Body,
+ v.From,
+ p.Items[0].ID)
+ case XMPPNS_AVATAR_PEP_METADATA:
+ return handleAvatarMetadata(p.Items[0].Body,
+ v
+ }*/
}
case v.Query.XMLName.Local == "":
return IQ{ID: v.ID, From: v.From, To: v.To, Type: v.Type}, nil