summaryrefslogtreecommitdiff
path: root/protocols/Telegram
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-03-14 19:33:36 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-03-14 19:33:36 +0300
commit013b228f4d3d992a0ac95acf08c52353d491c874 (patch)
tree29dfcdff51d85506f79b9ad6c5e455b9367fb24f /protocols/Telegram
parent012971bfceb38022ac90c47ce9dd8925094580e4 (diff)
fixes #3354 (Telegram: невозможно открыть приватные групповые чаты)
Diffstat (limited to 'protocols/Telegram')
-rw-r--r--protocols/Telegram/src/proto.h3
-rw-r--r--protocols/Telegram/src/server.cpp17
-rw-r--r--protocols/Telegram/src/utils.cpp22
-rw-r--r--protocols/Telegram/src/utils.h1
4 files changed, 27 insertions, 16 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 6295784b9c..4431ebe232 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -91,6 +91,8 @@ struct TG_USER
CMStringW wszNick, wszFirstName, wszLastName;
time_t m_timer1 = 0, m_timer2 = 0;
SESSION_INFO *m_si = nullptr;
+
+ CMStringW getDisplayName() const;
};
struct TG_SUPER_GROUP
@@ -249,6 +251,7 @@ class CTelegramProto : public PROTO<CTelegramProto>
TG_USER* FindUser(int64_t id);
TG_USER* AddUser(int64_t id, bool bIsChat);
TG_USER* AddFakeUser(int64_t id, bool bIsChat);
+ TG_USER* GetSender(const TD::MessageSender *pSender);
void SetId(MCONTACT, int64_t id);
// Popups
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 483fe73d82..8641e202e9 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -308,12 +308,9 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj)
break;
case TD::chatTypeSupergroup::ID:
+ bIsBasicGroup = false;
+ chatId = ((TD::chatTypeSupergroup *)pChat->type_.get())->supergroup_id_;
szTitle = pChat->title_;
- {
- auto *pSuperGroup = (TD::chatTypeSupergroup *)pChat->type_.get();
- chatId = pSuperGroup->supergroup_id_;
- bIsBasicGroup = !pSuperGroup->is_channel_;
- }
break;
default:
@@ -526,8 +523,14 @@ void CTelegramProto::ProcessMessage(TD::updateNewMessage *pObj)
pre.timestamp = pMessage->date_;
if (pMessage->is_outgoing_)
pre.flags |= PREF_SENT;
- if (pUser->isGroupChat)
- pre.szUserId = getSender(pMessage->sender_id_.get(), szUserId, sizeof(szUserId));
+ if (pUser->isGroupChat) {
+ if (auto *pSender = GetSender(pMessage->sender_id_.get())) {
+ _i64toa(pSender->id, szUserId, 10);
+ pre.szUserId = szUserId;
+ if (pUser->m_si)
+ g_chatApi.UM_AddUser(pUser->m_si, Utf2T(szUserId), pSender->getDisplayName(), ID_STATUS_ONLINE);
+ }
+ }
ProtoChainRecvMsg(pUser->hContact, &pre);
}
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index e93b40852f..1c8e31d0f3 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -22,19 +22,25 @@ const char *getName(const TD::usernames *pName)
return (pName == nullptr) ? TranslateU("none") : pName->editable_username_.c_str();
}
-const char* getSender(const TD::MessageSender *pSender, char *pDest, size_t cbSize)
+CMStringW TG_USER::getDisplayName() const
+{
+ if (!wszFirstName.IsEmpty())
+ return (wszLastName.IsEmpty()) ? wszFirstName : wszFirstName + L" " + wszLastName;
+
+ return wszNick;
+}
+
+TG_USER* CTelegramProto::GetSender(const TD::MessageSender *pSender)
{
switch (pSender->get_id()) {
case TD::messageSenderChat::ID:
- _i64toa_s(((TD::messageSenderChat *)pSender)->chat_id_, pDest, cbSize, 10);
- break;
+ return FindChat(((TD::messageSenderChat *)pSender)->chat_id_);
+
case TD::messageSenderUser::ID:
- _i64toa_s(((TD::messageSenderUser *)pSender)->user_id_, pDest, cbSize, 10);
- break;
- default:
- *pDest = 0;
+ return FindUser(((TD::messageSenderUser *)pSender)->user_id_);
}
- return pDest;
+
+ return nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Telegram/src/utils.h b/protocols/Telegram/src/utils.h
index d563350585..7f98ecbcf6 100644
--- a/protocols/Telegram/src/utils.h
+++ b/protocols/Telegram/src/utils.h
@@ -1,4 +1,3 @@
#pragma once
const char *getName(const TD::usernames *pName);
-const char *getSender(const TD::MessageSender *pSender, char *pDest, size_t cbSize);