summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/groupchat.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-05-11 16:50:58 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-05-11 16:50:58 +0300
commitadc82c1bfa455a4f5482a7937e5bb6e4cf2a7ff2 (patch)
treeb286bcfd101f448a7d3372de522afec2d295c2ba /protocols/Discord/src/groupchat.cpp
parent0bfc7cda142437e55909073f0654de060e3e1614 (diff)
fixes #724 ([Discord] Trying to add a new contact from group chat doesn't work)
Diffstat (limited to 'protocols/Discord/src/groupchat.cpp')
-rw-r--r--protocols/Discord/src/groupchat.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp
index 4a9d5bb457..60d9a52329 100644
--- a/protocols/Discord/src/groupchat.cpp
+++ b/protocols/Discord/src/groupchat.cpp
@@ -24,7 +24,7 @@ enum {
IDM_CHANGENICK, IDM_CHANGETOPIC, IDM_RENAME, IDM_PASSOWNER,
IDM_DESTROY, IDM_LEAVE,
- IDM_KICK, IDM_INVITE
+ IDM_KICK, IDM_INVITE, IDM_ADD
};
static void sttDisableMenuItem(int nItems, gc_item *items, uint32_t id, bool disabled)
@@ -77,6 +77,7 @@ static gc_item sttLogListItems[] =
static gc_item sttNicklistItems[] =
{
{ LPGENW("Copy ID"), IDM_COPY_ID, MENU_ITEM },
+ { LPGENW("Add friend"), IDM_ADD, MENU_ITEM },
{ nullptr, 0, MENU_SEPARATOR },
{ LPGENW("Kick user"), IDM_KICK, MENU_ITEM },
{ LPGENW("Make group owner"), IDM_PASSOWNER, MENU_ITEM },
@@ -107,6 +108,10 @@ int CDiscordProto::GroupchatMenuHook(WPARAM, LPARAM lParam)
Chat_AddMenuItems(gcmi->hMenu, _countof(sttLogListItems), sttLogListItems, &g_plugin);
}
else if (gcmi->Type == MENU_ON_NICKLIST) {
+ SnowFlake userId = (gcmi->pszUID) ? _wtoi64(gcmi->pszUID) : 0;
+ bool isFriend = (userId == m_ownId) ? true : FindUser(userId) != 0;
+
+ sttDisableMenuItem(_countof(sttNicklistItems), sttNicklistItems, IDM_ADD, isFriend);
sttDisableMenuItem(_countof(sttNicklistItems), sttNicklistItems, IDM_KICK, !isOwner);
sttDisableMenuItem(_countof(sttNicklistItems), sttNicklistItems, IDM_PASSOWNER, !isOwner);
@@ -315,6 +320,10 @@ void CDiscordProto::Chat_ProcessNickMenu(GCHOOK* gch)
CopyId(gch->ptszUID);
break;
+ case IDM_ADD:
+ AddFriend(_wtoi64(gch->ptszUID));
+ break;
+
case IDM_KICK:
KickChatUser(pChannel, gch->ptszUID);
break;