diff options
-rw-r--r-- | include/m_chat_int.h | 2 | ||||
-rw-r--r-- | protocols/Discord/src/guilds.cpp | 22 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 2 |
5 files changed, 12 insertions, 24 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 8a4f054b0c..0eb552f93a 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -298,7 +298,7 @@ struct CHAT_MANAGER BOOL (*TM_RemoveAll)(STATUSINFO** pStatusList);
int (*UM_CompareItem)(const USERINFO *u1, const USERINFO *u2);
- USERINFO* (*UM_AddUser)(STATUSINFO *pStatusList, SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus);
+ USERINFO* (*UM_AddUser)(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus);
USERINFO* (*UM_FindUser)(SESSION_INFO *si, const wchar_t *pszUID);
USERINFO* (*UM_FindUserFromIndex)(SESSION_INFO *si, int index);
USERINFO* (*UM_GiveStatus)(SESSION_INFO *si, const wchar_t *pszUID, WORD status);
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index 402d82545e..0ed0b6c801 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -137,7 +137,7 @@ void CDiscordProto::ProcessGuild(const JSONNode &p) for (auto &it : pGuild->arChatUsers) AddGuildUser(pGuild, *it); - pGuild->pParentSi = si; + pGuild->pParentSi = (SESSION_INFO*)si; pGuild->hContact = si->hContact; setId(si->hContact, DB_KEY_CHANNELID, guildId); @@ -218,30 +218,18 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS void CDiscordProto::AddGuildUser(CDiscordGuild *pGuild, const CDiscordGuildMember &pUser) { - int flags = GC_SSE_ONLYLISTED; + int flags = 0; switch (pUser.iStatus) { case ID_STATUS_ONLINE: case ID_STATUS_NA: case ID_STATUS_DND: - flags += GC_SSE_ONLINE; + flags = 1; break; - - default: - flags += GC_SSE_OFFLINE; } - GCEVENT gce = { m_szModuleName, pGuild->pParentSi->ptszID, GC_EVENT_JOIN }; - gce.time = time(0); - gce.dwFlags = GCEF_SILENT; + auto *pStatus = g_chatApi.TM_FindStatus(pGuild->pParentSi->pStatuses, pUser.wszRole); wchar_t wszUserId[100]; _i64tow_s(pUser.userId, wszUserId, _countof(wszUserId), 10); - - gce.ptszStatus = pUser.wszRole; - gce.bIsMe = (pUser.userId == m_ownId); - gce.ptszUID = wszUserId; - gce.ptszNick = pUser.wszNick; - Chat_Event(&gce); - - Chat_SetStatusEx(m_szModuleName, pGuild->pParentSi->ptszID, flags, wszUserId); + g_chatApi.UM_AddUser(pGuild->pParentSi, wszUserId, pUser.wszNick, (pStatus) ? pStatus->iStatus : 0)->iStatusEx = flags; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 6800fb52d6..b750b67b2d 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -129,7 +129,7 @@ struct CDiscordGuild : public MZeroedObject MGROUP groupId; LIST<CDiscordUser> arChannels; - GCSessionInfoBase *pParentSi; + SESSION_INFO *pParentSi; OBJLIST<CDiscordGuildMember> arChatUsers; OBJLIST<CDiscordRole> arRoles; // guild roles }; diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 3552cf8e7d..f51d1f2811 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -689,14 +689,14 @@ bool UM_SortUser(SESSION_INFO *si, const wchar_t *pszUID) return true;
}
-USERINFO* UM_AddUser(STATUSINFO *pStatusList, SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus)
+USERINFO* UM_AddUser(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus)
{
- if (pStatusList == nullptr || si == nullptr || pszNick == nullptr)
+ if (si == nullptr || pszNick == nullptr)
return nullptr;
USERINFO *node = new USERINFO();
- replaceStrW(node->pszUID, pszUID);
- replaceStrW(node->pszNick, pszNick);
+ node->pszUID = mir_wstrdup(pszUID);
+ node->pszNick = mir_wstrdup(pszNick);
node->Status = wStatus;
si->getUserList().insert(node);
return node;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 2eeb134218..daaab3b654 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -369,7 +369,7 @@ static void AddUser(GCEVENT *gce) WORD status = TM_StringToWord(si->pStatuses, gce->ptszStatus);
- USERINFO *ui = g_chatApi.UM_AddUser(si->pStatuses, si, gce->ptszUID, gce->ptszNick, status);
+ USERINFO *ui = g_chatApi.UM_AddUser(si, gce->ptszUID, gce->ptszNick, status);
if (ui == nullptr)
return;
|