Fix id clash for OOB caption messages

This commit is contained in:
Bohdan Horbeshko 2025-08-27 12:32:12 -04:00
parent f2867a7fc3
commit 7c9ea42f99
2 changed files with 6 additions and 1 deletions

View file

@ -1984,13 +1984,16 @@ func (c *Client) SendMessageToGateway(chatId int64, message *client.Message, id
// forward message to XMPP // forward message to XMPP
var sId string var sId string
var stanzaId string var stanzaId string
var auxId string
strId := strconv.FormatInt(message.Id, 10) strId := strconv.FormatInt(message.Id, 10)
if id == "" { if id == "" {
sId = strId sId = strId
stanzaId = strId stanzaId = strId
auxId = "c"+strId
} else { } else {
sId = id sId = id
stanzaId = strId stanzaId = strId
auxId = ""
} }
var from string var from string
@ -2031,7 +2034,7 @@ func (c *Client) SendMessageToGateway(chatId int64, message *client.Message, id
for _, jid := range jids { for _, jid := range jids {
gateway.SendMessageWithOOB(jid, from, text, sId, c.xmpp, reply, timestamp, oob, "", isCarbon, isGroupchat, c.Session.Receipts, originalFrom, stanzaId, mamQueryId, mucJID, mucUserItem) gateway.SendMessageWithOOB(jid, from, text, sId, c.xmpp, reply, timestamp, oob, "", isCarbon, isGroupchat, c.Session.Receipts, originalFrom, stanzaId, mamQueryId, mucJID, mucUserItem)
if auxText != "" { if auxText != "" {
gateway.SendMessage(jid, from, auxText, sId, c.xmpp, reply, timestamp, "", isCarbon, isGroupchat, c.Session.Receipts, originalFrom, stanzaId, mamQueryId, mucJID, mucUserItem) gateway.SendMessage(jid, from, auxText, auxId, c.xmpp, reply, timestamp, "", isCarbon, isGroupchat, c.Session.Receipts, originalFrom, auxId, mamQueryId, mucJID, mucUserItem)
} }
} }
c.UpdateLastChatMessageId(chatId, sId) c.UpdateLastChatMessageId(chatId, sId)

View file

@ -2908,6 +2908,8 @@ func parseMessageId(sId string) (int64, bool) {
if len(idParts) >= 1 { if len(idParts) >= 1 {
sId = idParts[0] sId = idParts[0]
} }
} else if sId[0] == 'c' {
sId = sId[1:]
} }
id, err := strconv.ParseInt(sId, 10, 64) id, err := strconv.ParseInt(sId, 10, 64)
if err != nil { if err != nil {