From 06d7b7d0fd02af55b5c5183cc04a9c2ac04a4163 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Jun 2023 19:24:47 +0300 Subject: =?UTF-8?q?#3542=20(Telegram:=20=D0=B8=D1=81=D1=85=D0=BE=D0=B4?= =?UTF-8?q?=D1=8F=D1=89=D0=B8=D0=B5=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D1=8E=D1=82=D1=81=D1=8F=20=D0=BA=D0=B0=D0=BA=20=D0=B2=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=D1=8F=D1=89=D0=B8=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/m_protosvc.h | 2 ++ protocols/Telegram/src/proto.h | 2 +- protocols/Telegram/src/utils.cpp | 19 ++++++++++--------- src/core/stdfile/src/file.cpp | 4 +++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/m_protosvc.h b/include/m_protosvc.h index 19bbad22f3..e4dc10c841 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -771,6 +771,8 @@ EXTERN_C MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, PROTORECVEV #define PRFF_UNICODE 0x0001 // in all MAllCStrings .w is valid #define PRFF_UTF 0x0002 // in all MAllCStrings .a contains text in UTF8 #define PRFF_SILENT 0x0004 // do not show file send/receive dialog +#define PRFF_SENT 0x0008 // this is an outgoing file +#define PRFF_READ 0x0010 // this event is marked read struct PROTORECVFILE { diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 3142f65826..0e397eca0d 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -246,7 +246,7 @@ class CTelegramProto : public PROTO void ProcessSuperGroup(TD::updateSupergroup *pObj); void ProcessUser(TD::updateUser *pObj); - 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, time_t); + 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); CMStringA GetMessageSticker(const TD::file *pFile, const char *pwszExtension); CMStringA GetMessageText(TG_USER *pUser, const TD::message *pMsg); diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 5aedf57407..17286c3649 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -277,7 +277,7 @@ bool CTelegramProto::GetMessageFile( const std::string &caption, const char *pszId, const char *pszUserId, - time_t timestamp) + const TD::message *pMsg) { if (pFile->get_id() != TD::file::ID) { debugLogA("Document contains unsupported type %d, exiting", pFile->get_id()); @@ -293,16 +293,17 @@ bool CTelegramProto::GetMessageFile( } PROTORECVFILE pre = {}; - pre.dwFlags = PRFF_UTF | PRFF_SILENT; + pre.dwFlags = PRFF_UTF | PRFF_SILENT | PRFF_READ; pre.fileCount = 1; - pre.timestamp = timestamp; + pre.timestamp = pMsg->date_; pre.files.a = &pszFileName; pre.lParam = (LPARAM)pRequest; pre.szId = pszId; pre.szUserId = pszUserId; - if (!caption.empty()) pre.descr.a = caption.c_str(); + if (pMsg->is_outgoing_) + pre.dwFlags = PRFF_SENT; ProtoChainRecvFile(pUser->hContact, &pre); return true; } @@ -358,7 +359,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_, szId, pszUserId, pMsg->date_); + GetMessageFile(TG_FILE_REQUEST::PICTURE, pUser, pPhoto->photo_.get(), fileName, pDoc->caption_->text_, szId, pszUserId, pMsg); } break; @@ -372,7 +373,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, szId, pszUserId, pMsg->date_); + GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pVideo->video_.get(), pVideo->file_name_.c_str(), caption, szId, pszUserId, pMsg); } break; @@ -386,7 +387,7 @@ 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, szId, pszUserId, pMsg->date_); + GetMessageFile(TG_FILE_REQUEST::VIDEO, pUser, pVideo->animation_.get(), pVideo->file_name_.c_str(), caption, szId, pszUserId, pMsg); } break; @@ -394,14 +395,14 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg { 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_, szId, pszUserId, pMsg->date_); + GetMessageFile(TG_FILE_REQUEST::VOICE, pUser, pDoc->voice_note_->voice_.get(), fileName, pDoc->caption_->text_, szId, pszUserId, pMsg); } break; case TD::messageDocument::ID: { auto *pDoc = (TD::messageDocument *)pBody; - GetMessageFile(TG_FILE_REQUEST::FILE, pUser, pDoc->document_->document_.get(), pDoc->document_->file_name_.c_str(), pDoc->caption_->text_, szId, pszUserId, pMsg->date_); + GetMessageFile(TG_FILE_REQUEST::FILE, pUser, pDoc->document_->document_.get(), pDoc->document_->file_name_.c_str(), pDoc->caption_->text_, szId, pszUserId, pMsg); } break; diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index c25d04eed1..68004435b2 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -325,7 +325,9 @@ static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam) dbei.szUserId = pre->szUserId; dbei.eventType = EVENTTYPE_FILE; dbei.flags = DBEF_UTF; - if (pre->dwFlags & PREF_CREATEREAD) + if (pre->dwFlags & PRFF_SENT) + dbei.flags |= DBEF_SENT; + if (pre->dwFlags & PRFF_READ) dbei.flags |= DBEF_READ; if ((pre->dwFlags & PRFF_UNICODE) == PRFF_UNICODE) { -- cgit v1.2.3