summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-03-06 11:17:29 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-03-06 11:17:29 +0300
commit572e9aa41d6551b8ad3029b224f0c2a3ec07bb63 (patch)
treef1bfc13b54c5636dc16f5c4da33f9ceadd8eb7e7 /protocols
parent7fa3372fc1b0ee5b0f70c2bfb495cb922ca499e3 (diff)
Telegram: my own group chat messages are loaded from server having "Unknown nick" as a sender
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/utils.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index a8817da7c7..ef19a92d3e 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -156,11 +156,13 @@ TG_FILE_REQUEST::Type AutoDetectType(const wchar_t *pwszFilename)
CMStringW TG_USER::getDisplayName() const
{
- if (hContact != INVALID_CONTACT_ID)
- return Clist_GetContactDisplayName(hContact, 0);
+ if (hContact != 0) {
+ if (hContact != INVALID_CONTACT_ID)
+ return Clist_GetContactDisplayName(hContact, 0);
- if (!wszFirstName.IsEmpty())
- return (wszLastName.IsEmpty()) ? wszFirstName : wszFirstName + L" " + wszLastName;
+ if (!wszFirstName.IsEmpty())
+ return (wszLastName.IsEmpty()) ? wszFirstName : wszFirstName + L" " + wszLastName;
+ }
return wszNick;
}
@@ -365,10 +367,12 @@ bool CTelegramProto::GetGcUserId(TG_USER *pUser, const TD::message *pMsg, char *
if (pUser->isGroupChat) {
if (auto *pSender = GetSender(pMsg->sender_id_.get())) {
_i64toa(pSender->id, dest, 10);
+
+ CMStringW wszDisplayName(pSender->getDisplayName());
if (pUser->m_si && !pSender->wszFirstName.IsEmpty())
- g_chatApi.UM_AddUser(pUser->m_si, Utf2T(dest), pSender->getDisplayName(), ID_STATUS_ONLINE);
+ g_chatApi.UM_AddUser(pUser->m_si, Utf2T(dest), wszDisplayName, ID_STATUS_ONLINE);
else
- mir_strncpy(dest, T2Utf(pSender->getDisplayName()), 100);
+ mir_strncpy(dest, T2Utf(wszDisplayName), 100);
return true;
}
}