From b499992148978913aacac2e86248f0b89c6c81b7 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Wed, 10 Apr 2024 22:17:58 -0400 Subject: [PATCH] Fix missing read markers in other XMPP clients than the message sender --- telegram/handlers.go | 44 +++++++++++++++++++++----------------------- xmpp/handlers.go | 2 +- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/telegram/handlers.go b/telegram/handlers.go index 425309e..ed18e4f 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -56,30 +56,28 @@ func (c *Client) cleanTempFile(path string) { } func (c *Client) sendMarker(chatId, messageId int64, typ gateway.MarkerType) { - if xmppId, err := gateway.IdsDB.GetByTgIds(c.Session.Login, c.jid, chatId, messageId); err == nil { - resource := c.getFromOutbox(xmppId) - - var stringType string - if typ == gateway.MarkerTypeReceived { - stringType = "received" - } else if typ == gateway.MarkerTypeDisplayed { - stringType = "displayed" - } - log.WithFields(log.Fields{ - "xmppId": xmppId, - "resource": resource, - }).Debugf("marker: %s", stringType) - - if resource != "" { - gateway.SendMessageMarker( - c.jid+"/"+resource, - strconv.FormatInt(chatId, 10), - c.xmpp, - typ, - xmppId, - ) - } + xmppId, err := gateway.IdsDB.GetByTgIds(c.Session.Login, c.jid, chatId, messageId) + if err != nil { + xmppId = strconv.FormatInt(messageId, 10) } + + var stringType string + if typ == gateway.MarkerTypeReceived { + stringType = "received" + } else if typ == gateway.MarkerTypeDisplayed { + stringType = "displayed" + } + log.WithFields(log.Fields{ + "xmppId": xmppId, + }).Debugf("marker: %s", stringType) + + gateway.SendMessageMarker( + c.jid, + strconv.FormatInt(chatId, 10), + c.xmpp, + typ, + xmppId, + ) } func (c *Client) updateHandler() { diff --git a/xmpp/handlers.go b/xmpp/handlers.go index 8c6ba37..811cef6 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -203,7 +203,7 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { } else { err = gateway.IdsDB.Set(session.Session.Login, bare, toID, tgMessageId, msg.Id) if err == nil { - session.AddToOutbox(msg.Id, resource) + // session.AddToOutbox(msg.Id, resource) session.UpdateLastChatMessageId(toID, msg.Id) } else { log.Errorf("Failed to save ids %v/%v %v", toID, tgMessageId, msg.Id)