diff --git a/xmpp.go b/xmpp.go
index 6998f732..0afdd7e8 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -1451,6 +1451,7 @@ func (c *Client) IsEncrypted() bool {
// Chat is an incoming or outgoing XMPP chat message.
type Chat struct {
+ ID string
Remote string
Type string
Text string
@@ -1465,7 +1466,11 @@ type Chat struct {
// Only for incoming messages, ID for outgoing messages will be generated.
OriginID string
// Only for incoming messages, ID for outgoing messages will be generated.
- StanzaID StanzaID
+ StanzaID StanzaID
+ // XEP-0461: id of the message being replied to (use StanzaID for groupchat)
+ ReplyID string
+ // XEP-0461: JID of the author of the message being replied to
+ ReplyTo string
Roster Roster
Other []string
OtherElem []XMLElement
@@ -1550,6 +1555,7 @@ func (c *Client) Recv() (stanza interface{}, err error) {
v.Delay.Stamp,
)
chat := Chat{
+ ID: v.ID,
Remote: v.From,
Type: v.Type,
Text: v.Body,
@@ -1561,6 +1567,8 @@ func (c *Client) Recv() (stanza interface{}, err error) {
Lang: v.Lang,
OriginID: v.OriginID.ID,
StanzaID: v.StanzaID,
+ ReplyID: v.Reply.ID,
+ ReplyTo: v.Reply.To,
Oob: v.Oob,
}
return chat, nil
@@ -1852,10 +1860,22 @@ func (c *Client) Send(chat Chat) (n int, err error) {
oobtext += ``
}
+ var replytext string
+ if chat.ReplyID != `` {
+ replytext = ``
+ }
+
chat.Text = validUTF8(chat.Text)
- id := getUUID()
+ id := chat.ID
+ if id == "" {
+ id = getUUID()
+ }
stanza := fmt.Sprintf("%s%s"+
- "%s%s\n",
+ replytext+"%s%s\n",
xmlEscape(chat.Remote), xmlEscape(chat.Type), id, subtext, xmlEscape(chat.Text),
XMPPNS_SID_0, id, oobtext, thdtext)
if c.LimitMaxBytes != 0 && len(stanza) > c.LimitMaxBytes {
@@ -2166,6 +2186,13 @@ type StanzaID struct {
By string `xml:"by,attr"`
}
+// XEP-0461 Message Replies
+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"`
@@ -2184,6 +2211,9 @@ type clientMessage struct {
OriginID originID `xml:"origin-id"`
StanzaID StanzaID `xml:"stanza-id"`
+ // XEP-0461
+ Reply clientReply `xml:"reply"`
+
// Pubsub
Event clientPubsubEvent `xml:"event"`