summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_protosvc.h42
-rw-r--r--protocols/Telegram/src/proto.cpp5
-rw-r--r--protocols/Telegram/src/proto.h3
-rw-r--r--protocols/Telegram/src/server.cpp6
-rw-r--r--protocols/Telegram/src/utils.cpp6
-rw-r--r--src/mir_app/src/file.cpp1
-rw-r--r--src/mir_app/src/proto_interface.cpp1
7 files changed, 40 insertions, 24 deletions
diff --git a/include/m_protosvc.h b/include/m_protosvc.h
index dcc7438b0d..67b3952cd3 100644
--- a/include/m_protosvc.h
+++ b/include/m_protosvc.h
@@ -724,21 +724,22 @@ struct PROTOFILERESUME
// DB event: EVENTTYPE_MESSAGE, blob contains szMessage without 0 terminator
// Return 0 - success, other failure
-#define PREF_CREATEREAD 1 // create the database event with the 'read' flag set
-#define PREF_RTL 4 // 0.5+ addition: support for right-to-left messages
-#define PREF_SENT 16 // message will be created with the DBEF_SENT flag
-#define PREF_ENCRYPTED 32 // message is encrypted
-#define PREF_ENCRYPTED_STRONG 64// message is encrypted with verified key
+#define PREF_CREATEREAD 1 // create the database event with the 'read' flag set
+#define PREF_RTL 4 // 0.5+ addition: support for right-to-left messages
+#define PREF_SENT 16 // message will be created with the DBEF_SENT flag
+#define PREF_ENCRYPTED 32 // message is encrypted
+#define PREF_ENCRYPTED_STRONG 64 // message is encrypted with verified key
struct PROTORECVEVENT
{
- uint32_t flags; // combination of PREF_*
- uint32_t timestamp; // unix time
- char* szMessage; // message body in utf8
- LPARAM lParam; // extra space for the network level protocol module
- const char* szMsgId; // server message id, optional, should be NULL otherwise
- // ignored for protocols without PF4_SERVERMSGID in GetCaps()
- const char *szUserId; // user id, for group chats stored in the database
+ uint32_t flags; // combination of PREF_*
+ uint32_t timestamp; // unix time
+ char* szMessage; // message body in utf8
+ LPARAM lParam; // extra space for the network level protocol module
+ const char* szMsgId; // server message id, optional, should be NULL otherwise
+ // ignored for protocols without PF4_SERVERMSGID in GetCaps()
+ const char *szUserId; // user id, for group chats stored in the database
+ const char *szReplyId; // this message is a reply to a message with that server id
};
///////////////////////////////////////////////////////////////////////////////
@@ -781,14 +782,15 @@ EXTERN_C MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, PROTORECVEV
struct PROTORECVFILE
{
- uint32_t dwFlags; // PRFF_*
- uint32_t timestamp; // unix time
- MAllCStrings descr; // file description
- int fileCount; // number of files being transferred
- MAllCStringArray files; // array of file names
- LPARAM lParam; // extra space for the network level protocol module
- const char *szId; // server message id
- const char *szUserId; // groupchat user id
+ uint32_t dwFlags; // PRFF_*
+ uint32_t timestamp; // unix time
+ MAllCStrings descr; // file description
+ int fileCount; // number of files being transferred
+ MAllCStringArray files; // array of file names
+ LPARAM lParam; // extra space for the network level protocol module
+ const char *szId; // server message id
+ const char *szUserId; // groupchat user id
+ const char *szReplyId; // this message is a reply to a message with that server id
};
#define PSR_FILE "/RecvFile"
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 763db665e9..79694ac08c 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -345,9 +345,10 @@ INT_PTR CTelegramProto::GetCaps(int type, MCONTACT)
/////////////////////////////////////////////////////////////////////////////////////////
-MEVENT CTelegramProto::RecvFile(MCONTACT, PROTORECVFILE *)
+MEVENT CTelegramProto::RecvFile(MCONTACT hContact, PROTORECVFILE *pre)
{
- return 0;
+ auto *ft = (TG_FILE_REQUEST *)pre->lParam;
+ return (ft->m_bRecv) ? CSuper::RecvFile(hContact, pre) : 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index f64492c8c2..01cbf1e6f3 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -78,7 +78,8 @@ struct TG_FILE_REQUEST : public MZeroedObject
TD::int53 m_fileId, m_fileSize = 0;
CMStringA m_uniqueId, m_szUserId;
CMStringW m_destPath, m_fileName, m_wszDescr;
- OFDTHREAD *ofd = 0;
+ OFDTHREAD *ofd;
+ bool m_bRecv;
};
struct TG_USER : public MZeroedObject
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index c846d25666..c3c9bd408c 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -730,7 +730,7 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage)
if (pMessage->sending_state_->get_id() == TD::messageSendingStatePending::ID)
return;
- char szId[100], szUserId[100];
+ char szId[100], szUserId[100], szReplyId[100];
_i64toa(pMessage->id_, szId, 10);
if (db_event_getById(m_szModuleName, szId))
return;
@@ -760,6 +760,10 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage)
pre.flags |= PREF_SENT;
if (GetGcUserId(pUser, pMessage, szUserId))
pre.szUserId = szUserId;
+ if (pMessage->reply_to_message_id_) {
+ _i64toa(pMessage->reply_to_message_id_, szReplyId, 10);
+ pre.szReplyId = szReplyId;
+ }
ProtoChainRecvMsg(GetRealContact(pUser), &pre);
}
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index 1ced9f9a6f..15a6484a0c 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -369,11 +369,13 @@ bool CTelegramProto::GetMessageFile(
auto *pRequest = new TG_FILE_REQUEST(fileType, pFile->id_, pFile->remote_->id_.c_str());
pRequest->m_fileName = Utf2T(pszFileName);
pRequest->m_fileSize = pFile->size_;
+ pRequest->m_bRecv = true;
{
mir_cslock lck(m_csFiles);
m_arFiles.insert(pRequest);
}
+ char szReplyId[100];
MCONTACT hContact = GetRealContact(pUser);
PROTORECVFILE pre = {};
pre.dwFlags = PRFF_UTF | PRFF_SILENT;
@@ -389,6 +391,10 @@ bool CTelegramProto::GetMessageFile(
pre.dwFlags |= PRFF_SENT;
if (Contact::IsGroupChat(hContact))
pre.dwFlags |= PRFF_READ;
+ if (pMsg->reply_to_message_id_) {
+ _i64toa(pMsg->reply_to_message_id_, szReplyId, 10);
+ pre.szReplyId = szReplyId;
+ }
ProtoChainRecvFile(hContact, &pre);
return true;
}
diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp
index aaa5477a4b..e26571d4aa 100644
--- a/src/mir_app/src/file.cpp
+++ b/src/mir_app/src/file.cpp
@@ -249,6 +249,7 @@ MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre)
dbei.timestamp = pre->timestamp;
dbei.szId = pre->szId;
dbei.szUserId = pre->szUserId;
+ dbei.szReplyId = pre->szReplyId;
dbei.eventType = EVENTTYPE_FILE;
dbei.flags = DBEF_UTF;
if (bSent)
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp
index 0f3b2e12d5..88488be82c 100644
--- a/src/mir_app/src/proto_interface.cpp
+++ b/src/mir_app/src/proto_interface.cpp
@@ -220,6 +220,7 @@ MEVENT PROTO_INTERFACE::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
dbei.cbBlob = (uint32_t)mir_strlen(pre->szMessage) + 1;
dbei.pBlob = (uint8_t*)pre->szMessage;
dbei.szUserId = pre->szUserId;
+ dbei.szReplyId = pre->szReplyId;
if (pre->flags & PREF_CREATEREAD)
dbei.flags |= DBEF_READ;