diff --git a/xmpp.go b/xmpp.go
index 169bb0a..6f9e87a 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -1202,6 +1202,8 @@ type Chat struct {
Ooburl string
Oobdesc string
Lang string
+ ID string
+ ReplaceID string
Roster Roster
Other []string
OtherElem []XMLElement
@@ -1282,6 +1284,8 @@ func (c *Client) Recv() (stanza interface{}, err error) {
Text: v.Body,
Subject: v.Subject,
Thread: v.Thread,
+ ID: v.ID,
+ ReplaceID: v.ReplaceID.ID,
Other: v.OtherStrings(),
OtherElem: v.Other,
Stamp: stamp,
@@ -1484,7 +1488,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 string
+ var subtext, thdtext, oobtext, msgidtext, msgcorrecttext string
if chat.Subject != `` {
subtext = `` + xmlEscape(chat.Subject) + ``
}
@@ -1498,10 +1502,21 @@ func (c *Client) Send(chat Chat) (n int, err error) {
}
oobtext += ``
}
+ if chat.ID != `` {
+ msgidtext = `id='` + xmlEscape(chat.ID) + `'`
+ } else {
+ msgidtext = `id='` + cnonce() + `'`
+ }
+
+ if chat.ReplaceID != `` {
+ msgcorrecttext = ``
+ }
chat.Text = validUTF8(chat.Text)
- stanza := fmt.Sprintf(""+subtext+"%s"+oobtext+thdtext+"\n",
- xmlEscape(chat.Remote), xmlEscape(chat.Type), cnonce(), xmlEscape(chat.Text))
+
+ stanza := fmt.Sprintf(""+subtext+"%s"+msgcorrecttext+oobtext+thdtext+"",
+ xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text))
+
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
return 0, fmt.Errorf("stanza size (%v bytes) exceeds server limit (%v bytes)",
len(stanza), c.LimitMaxBytes)
@@ -1748,6 +1763,11 @@ type bindBind struct {
Jid string `xml:"jid"`
}
+type clientMessageCorrect struct {
+ XMLName xml.Name `xml:"urn:xmpp:message-correct:0 replace"`
+ ID string `xml:"id,attr"`
+}
+
// RFC 3921 B.1 jabber:client
type clientMessage struct {
XMLName xml.Name `xml:"jabber:client message"`
@@ -1758,9 +1778,10 @@ type clientMessage struct {
Lang string `xml:"lang,attr"`
// These should technically be []clientText, but string is much more convenient.
- Subject string `xml:"subject"`
- Body string `xml:"body"`
- Thread string `xml:"thread"`
+ Subject string `xml:"subject"`
+ Body string `xml:"body"`
+ Thread string `xml:"thread"`
+ ReplaceID clientMessageCorrect
// Pubsub
Event clientPubsubEvent `xml:"event"`