aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/handlers.go24
1 files changed, 17 insertions, 7 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index 51fd831..5034551 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -114,13 +114,23 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
var err error
text := msg.Body
if len(reply.Id) > 0 {
- id := reply.Id
- if id[0] == 'e' {
- id = id[1:]
- }
- replyId, err = strconv.ParseInt(id, 10, 64)
- if err != nil {
- log.Warn(errors.Wrap(err, "Failed to parse message ID!"))
+ chatId, msgId, err := gateway.IdsDB.GetByXmppId(session.Session.Login, bare, reply.Id)
+ if err == nil {
+ if chatId != toID {
+ log.Warnf("Chat mismatch: %v ≠ %v", chatId, toID)
+ } else {
+ replyId = msgId
+ log.Debugf("replace tg: %#v %#v", chatId, msgId)
+ }
+ } else {
+ id := reply.Id
+ if id[0] == 'e' {
+ id = id[1:]
+ }
+ replyId, err = strconv.ParseInt(id, 10, 64)
+ if err != nil {
+ log.Warn(errors.Wrap(err, "Failed to parse message ID!"))
+ }
}
if replyId != 0 && fallback.For == "urn:xmpp:reply:0" && len(fallback.Body) > 0 {