diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2024-01-27 14:13:45 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2024-01-27 14:13:45 +0300 |
commit | 599cf16cdbb8567cf2ab1ce42aee5f493884de96 (patch) | |
tree | bc9be25328223d6ce5b3c3d3868496dd0ccdc75e /telegram | |
parent | 81fc3ea3707cdf73b846ab55b2ecc5b8f68ccd21 (diff) |
Request and send to Telegram XEP-0333 displayed markers by "receipts" option
Diffstat (limited to 'telegram')
-rw-r--r-- | telegram/commands.go | 1 | ||||
-rw-r--r-- | telegram/handlers.go | 2 | ||||
-rw-r--r-- | telegram/utils.go | 21 |
3 files changed, 16 insertions, 8 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index 19fd655..b5c856e 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -202,6 +202,7 @@ func (c *Client) sendMessagesReverse(chatID int64, messages []*client.Message) { c.xmpp, reply, false, + false, ) } } diff --git a/telegram/handlers.go b/telegram/handlers.go index 6f6d339..c715932 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -298,7 +298,7 @@ func (c *Client) updateMessageContent(update *client.UpdateMessageContent) { markupFunction, )) for _, jid := range jids { - gateway.SendMessage(jid, strconv.FormatInt(update.ChatId, 10), text, "e"+strconv.FormatInt(update.MessageId, 10), c.xmpp, nil, false) + gateway.SendMessage(jid, strconv.FormatInt(update.ChatId, 10), text, "e"+strconv.FormatInt(update.MessageId, 10), c.xmpp, nil, false, false) } } } diff --git a/telegram/utils.go b/telegram/utils.go index 6aab03a..966c5c2 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -1074,24 +1074,31 @@ func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message) { } // mark message as read - c.client.ViewMessages(&client.ViewMessagesRequest{ - ChatId: chatId, - MessageIds: []int64{message.Id}, - ForceRead: true, - }) + if !c.Session.Receipts { + c.MarkAsRead(chatId, message.Id) + } // forward message to XMPP sId := strconv.FormatInt(message.Id, 10) sChatId := strconv.FormatInt(chatId, 10) for _, jid := range jids { - gateway.SendMessageWithOOB(jid, sChatId, text, sId, c.xmpp, reply, oob, isCarbon) + gateway.SendMessageWithOOB(jid, sChatId, text, sId, c.xmpp, reply, oob, isCarbon, c.Session.Receipts) if auxText != "" { - gateway.SendMessage(jid, sChatId, auxText, sId, c.xmpp, reply, isCarbon) + gateway.SendMessage(jid, sChatId, auxText, sId, c.xmpp, reply, isCarbon, c.Session.Receipts) } } } +// MarkAsRead marks a message as read +func (c *Client) MarkAsRead(chatId, messageId int64) { + c.client.ViewMessages(&client.ViewMessagesRequest{ + ChatId: chatId, + MessageIds: []int64{messageId}, + ForceRead: true, + }) +} + // PrepareMessageContent creates a simple text message func (c *Client) PrepareOutgoingMessageContent(text string) client.InputMessageContent { return c.prepareOutgoingMessageContent(text, nil) |