Reply own messages

This commit is contained in:
Bohdan Horbeshko 2023-06-08 13:14:55 -04:00
parent 7215d11d79
commit 945b9c063b

View file

@ -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 {