diff options
author | Wim <wim@42.be> | 2018-05-09 22:38:17 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-05-09 22:38:17 +0200 |
commit | 8d307d8134a528d8e4a8f44ad98fccfd288acc42 (patch) | |
tree | d5daa2b4f3c648a152f849f3c4afa997035d7e50 /vendor/github.com/matterbridge/go-xmpp/xmpp.go | |
parent | 8c675b52bc9478e59be429d619e6414a2e621900 (diff) | |
download | matterbridge-msglm-8d307d8134a528d8e4a8f44ad98fccfd288acc42.tar.gz matterbridge-msglm-8d307d8134a528d8e4a8f44ad98fccfd288acc42.tar.bz2 matterbridge-msglm-8d307d8134a528d8e4a8f44ad98fccfd288acc42.zip |
Update vendor matterbridge/go-xmpp
Diffstat (limited to 'vendor/github.com/matterbridge/go-xmpp/xmpp.go')
-rw-r--r-- | vendor/github.com/matterbridge/go-xmpp/xmpp.go | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/vendor/github.com/matterbridge/go-xmpp/xmpp.go b/vendor/github.com/matterbridge/go-xmpp/xmpp.go index d3f31367..253b7613 100644 --- a/vendor/github.com/matterbridge/go-xmpp/xmpp.go +++ b/vendor/github.com/matterbridge/go-xmpp/xmpp.go @@ -573,6 +573,8 @@ type Chat struct { Text string Subject string Thread string + Ooburl string + Oobdesc string Roster Roster Other []string OtherElem []XMLElement @@ -654,16 +656,42 @@ func (c *Client) Recv() (stanza interface{}, err error) { func (c *Client) Send(chat Chat) (n int, err error) { var subtext = `` var thdtext = `` + var oobtext = `` if chat.Subject != `` { subtext = `<subject>` + xmlEscape(chat.Subject) + `</subject>` } if chat.Thread != `` { thdtext = `<thread>` + xmlEscape(chat.Thread) + `</thread>` } - return fmt.Fprintf(c.conn, "<message to='%s' type='%s' xml:lang='en'>"+subtext+"<body>%s</body>"+thdtext+"</message>", + if chat.Ooburl != `` { + oobtext = `<x xmlns="jabber:x:oob"><url>` + xmlEscape(chat.Ooburl) + `</url>` + if chat.Oobdesc != `` { + oobtext += `<desc>` + xmlEscape(chat.Oobdesc) + `</desc>` + } + oobtext += `</x>` + } + return fmt.Fprintf(c.conn, "<message to='%s' type='%s' xml:lang='en'>" + subtext + "<body>%s</body>" + oobtext + thdtext + "</message>", xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text)) } +// SendOOB sends OOB data wrapped inside an XMPP message stanza, without actual body. +func (c *Client) SendOOB(chat Chat) (n int, err error) { + var thdtext = `` + var oobtext = `` + if chat.Thread != `` { + thdtext = `<thread>` + xmlEscape(chat.Thread) + `</thread>` + } + if chat.Ooburl != `` { + oobtext = `<x xmlns="jabber:x:oob"><url>` + xmlEscape(chat.Ooburl) + `</url>` + if chat.Oobdesc != `` { + oobtext += `<desc>` + xmlEscape(chat.Oobdesc) + `</desc>` + } + oobtext += `</x>` + } + return fmt.Fprintf(c.conn, "<message to='%s' type='%s' xml:lang='en'>" + oobtext + thdtext + "</message>", + xmlEscape(chat.Remote), xmlEscape(chat.Type)) +} + // SendOrg sends the original text without being wrapped in an XMPP message stanza. func (c *Client) SendOrg(org string) (n int, err error) { return fmt.Fprint(c.conn, org) |