summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-16 15:17:47 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-16 15:17:47 +0300
commitc00f494c8165b9f2d9facc6488173502b19ca696 (patch)
treec9b16d5341ed4336f7797333e12c926fe5e73211 /protocols/Discord/src/proto.cpp
parentd50c14d30197fcf8d31e875d5c936a0890200be4 (diff)
- added reaction to remote contact removal;
- now we remove a channel & friendship on local contact removal
Diffstat (limited to 'protocols/Discord/src/proto.cpp')
-rw-r--r--protocols/Discord/src/proto.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 427fba67d2..31a12fbdac 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -357,6 +357,24 @@ int CDiscordProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
/////////////////////////////////////////////////////////////////////////////////////////
+int CDiscordProto::OnDeleteContact(MCONTACT hContact)
+{
+ CDiscordUser *pUser = FindUser(getId(hContact, DB_KEY_ID));
+ if (pUser == NULL || !m_bOnline)
+ return 0;
+
+ if (pUser->channelId)
+ Push(new AsyncHttpRequest(this, REQUEST_DELETE, CMStringA(FORMAT, "/channels/%lld", pUser->channelId), NULL));
+
+ if (pUser->id)
+ Push(new AsyncHttpRequest(this, REQUEST_DELETE, CMStringA(FORMAT, "/users/@me/relationships/%lld", pUser->id), NULL));
+
+ return 0;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int CDiscordProto::OnModulesLoaded(WPARAM, LPARAM)
{
return 0;
@@ -379,9 +397,17 @@ int CDiscordProto::OnPreShutdown(WPARAM, LPARAM)
int CDiscordProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
{
switch (event) {
- case EV_PROTO_ONLOAD: return OnModulesLoaded(wParam, lParam);
- case EV_PROTO_ONEXIT: return OnPreShutdown(wParam, lParam);
- case EV_PROTO_ONOPTIONS: return OnOptionsInit(wParam, lParam);
+ case EV_PROTO_ONLOAD:
+ return OnModulesLoaded(wParam, lParam);
+
+ case EV_PROTO_ONEXIT:
+ return OnPreShutdown(wParam, lParam);
+
+ case EV_PROTO_ONOPTIONS:
+ return OnOptionsInit(wParam, lParam);
+
+ case EV_PROTO_ONCONTACTDELETED:
+ return OnDeleteContact((MCONTACT)wParam);
}
return 1;