aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'telegram/utils.go')
-rw-r--r--telegram/utils.go21
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)