diff options
author | George Hazan <george.hazan@gmail.com> | 2024-04-19 12:53:36 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-04-19 12:53:36 +0300 |
commit | ab21ce3ccfe7d076d6de1606b280690e9399b59f (patch) | |
tree | 54017e79682c2c3b19fc1713839cbeaa80b98056 /protocols/Telegram | |
parent | 99f6af5d383916168d6edb1b7a05fd64b633f03b (diff) |
Telegram: part of events aren't marked read during history load
Diffstat (limited to 'protocols/Telegram')
-rw-r--r-- | protocols/Telegram/src/proto.h | 4 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 19 |
3 files changed, 13 insertions, 12 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 2fcc8b65d6..a917ed4457 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -281,10 +281,10 @@ class CTelegramProto : public PROTO<CTelegramProto> void UnregisterSession(); - bool GetMessageFile(TG_FILE_REQUEST::Type, TG_USER *pUser, const TD::file *pFile, const char *pszFileName, const std::string &caption, const char *szId, const char *szUser, const TD::message *pMsg); + bool GetMessageFile(TG_FILE_REQUEST::Type, TG_USER *pUser, const TD::file *pFile, const char *pszFileName, const std::string &caption, const char *szId, const char *szUser, const TD::message *pMsg, bool bRead); CMStringA GetMessagePreview(const TD::file *pFile); CMStringA GetMessageSticker(const TD::file *pFile, const char *pwszExtension); - CMStringA GetMessageText(TG_USER *pUser, const TD::message *pMsg, bool bSkipJoin = false); + CMStringA GetMessageText(TG_USER *pUser, const TD::message *pMsg, bool bSkipJoin = false, bool bRead = false); void UpdateString(MCONTACT hContact, const char *pszSetting, const std::string &str); diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index d5755cbed1..8701579763 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -432,7 +432,7 @@ void CTelegramProto::OnGetHistory(td::ClientManager::Response &response, void *p if (db_event_getById(m_szModuleName, szMsgId))
continue;
- CMStringA szBody = GetMessageText(pUser, pMsg, true), szReplyId;
+ CMStringA szBody = GetMessageText(pUser, pMsg, true, true), szReplyId;
if (szBody.IsEmpty())
continue;
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 34201b930d..4fa25bb11f 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -403,7 +403,8 @@ bool CTelegramProto::GetMessageFile( const std::string &caption,
const char *pszId,
const char *pszUserId,
- const TD::message *pMsg)
+ const TD::message *pMsg,
+ bool bRead)
{
if (pFile->get_id() != TD::file::ID) {
debugLogA("Document contains unsupported type %d, exiting", pFile->get_id());
@@ -429,7 +430,7 @@ bool CTelegramProto::GetMessageFile( szDesc = caption.c_str();
if (pMsg->is_outgoing_)
dbei.flags |= DBEF_SENT;
- if (!pUser->bInited)
+ if (!pUser->bInited || bRead)
dbei.flags |= DBEF_READ;
if (pMsg->reply_to_message_id_) {
_i64toa(pMsg->reply_to_message_id_, szReplyId, 10);
@@ -507,7 +508,7 @@ static bool checkStickerType(uint32_t ID) }
}
-CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg, bool bSkipJoin)
+CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg, bool bSkipJoin, bool bRead)
{
const TD::MessageContent *pBody = pMsg->content_.get();
@@ -557,7 +558,7 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg }
CMStringA fileName(FORMAT, "%s (%d x %d)", TranslateU("Picture"), pPhoto->width_, pPhoto->height_);
- GetMessageFile(TG_FILE_REQUEST::PICTURE, pUser, pPhoto->photo_.get(), fileName, pDoc->caption_->text_, szMsgId, pszUserId, pMsg);
+ GetMessageFile(TG_FILE_REQUEST::PICTURE, pUser, pPhoto->photo_.get(), fileName, pDoc->caption_->text_, szMsgId, pszUserId, pMsg, bRead);
}
break;
@@ -570,7 +571,7 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg caption += " ";
caption += pDoc->caption_->text_;
}
- GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pAudio->audio_.get(), pAudio->file_name_.c_str(), caption, szMsgId, pszUserId, pMsg);
+ GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pAudio->audio_.get(), pAudio->file_name_.c_str(), caption, szMsgId, pszUserId, pMsg, bRead);
}
break;
@@ -583,7 +584,7 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg caption += " ";
caption += pDoc->caption_->text_;
}
- GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pVideo->video_.get(), pVideo->file_name_.c_str(), caption, szMsgId, pszUserId, pMsg);
+ GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pVideo->video_.get(), pVideo->file_name_.c_str(), caption, szMsgId, pszUserId, pMsg, bRead);
}
break;
@@ -596,20 +597,20 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg caption += " ";
caption += pDoc->caption_->text_;
}
- GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pVideo->animation_.get(), pVideo->file_name_.c_str(), caption, szMsgId, pszUserId, pMsg);
+ GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pVideo->animation_.get(), pVideo->file_name_.c_str(), caption, szMsgId, pszUserId, pMsg, bRead);
}
break;
case TD::messageVoiceNote::ID:
if (auto *pDoc = (TD::messageVoiceNote *)pBody) {
CMStringA fileName(FORMAT, "%s (%d %s)", TranslateU("Voice message"), pDoc->voice_note_->duration_, TranslateU("seconds"));
- GetMessageFile(TG_FILE_REQUEST::VOICE, pUser, pDoc->voice_note_->voice_.get(), fileName, pDoc->caption_->text_, szMsgId, pszUserId, pMsg);
+ GetMessageFile(TG_FILE_REQUEST::VOICE, pUser, pDoc->voice_note_->voice_.get(), fileName, pDoc->caption_->text_, szMsgId, pszUserId, pMsg, bRead);
}
break;
case TD::messageDocument::ID:
if (auto *pDoc = (TD::messageDocument *)pBody)
- GetMessageFile(TG_FILE_REQUEST::FILE, pUser, pDoc->document_->document_.get(), pDoc->document_->file_name_.c_str(), pDoc->caption_->text_, szMsgId, pszUserId, pMsg);
+ GetMessageFile(TG_FILE_REQUEST::FILE, pUser, pDoc->document_->document_.get(), pDoc->document_->file_name_.c_str(), pDoc->caption_->text_, szMsgId, pszUserId, pMsg, bRead);
break;
case TD::messageAnimatedEmoji::ID:
|