diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-06-08 20:14:55 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2023-06-08 20:14:55 +0300 |
commit | 945b9c063b8bcf20f0df370fd1f68457f84f3361 (patch) | |
tree | 4569ed1278b1ee3b6dfa830001605b222801c3f8 /xmpp | |
parent | 7215d11d7973b9896c6223938649c75165fa3ae7 (diff) |
Reply own messages
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/handlers.go | 24 |
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 { |