diff options
-rw-r--r-- | protocols/Telegram/src/groupchat.cpp | 10 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/chat_log.cpp | 1 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 13 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 4 |
6 files changed, 21 insertions, 13 deletions
diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp index 69a4ca7649..3df631aa1b 100644 --- a/protocols/Telegram/src/groupchat.cpp +++ b/protocols/Telegram/src/groupchat.cpp @@ -282,20 +282,22 @@ void CTelegramProto::Chat_SendPrivateMessage(GCHOOK *gch) ///////////////////////////////////////////////////////////////////////////////////////// -void CTelegramProto::GcChangeMember(TG_USER *pChat, TD::int53 userId, bool bJoined) +void CTelegramProto::GcChangeMember(TG_USER *pChat, const char *adminId, TD::int53 userId, bool bJoined) { if (pChat->m_si == nullptr) return; if (auto *pMember = FindUser(userId)) { CMStringW wszId(FORMAT, L"%lld", pMember->id), wszNick(pMember->getDisplayName()); + Utf2T wszAdminId(adminId); GCEVENT gce = { pChat->m_si, (bJoined) ? GC_EVENT_JOIN : GC_EVENT_PART }; gce.pszUID.w = wszId; gce.pszNick.w = wszNick; gce.bIsMe = false; gce.time = time(0); - gce.pszStatus.w = TranslateT("Visitor"); + gce.pszStatus.w = TranslateT("Participant"); + gce.pszText.w = wszAdminId; Chat_Event(&gce); } } @@ -428,12 +430,14 @@ void CTelegramProto::ProcessSuperGroup(TD::updateSupergroup *pObj) else { auto *pChat = AddUser(tmp.id, true); if (auto *si = pChat->m_si) { - CMStringW wszUserId(FORMAT, L"%lld", m_iOwnId); + CMStringW wszUserId(FORMAT, L"%lld", m_iOwnId); GCEVENT gce = { si, GC_EVENT_SETSTATUS }; gce.pszUID.w = wszUserId; gce.time = time(0); + gce.bIsMe = true; gce.pszStatus.w = getRoleById(iStatusId); + gce.pszText.w = TranslateT("Admin"); Chat_Event(&gce); } } diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index dcb85fbfe7..1ab2b23d08 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -294,7 +294,7 @@ class CTelegramProto : public PROTO<CTelegramProto> bool GetGcUserId(TG_USER *pUser, const TD::message *pMsg, char *dest); void GcAddMembers(TG_USER *pChat, const TD::array<TD::object_ptr<TD::chatMember>> &pMembers, bool bSilent); - void GcChangeMember(TG_USER *pChat, TD::int53 userId, bool bJoined); + void GcChangeMember(TG_USER *pChat, const char *adminId, TD::int53 userId, bool bJoined); void GcChangeTopic(TG_USER *pChat, const wchar_t *pwszNewTopic); // Search diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index e110d1c5a0..2db0a384f7 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -491,12 +491,12 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg case TD::messageChatAddMembers::ID:
if (auto *pDoc = (TD::messageChatAddMembers *)pBody)
for (auto &it : pDoc->member_user_ids_)
- GcChangeMember(pUser, it, true);
+ GcChangeMember(pUser, pszUserId, it, true);
break;
case TD::messageChatDeleteMember::ID:
if (auto *pDoc = (TD::messageChatDeleteMember *)pBody)
- GcChangeMember(pUser, pDoc->user_id_, false);
+ GcChangeMember(pUser, pszUserId, pDoc->user_id_, false);
break;
case TD::messageChatChangeTitle::ID:
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index a209e6f434..8ef8ffca1e 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -98,6 +98,7 @@ MIR_APP_DLL(bool) Chat_GetDefaultEventDescr(const SESSION_INFO *si, const LOGINF return true;
case GC_EVENT_ADDSTATUS:
+ case GC_EVENT_SETSTATUS:
if (lin->ptszNick && lin->ptszText && lin->ptszStatus)
res.AppendFormat(TranslateT("%s enables '%s' status for %s"), lin->ptszText, lin->ptszStatus, lin->ptszNick);
return true;
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 613bbd3f48..f849da254b 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -409,13 +409,14 @@ BOOL SM_GiveStatus(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszSt BOOL SM_AssignStatus(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszStatus)
{
- if (si == nullptr)
- return FALSE;
+ if (si != nullptr)
+ if (USERINFO *ui = UM_SetStatus(si, pszUID, TM_StringToWord(si->pStatuses, pszStatus))) {
+ if (si->pDlg)
+ si->pDlg->UpdateNickList();
+ return TRUE;
+ }
- USERINFO *ui = UM_SetStatus(si, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
- if (ui && si->pDlg)
- si->pDlg->UpdateNickList();
- return TRUE;
+ return FALSE;
}
BOOL SM_SetContactStatus(SESSION_INFO *si, const wchar_t *pszUID, uint16_t wStatus)
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 28bfcba762..b7a759e3f0 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -495,7 +495,9 @@ static BOOL HandleChatEvent(GCEVENT &gce, int bManyFix) break;
case GC_EVENT_SETSTATUS:
- SM_AssignStatus(si, gce.pszUID.w, gce.pszStatus.w);
+ if (!SM_AssignStatus(si, gce.pszUID.w, gce.pszStatus.w))
+ return 0;
+
bIsHighlighted = g_chatApi.IsHighlighted(si, &gce);
break;
|