diff options
author | ElzorFox <elzorfox@ya.ru> | 2024-06-04 08:58:18 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2024-06-04 08:58:18 +0500 |
commit | 8d1cd864c3311e6ec8145388c2ab1ad6588eaa79 (patch) | |
tree | 6d8e851f38e678215963639f7095c896519948af /protocols/VKontakte/src | |
parent | 4e8370452526b6d3e5fb6a95ec1bfe39e2b61034 (diff) |
VKontakte: fix owner groupchat status
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 33 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 2 |
2 files changed, 21 insertions, 14 deletions
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 90c38fb366..709465dda5 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -231,14 +231,21 @@ void CVkProto::OnReceiveChatInfo(MHttpResponse *reply, AsyncHttpRequest *pReq) LeaveChat(cc->m_iChatId);
return;
}
- cc->m_iAdminId = jnInfo["admin_id"].as_int();
}
-
if (!jnResponse["users"])
return;
- const JSONNode &jnUsers = jnResponse["users"]["profiles"];
+ const JSONNode &jnUsersItems = jnResponse["users"]["items"];
+
+ if (jnUsersItems)
+ for (auto& jnUser : jnUsersItems)
+ if (jnUser["is_owner"].as_bool()) {
+ cc->m_iOwner = jnUser["member_id"].as_int();
+ break;
+ }
+
+ const JSONNode& jnUsers = jnResponse["users"]["profiles"];
if (jnUsers) {
for (auto &it : cc->m_users)
@@ -257,32 +264,32 @@ void CVkProto::OnReceiveChatInfo(MHttpResponse *reply, AsyncHttpRequest *pReq) _ltow(iUserId, wszId, 10);
bool bNew;
- CVkChatUser *iChatUser = cc->m_users.find((CVkChatUser*)&iUserId);
- if (iChatUser == nullptr) {
- cc->m_users.insert(iChatUser = new CVkChatUser(iUserId));
+ CVkChatUser *vkChatUser = cc->m_users.find((CVkChatUser*)&iUserId);
+ if (vkChatUser == nullptr) {
+ cc->m_users.insert(vkChatUser = new CVkChatUser(iUserId));
bNew = true;
}
else
- bNew = iChatUser->m_bUnknown;
- iChatUser->m_bDel = false;
+ bNew = vkChatUser->m_bUnknown;
+ vkChatUser->m_bDel = false;
- CMStringW wszNick(ptrW(db_get_wsa(cc->m_si->hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", iChatUser->m_iUserId))));
+ CMStringW wszNick(ptrW(db_get_wsa(cc->m_si->hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", vkChatUser->m_iUserId))));
if (wszNick.IsEmpty())
wszNick = bIsGroup ?
jnUser["name"].as_mstring() :
jnUser["first_name"].as_mstring().Trim() + L" " + jnUser["last_name"].as_mstring().Trim();
- iChatUser->m_wszNick = mir_wstrdup(wszNick);
- iChatUser->m_bUnknown = false;
+ vkChatUser->m_wszNick = mir_wstrdup(wszNick);
+ vkChatUser->m_bUnknown = false;
if (bNew) {
GCEVENT gce = { cc->m_si, GC_EVENT_JOIN };
gce.bIsMe = iUserId == m_iMyUserId;
gce.pszUID.w = wszId;
gce.pszNick.w = wszNick;
- gce.pszStatus.w = TranslateW(sttStatuses[iUserId == cc->m_iAdminId]);
- gce.dwItemData = (INT_PTR)iChatUser;
+ gce.pszStatus.w = TranslateW(sttStatuses[iUserId == cc->m_iOwner]);
+ gce.dwItemData = (INT_PTR)vkChatUser;
Chat_Event(&gce);
}
}
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 1042a7cee4..7a64e62996 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -143,7 +143,7 @@ struct CVkChatInfo : public MZeroedObject {}
VKUserID_t m_iChatId;
- VKUserID_t m_iAdminId = 0;
+ VKUserID_t m_iOwner = 0;
bool m_bHistoryRead = false;
ptrW m_wszTopic;
SESSION_INFO *m_si = nullptr;
|