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/utils.go | |
parent | 81fc3ea3707cdf73b846ab55b2ecc5b8f68ccd21 (diff) |
Request and send to Telegram XEP-0333 displayed markers by "receipts" option
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 21 |
1 files changed, 14 insertions, 7 deletions
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) |