diff options
author | George Hazan <ghazan@miranda.im> | 2018-11-27 20:43:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-11-27 20:43:55 +0300 |
commit | 40c4c15d469744813f75e73ae9edf82485c1862f (patch) | |
tree | e5c0e71b2b8fc3c670a28a8c8d0d4aaa4e86d298 /protocols | |
parent | 8a57ca7afd4cce23a6a9112a64e3a2aeee7d96be (diff) |
fixes #1638 ([Discord] Direct messages from temporary contacts cause the contact to be shown as if it were a regular friend)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 4 | ||||
-rw-r--r-- | protocols/Discord/src/menus.cpp | 3 | ||||
-rw-r--r-- | protocols/Discord/src/proto.cpp | 10 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/Discord/src/utils.cpp | 1 |
5 files changed, 19 insertions, 0 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 01eb1868a1..a4ef8a175d 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -81,10 +81,14 @@ void CDiscordProto::OnCommandChannelCreated(const JSONNode &pRoot) // private channel, created for a contact const JSONNode &members = pRoot["recipients"]; for (auto it = members.begin(); it != members.end(); ++it) { + bool bNewUser = FindUser(::getId((*it)["id"])) == nullptr; CDiscordUser *pUser = PrepareUser(*it); + pUser->bIsPrivate = true; pUser->lastMsgId = ::getId(pRoot["last_message_id"]); pUser->channelId = ::getId(pRoot["id"]); setId(pUser->hContact, DB_KEY_CHANNELID, pUser->channelId); + if (bNewUser) + setWord(pUser->hContact, "ApparentMode", ID_STATUS_OFFLINE); } } else { diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp index 2cd87eef15..2852a84c83 100644 --- a/protocols/Discord/src/menus.cpp +++ b/protocols/Discord/src/menus.cpp @@ -82,6 +82,9 @@ int CDiscordProto::OnMenuPrebuild(WPARAM hContact, LPARAM) bool bIsGuild = getByte(hContact, "ChatRoom") == 2; Menu_ShowItem(m_hMenuLeaveGuild, bIsGuild); Menu_ShowItem(m_hMenuCreateChannel, bIsGuild); + + if (getWord(hContact, "ApparentMode") != 0) + Menu_ShowItem(m_hmiReqAuth, true); return 0; } diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 50e9481b12..b95b393c62 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -59,6 +59,8 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) : CreateProtoService(PS_GETMYAVATAR, &CDiscordProto::GetMyAvatar); CreateProtoService(PS_SETMYAVATAR, &CDiscordProto::SetMyAvatar); + CreateProtoService(PS_MENU_REQAUTH, &CDiscordProto::RequestFriendship); + // Events HookProtoEvent(ME_OPT_INITIALISE, &CDiscordProto::OnOptionsInit); HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CDiscordProto::OnDbEventRead); @@ -486,6 +488,14 @@ void CDiscordProto::OnContactDeleted(MCONTACT hContact) ///////////////////////////////////////////////////////////////////////////////////////// +INT_PTR CDiscordProto::RequestFriendship(WPARAM hContact, LPARAM) +{ + AuthRequest(hContact, 0); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + struct SendFileThreadParam { MCONTACT hContact; diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index b092abaa04..fd9bc8d632 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -299,6 +299,7 @@ public: ////////////////////////////////////////////////////////////////////////////////////// // Services + INT_PTR __cdecl RequestFriendship(WPARAM, LPARAM); INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM); diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index d4e35b4090..6c076e58be 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -230,6 +230,7 @@ void CDiscordProto::ProcessType(CDiscordUser *pUser, const JSONNode &pRoot) case 1: // confirmed db_unset(pUser->hContact, "CList", "NotOnList"); delSetting(pUser->hContact, DB_KEY_REQAUTH); + delSetting(pUser->hContact, "ApparentMode"); break; case 3: // expecting authorization |