diff options
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r-- | protocols/Telegram/src/groupchat.cpp | 5 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 7 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 3 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 8 |
5 files changed, 15 insertions, 10 deletions
diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp index e38a182abb..ead181089d 100644 --- a/protocols/Telegram/src/groupchat.cpp +++ b/protocols/Telegram/src/groupchat.cpp @@ -215,7 +215,7 @@ int CTelegramProto::GcEventHook(WPARAM, LPARAM lParam) if (dbei) replyId = dbei2id(dbei); } - SendTextMessage(pUser->chatId, replyId, T2Utf(gch->ptszText)); + SendTextMessage(pUser->chatId, GetId(gch->si->hContact, DBKEY_THREAD), replyId, T2Utf(gch->ptszText)); } } break; @@ -434,6 +434,9 @@ void CTelegramProto::ProcessForum(TD::updateForumTopicInfo *pForum) auto *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszId, Utf2T(pForum->info_->name_.c_str()), pUser); si->pParent = pUser->m_si; + + SetId(si->hContact, pForum->info_->message_thread_id_, DBKEY_THREAD); + Clist_SetGroup(si->hContact, ptrW(Clist_GetGroup(pUser->hContact))); Chat_Control(si, m_bHideGroupchats ? WINDOW_HIDDEN : SESSION_INITDONE); diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index d62eda948c..7817d7e4ff 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -617,7 +617,7 @@ int CTelegramProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *p iReplyId = dbei2id(dbei); } - int msgid = SendTextMessage(pUser->chatId, iReplyId, pszMessage); + int msgid = SendTextMessage(pUser->chatId, 0, iReplyId, pszMessage); if (msgid != -1) m_arOwnMsg.insert(new TG_OWN_MESSAGE(hContact, (HANDLE)msgid, "")); diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 439a6b9697..6b778deda6 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -2,6 +2,7 @@ #define DBKEY_ID "id" #define DBKEY_COMPAT "Compatibility" +#define DBKEY_THREAD "ThreadId" #define DBKEY_AUTHORIZED "Authorized" #define DBKEY_AVATAR_HASH "AvatarHash" @@ -246,7 +247,7 @@ class CTelegramProto : public PROTO<CTelegramProto> void SendMarkRead(void); int SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler = nullptr); int SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandler, void *pUserInfo); - int SendTextMessage(int64_t chatId, int64_t replyId, const char *pszMessage); + int SendTextMessage(int64_t chatId, int64_t threadId, int64_t replyId, const char *pszMessage); void ProcessAvatar(const TD::file *pFile, TG_USER *pUser); void ProcessAuth(TD::updateAuthorizationState *pObj); @@ -328,8 +329,8 @@ class CTelegramProto : public PROTO<CTelegramProto> TG_USER* AddFakeUser(int64_t id, bool bIsChat); TG_USER* GetSender(const TD::MessageSender *pSender); - int64_t GetId(MCONTACT); - void SetId(MCONTACT, int64_t id); + int64_t GetId(MCONTACT, const char *pszSetting = DBKEY_ID); + void SetId(MCONTACT, int64_t id, const char *pszSetting = DBKEY_ID); MCONTACT GetRealContact(const TG_USER *pUser); diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index b80bef0988..12a2c6defe 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -340,7 +340,7 @@ void CTelegramProto::OnSendMessage(td::ClientManager::Response &response) }
}
-int CTelegramProto::SendTextMessage(int64_t chatId, int64_t replyId, const char *pszMessage)
+int CTelegramProto::SendTextMessage(int64_t chatId, int64_t threadId, int64_t replyId, const char *pszMessage)
{
auto pContent = TD::make_object<TD::inputMessageText>();
pContent->text_ = formatBbcodes(pszMessage);
@@ -348,6 +348,7 @@ int CTelegramProto::SendTextMessage(int64_t chatId, int64_t replyId, const char auto *pMessage = new TD::sendMessage();
pMessage->chat_id_ = chatId;
pMessage->input_message_content_ = std::move(pContent);
+ pMessage->message_thread_id_ = threadId;
pMessage->reply_to_message_id_ = replyId;
return SendQuery(pMessage, &CTelegramProto::OnSendMessage);
}
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index dc0eaac817..0069b77cbb 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -228,16 +228,16 @@ void CTelegramProto::ReportSearchUser(TG_USER *pUser) /////////////////////////////////////////////////////////////////////////////////////////
-int64_t CTelegramProto::GetId(MCONTACT hContact)
+int64_t CTelegramProto::GetId(MCONTACT hContact, const char *pszSetting)
{
- return _atoi64(getMStringA(hContact, DBKEY_ID));
+ return _atoi64(getMStringA(hContact, pszSetting));
}
-void CTelegramProto::SetId(MCONTACT hContact, int64_t id)
+void CTelegramProto::SetId(MCONTACT hContact, int64_t id, const char *pszSetting)
{
char szId[100];
_i64toa(id, szId, 10);
- setString(hContact, DBKEY_ID, szId);
+ setString(hContact, pszSetting, szId);
}
/////////////////////////////////////////////////////////////////////////////////////////
|