summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-06-07 19:24:47 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-06-07 19:24:47 +0300
commit06d7b7d0fd02af55b5c5183cc04a9c2ac04a4163 (patch)
tree67d930f48950572ee31fc441fdde710114163108
parent65082d3cc4f7fe8e2f25b3ef367ab7c6a002b4cb (diff)
#3542 (Telegram: исходящие картинки показываются как входящие)
-rw-r--r--include/m_protosvc.h2
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/utils.cpp19
-rw-r--r--src/core/stdfile/src/file.cpp4
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<CTelegramProto>
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) {