Add 'id' to outgoing message using cnonce

This commit is contained in:
Richard Phillips 2018-05-04 12:20:46 +01:00 committed by Yasuhiro Matsumoto
parent 8a5843171f
commit 4fdbee9ac5
No known key found for this signature in database
GPG Key ID: 622DE34DC490584B

10
xmpp.go
View File

@ -660,8 +660,11 @@ func (c *Client) Send(chat Chat) (n int, err error) {
if chat.Thread != `` { if chat.Thread != `` {
thdtext = `<thread>` + xmlEscape(chat.Thread) + `</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>",
xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text)) stanza := "<message to='%s' type='%s' id='%s' xml:lang='en'>" + subtext + "<body>%s</body>" + thdtext + "</message>"
return fmt.Fprintf(c.conn, stanza,
xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce(), xmlEscape(chat.Text))
} }
// SendOrg sends the original text without being wrapped in an XMPP message stanza. // SendOrg sends the original text without being wrapped in an XMPP message stanza.
@ -836,7 +839,8 @@ type clientPresence struct {
Error *clientError Error *clientError
} }
type clientIQ struct { // info/query type clientIQ struct {
// info/query
XMLName xml.Name `xml:"jabber:client iq"` XMLName xml.Name `xml:"jabber:client iq"`
From string `xml:"from,attr"` From string `xml:"from,attr"`
ID string `xml:"id,attr"` ID string `xml:"id,attr"`