summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-13 15:25:34 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-13 15:25:34 +0300
commitd3261a063d470c00a3544829ebdac906e3f9b9a9 (patch)
treeba06bedc33d6773878a2cff4b01b46f1f9fa71e0 /protocols
parentab7236480aa71a278e4882eabbfed20f386333d3 (diff)
fixes #3883 (Telegram: если в Saved Messages никогда ничего не сохраняли, то Миранда не может туда ничего записать)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/proto.cpp12
-rw-r--r--protocols/Telegram/src/proto.h4
-rw-r--r--protocols/Telegram/src/server.cpp12
3 files changed, 20 insertions, 8 deletions
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index fff388caa5..cc386b8a11 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -68,6 +68,7 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
HookProtoEvent(ME_HISTORY_EMPTY, &CTelegramProto::OnEmptyHistory);
HookProtoEvent(ME_OPT_INITIALISE, &CTelegramProto::OnOptionsInit);
+ HookProtoEvent(ME_MSG_WINDOWEVENT, &CTelegramProto::OnWindowEvent);
// avatar
CreateDirectoryTreeW(GetAvatarPath());
@@ -160,6 +161,17 @@ void CTelegramProto::OnShutdown()
m_bTerminated = true;
}
+int CTelegramProto::OnWindowEvent(WPARAM wParam, LPARAM lParam)
+{
+ if (wParam == MSG_WINDOW_EVT_OPENING) {
+ auto *pDlg = (CMsgDialog *)lParam;
+ auto *pUser = FindUser(GetId(pDlg->m_hContact));
+ if (pUser->chatId == -1 && !pDlg->isChat())
+ SendQuery(new TD::createPrivateChat(pUser->id, true));
+ }
+ return 0;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
void CTelegramProto::OnBuildProtoMenu()
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index b90f6e9d45..c5566472d8 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -92,7 +92,6 @@ struct TG_USER : public MZeroedObject
hContact(_2),
isGroupChat(_3)
{
- chatId = (isGroupChat) ? -1 : id;
}
~TG_USER()
@@ -100,7 +99,7 @@ struct TG_USER : public MZeroedObject
delete pReactions;
}
- int64_t id, chatId;
+ int64_t id, chatId = -1;
MCONTACT hContact;
bool isGroupChat, bLoadMembers;
CMStringA szAvatarHash;
@@ -363,6 +362,7 @@ public:
int __cdecl OnEmptyHistory(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
+ int __cdecl OnWindowEvent(WPARAM, LPARAM);
int __cdecl GcMenuHook(WPARAM, LPARAM);
int __cdecl GcMuteHook(WPARAM, LPARAM);
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 0bd26786be..e2eb723e68 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -418,23 +418,23 @@ void CTelegramProto::ProcessBasicGroup(TD::updateBasicGroup *pObj)
void CTelegramProto::ProcessChat(TD::updateNewChat *pObj)
{
- int64_t chatId;
+ int64_t userId;
auto *pChat = pObj->chat_.get();
std::string szTitle;
switch(pChat->type_->get_id()) {
case TD::chatTypePrivate::ID:
case TD::chatTypeSecret::ID:
- chatId = pChat->id_;
+ userId = pChat->id_;
break;
case TD::chatTypeBasicGroup::ID:
- chatId = ((TD::chatTypeBasicGroup*)pChat->type_.get())->basic_group_id_;
+ userId = ((TD::chatTypeBasicGroup*)pChat->type_.get())->basic_group_id_;
szTitle = pChat->title_;
break;
case TD::chatTypeSupergroup::ID:
- chatId = ((TD::chatTypeSupergroup *)pChat->type_.get())->supergroup_id_;
+ userId = ((TD::chatTypeSupergroup *)pChat->type_.get())->supergroup_id_;
szTitle = pChat->title_;
break;
@@ -443,7 +443,7 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj)
return;
}
- if (auto *pUser = FindUser(chatId)) {
+ if (auto *pUser = FindUser(userId)) {
pUser->chatId = pChat->id_;
MCONTACT hContact = (pUser->id == m_iOwnId) ? 0 : pUser->hContact;
@@ -463,7 +463,7 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj)
if (pUser->isGroupChat && pUser->hContact != INVALID_CONTACT_ID)
InitGroupChat(pUser, pChat);
}
- else debugLogA("Unknown chat id %lld, ignoring", chatId);
+ else debugLogA("Unknown user id %lld, ignoring", userId);
}
void CTelegramProto::ProcessChatLastMessage(TD::updateChatLastMessage *pObj)