summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-17 16:58:49 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-17 16:58:49 +0300
commit10e4d233d850c9fa7237174490e4e6d9bfd8e764 (patch)
treeffc6c59a7ea8eb16ca1d103e43ec3f913b35697b
parent179f341b7b5be2b48e690c7f7289bd1ce3dc1739 (diff)
duplicate request eliminated
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h9
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp7
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp20
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h2
4 files changed, 11 insertions, 27 deletions
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index 0eb5571be7..81151fd97a 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -105,15 +105,6 @@ struct InviteUserToChatRequest : public AsyncHttpRequest
}
};
-struct KickUserRequest : public AsyncHttpRequest
-{
- KickUserRequest(const char *chatId, const char *skypename) :
- AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT)
- {
- m_szUrl.AppendFormat("/threads/%s/members/%s", chatId, skypename);
- }
-};
-
struct SetChatPropertiesRequest : public AsyncHttpRequest
{
SetChatPropertiesRequest(const char *chatId, const char *propname, const char *value) :
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index d88bdc68bf..e5b75a7131 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -146,7 +146,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case GC_USER_NICKLISTMENU:
switch (gch->dwData) {
case 10:
- PushRequest(new KickUserRequest(chat_id, user_id));
+ KickChatUser(chat_id, user_id);
break;
case 30:
PushRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin"));
@@ -470,6 +470,11 @@ void CSkypeProto::RemoveChatContact(SESSION_INFO *si, const wchar_t *id, bool is
Chat_Event(&gce);
}
+void CSkypeProto::KickChatUser(const char *chatId, const char *userId)
+{
+ PushRequest(new AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT, "/threads/" + mir_urlEncode(chatId) + "/members/" + mir_urlEncode(userId)));
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// Group chat creation dialog
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index fec21784af..e5e6038ba5 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -236,28 +236,14 @@ INT_PTR CSkypeProto::OnGrantAuth(WPARAM hContact, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
-struct DestroyChatroomRequest : public AsyncHttpRequest
-{
- DestroyChatroomRequest(const char *room_id, const char *user_id) :
- AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT, "/threads/" + mir_urlEncode(room_id) + "/members/" + mir_urlEncode(user_id))
- {}
-};
-
-struct DeleteContactRequest : public AsyncHttpRequest
-{
- DeleteContactRequest(const char *who) :
- AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, "/users/SELF/contacts/" + mir_urlEncode(who))
- {
- }
-};
-
bool CSkypeProto::OnContactDeleted(MCONTACT hContact, uint32_t flags)
{
if (IsOnline() && hContact && (flags & CDF_DEL_CONTACT)) {
+ CMStringA szId(getId(hContact));
if (isChatRoom(hContact))
- PushRequest(new DestroyChatroomRequest(getId(hContact), m_szOwnSkypeId));
+ KickChatUser(szId, m_szOwnSkypeId);
else
- PushRequest(new DeleteContactRequest(getId(hContact)));
+ PushRequest(new AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, "/users/SELF/contacts/" + mir_urlEncode(szId)));
}
return true;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index af1915eb6f..ced2d6771b 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -280,6 +280,8 @@ private:
void RemoveChatContact(SESSION_INFO *si, const wchar_t *id, bool isKick = false, const wchar_t *initiator = L"");
void SendChatMessage(SESSION_INFO *si, const wchar_t *tszMessage);
+ void KickChatUser(const char *chatId, const char *userId);
+
void SetChatStatus(MCONTACT hContact, int iStatus);
// polling