From 9f486b57c18ef0ab58f80c088c2156eeaea1189c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 2 Mar 2023 15:34:40 +0300 Subject: =?UTF-8?q?fixes=20#3358=20(Telegram:=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B8=D0=B4=D0=B5=D0=BD=D1=82=D0=B8?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D1=80=D1=8B=20=D0=B2=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D1=8B=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/server.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'protocols') diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 8b708a1e81..167b2badae 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -253,14 +253,15 @@ void CTelegramProto::ProcessBasicGroup(TD::updateBasicGroup *pObj) TG_BASIC_GROUP tmp(pObj->basic_group_->id_, 0); auto *pGroup = m_arBasicGroups.find(&tmp); - if (pGroup == nullptr) - m_arBasicGroups.insert(new TG_BASIC_GROUP(tmp.id, std::move(pObj->basic_group_))); - else - pGroup->group = std::move(pObj->basic_group_); + if (pGroup == nullptr) { + pGroup = new TG_BASIC_GROUP(tmp.id, std::move(pObj->basic_group_)); + m_arBasicGroups.insert(pGroup); + } + else pGroup->group = std::move(pObj->basic_group_); if (iStatusId == TD::chatMemberStatusLeft::ID) { auto *pUser = AddFakeUser(tmp.id, true); - pUser->wszFirstName.Format(TranslateT("%d member(s)"), pGroup->group->member_count_); + pUser->wszLastName.Format(TranslateT("%d member(s)"), pGroup->group->member_count_); } else AddUser(tmp.id, true); } @@ -270,6 +271,7 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj) bool bIsBasicGroup = false; int64_t chatId; auto *pChat = pObj->chat_.get(); + std::string szTitle; switch(pChat->type_->get_id()) { case TD::chatTypePrivate::ID: @@ -280,9 +282,11 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj) case TD::chatTypeBasicGroup::ID: bIsBasicGroup = true; chatId = ((TD::chatTypeBasicGroup*)pChat->type_.get())->basic_group_id_; + szTitle = pChat->title_; break; case TD::chatTypeSupergroup::ID: + szTitle = pChat->title_; { auto *pSuperGroup = (TD::chatTypeSupergroup *)pChat->type_.get(); chatId = pSuperGroup->supergroup_id_; @@ -301,11 +305,11 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj) if (!m_arChats.find(pUser)) m_arChats.insert(pUser); - if (!pChat->title_.empty()) { + if (!szTitle.empty()) { if (pUser->hContact != INVALID_CONTACT_ID) - setUString(pUser->hContact, "Nick", pChat->title_.c_str()); - else - pUser->wszNick = Utf2T(pChat->title_.c_str()); + setUString(pUser->hContact, "Nick", szTitle.c_str()); + else if (pUser->wszNick.IsEmpty()) + pUser->wszFirstName = Utf2T(szTitle.c_str()); } if (CheckSearchUser(pUser)) @@ -475,7 +479,7 @@ void CTelegramProto::ProcessSuperGroup(TD::updateSupergroup *pObj) if (iStatusId == TD::chatMemberStatusLeft::ID) { auto *pUser = AddFakeUser(tmp.id, true); pUser->wszNick = getName(pGroup->group->usernames_.get()); - pUser->wszFirstName.Format(TranslateT("%d member(s)"), pGroup->group->member_count_); + pUser->wszLastName.Format(TranslateT("%d member(s)"), pGroup->group->member_count_); } else AddUser(tmp.id, true); } @@ -499,8 +503,10 @@ void CTelegramProto::ProcessUser(TD::updateUser *pObj) auto *pu = AddFakeUser(pUser->id_, false); pu->wszFirstName = Utf2T(pUser->first_name_.c_str()); pu->wszLastName = Utf2T(pUser->last_name_.c_str()); - if (pUser->usernames_) - pu->wszNick = Utf2T(pUser->usernames_->editable_username_.c_str()); + if (pUser->usernames_) { + pu->wszNick = L"@"; + pu->wszNick.Append(Utf2T(pUser->usernames_->editable_username_.c_str())); + } else { pu->wszNick = Utf2T(pUser->first_name_.c_str()); if (!pUser->last_name_.empty()) -- cgit v1.2.3