summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-09-06 15:14:07 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-09-06 15:14:07 +0300
commit38b24044db30c606e9bb3ebe0849b16c9fdc6e62 (patch)
treeaf2822805df50b5f3cc18abc2d709ace3140342d /protocols/Telegram/src/proto.cpp
parent5e232971e1eb3a0ce665a3e34b982db49676e653 (diff)
fixes #3667 (Telegram: add message edit feature)
Diffstat (limited to 'protocols/Telegram/src/proto.cpp')
-rw-r--r--protocols/Telegram/src/proto.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index b3a6b2466e..98d055af2b 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -216,6 +216,24 @@ void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent)
}
}
+void CTelegramProto::OnEventEdited(MCONTACT hContact, MEVENT, const DBEVENTINFO &dbei)
+{
+ if (!hContact)
+ return;
+
+ auto *pUser = FindUser(GetId(hContact));
+ if (!pUser)
+ return;
+
+ if (dbei.szId && dbei.cbBlob && dbei.eventType == EVENTTYPE_MESSAGE) {
+ auto text = TD::make_object<TD::formattedText>();
+ text->text_ = (char*)dbei.pBlob;
+
+ auto content = TD::make_object<TD::inputMessageText>(std::move(text), false, false);
+ SendQuery(new TD::editMessageText(pUser->chatId, _atoi64(dbei.szId), 0, std::move(content)));
+ }
+}
+
void CTelegramProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
{
if (!hContact)
@@ -225,9 +243,8 @@ void CTelegramProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
if (!pUser)
return;
- DBEVENTINFO dbei = {};
- db_event_get(hDbEvent, &dbei);
- if (dbei.szId) {
+ DB::EventInfo dbei(hDbEvent, false);
+ if (dbei && dbei.szId) {
mir_cslock lck(m_csMarkRead);
if (m_markChatId) {
if (m_markChatId != hContact)