diff --git a/xmpp.go b/xmpp.go index 6f9e87a..4386245 100644 --- a/xmpp.go +++ b/xmpp.go @@ -1204,6 +1204,8 @@ type Chat struct { Lang string ID string ReplaceID string + ReplyID string + StanzaID string Roster Roster Other []string OtherElem []XMLElement @@ -1286,6 +1288,8 @@ func (c *Client) Recv() (stanza interface{}, err error) { Thread: v.Thread, ID: v.ID, ReplaceID: v.ReplaceID.ID, + ReplyID: v.ReplyID.ID, + StanzaID: v.StanzaID.ID, Other: v.OtherStrings(), OtherElem: v.Other, Stamp: stamp, @@ -1488,7 +1492,7 @@ func (c *Client) Recv() (stanza interface{}, err error) { // Send sends the message wrapped inside an XMPP message stanza body. func (c *Client) Send(chat Chat) (n int, err error) { - var subtext, thdtext, oobtext, msgidtext, msgcorrecttext string + var subtext, thdtext, oobtext, msgidtext, msgcorrecttext, replytext string if chat.Subject != `` { subtext = `` + xmlEscape(chat.Subject) + `` } @@ -1512,9 +1516,13 @@ func (c *Client) Send(chat Chat) (n int, err error) { msgcorrecttext = `` } + if chat.ReplyID != `` { + replytext = `` + } + chat.Text = validUTF8(chat.Text) - stanza := fmt.Sprintf(""+subtext+"%s"+msgcorrecttext+oobtext+thdtext+"", + stanza := fmt.Sprintf(""+subtext+"%s"+msgcorrecttext+replytext+oobtext+thdtext+"", xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text)) if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes { @@ -1768,6 +1776,18 @@ type clientMessageCorrect struct { ID string `xml:"id,attr"` } +type stanzaID struct { + XMLName xml.Name `xml:"urn:xmpp:sid:0 stanza-id"` + ID string `xml:"id,attr"` + By string `xml:"by,attr"` +} + +type clientReply struct { + XMLName xml.Name `xml:"urn:xmpp:reply:0 reply"` + ID string `xml:"id,attr"` + To string `xml:"to,attr"` +} + // RFC 3921 B.1 jabber:client type clientMessage struct { XMLName xml.Name `xml:"jabber:client message"` @@ -1782,6 +1802,8 @@ type clientMessage struct { Body string `xml:"body"` Thread string `xml:"thread"` ReplaceID clientMessageCorrect + StanzaID stanzaID + ReplyID clientReply // Pubsub Event clientPubsubEvent `xml:"event"`