diff options
| -rw-r--r-- | protocols/Teams/src/requests/contacts.h | 89 | ||||
| -rw-r--r-- | protocols/Teams/src/stdafx.h | 3 | ||||
| -rw-r--r-- | protocols/Teams/src/teams_contacts.cpp | 47 | ||||
| -rw-r--r-- | protocols/Teams/src/teams_endpoint.cpp | 2 | ||||
| -rw-r--r-- | protocols/Teams/src/teams_http.cpp | 2 | ||||
| -rw-r--r-- | protocols/Teams/src/teams_proto.cpp | 14 |
6 files changed, 42 insertions, 115 deletions
diff --git a/protocols/Teams/src/requests/contacts.h b/protocols/Teams/src/requests/contacts.h deleted file mode 100644 index f0614f10b6..0000000000 --- a/protocols/Teams/src/requests/contacts.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright (c) 2015-25 Miranda NG team (https://miranda-ng.org) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _SKYPE_REQUEST_CONTACTS_H_ -#define _SKYPE_REQUEST_CONTACTS_H_ - -struct GetContactListRequest : public AsyncHttpRequest -{ - GetContactListRequest() : - AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/users/SELF/contacts", &CTeamsProto::LoadContactList) - { - } -}; - -struct GetContactsAuthRequest : public AsyncHttpRequest -{ - GetContactsAuthRequest() : - AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/users/SELF/invites", &CTeamsProto::LoadContactsAuth) - { - } -}; - -struct AddContactRequest : public AsyncHttpRequest -{ - AddContactRequest(const char *who, const char *greeting = "") : - AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, "/users/SELF/contacts") - { - JSONNode node; - node << CHAR_PARAM("mri", who) << CHAR_PARAM("greeting", greeting); - m_szParam = node.write().c_str(); - } -}; - -struct AuthAcceptRequest : public AsyncHttpRequest -{ - AuthAcceptRequest(const char *who) : - AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS) - { - m_szUrl.AppendFormat("/users/SELF/invites/%s/accept", mir_urlEncode(who).c_str()); - } -}; - -struct AuthDeclineRequest : public AsyncHttpRequest -{ - AuthDeclineRequest(const char *who) : - AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS) - { - m_szUrl.AppendFormat("/users/SELF/invites/%s/decline", mir_urlEncode(who).c_str()); - } -}; - -struct BlockContactRequest : public AsyncHttpRequest -{ - BlockContactRequest(CTeamsProto *ppro, MCONTACT hContact) : - AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, "/users/SELF/contacts/blocklist/" + ppro->getId(hContact), &CTeamsProto::OnBlockContact) - { - m_szParam = "{\"report_abuse\":\"false\",\"ui_version\":\"skype.com\"}"; - pUserInfo = (void *)hContact; - } -}; - -struct UnblockContactRequest : public AsyncHttpRequest -{ - UnblockContactRequest(CTeamsProto *ppro, MCONTACT hContact) : - AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, 0, &CTeamsProto::OnUnblockContact) - { - m_szUrl.AppendFormat("/users/SELF/contacts/blocklist/%s", ppro->getId(hContact).c_str()); - pUserInfo = (void *)hContact; - - // TODO: user ip address - this << CHAR_PARAM("reporterIp", "123.123.123.123") << CHAR_PARAM("uiVersion", g_szMirVer); - } -}; - -#endif //_SKYPE_REQUEST_CONTACTS_H_
\ No newline at end of file diff --git a/protocols/Teams/src/stdafx.h b/protocols/Teams/src/stdafx.h index de676dace4..45fbabe8cb 100644 --- a/protocols/Teams/src/stdafx.h +++ b/protocols/Teams/src/stdafx.h @@ -90,7 +90,6 @@ struct AsyncHttpRequest : public MTHttpRequest<CTeamsProto> #include "requests/capabilities.h" #include "requests/chatrooms.h" -#include "requests/contacts.h" #include "requests/history.h" #include "requests/poll.h" #include "requests/profile.h" @@ -98,6 +97,4 @@ struct AsyncHttpRequest : public MTHttpRequest<CTeamsProto> #include "requests/status.h" #include "requests/subscriptions.h" -#define POLLING_ERRORS_LIMIT 3 - #endif //_COMMON_H_
\ No newline at end of file diff --git a/protocols/Teams/src/teams_contacts.cpp b/protocols/Teams/src/teams_contacts.cpp index 90fde17b50..8579aed3c3 100644 --- a/protocols/Teams/src/teams_contacts.cpp +++ b/protocols/Teams/src/teams_contacts.cpp @@ -100,6 +100,8 @@ MCONTACT CTeamsProto::AddContact(const char *skypeId, const char *nick, bool isT return hContact; } +///////////////////////////////////////////////////////////////////////////////////////// + void CTeamsProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*) { TeamsReply reply(response); @@ -220,16 +222,14 @@ void CTeamsProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*) } } - PushRequest(new GetContactsAuthRequest()); + PushRequest(new AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/users/SELF/invites", &CTeamsProto::LoadContactsAuth)); } +///////////////////////////////////////////////////////////////////////////////////////// + INT_PTR CTeamsProto::OnRequestAuth(WPARAM hContact, LPARAM) { - if (hContact == INVALID_CONTACT_ID) - return 1; - - PushRequest(new AddContactRequest(getId(hContact))); - return 0; + return AuthRequest(hContact, 0); } INT_PTR CTeamsProto::OnGrantAuth(WPARAM hContact, LPARAM) @@ -237,7 +237,7 @@ INT_PTR CTeamsProto::OnGrantAuth(WPARAM hContact, LPARAM) if (hContact == INVALID_CONTACT_ID) return 1; - PushRequest(new AuthAcceptRequest(getId(hContact))); + PushRequest(new AsyncHttpRequest(REQUEST_POST, HOST_CONTACTS, "/users/SELF/invites/" + mir_urlEncode(getId(hContact)) + "/accept")); return 0; } @@ -257,15 +257,6 @@ bool CTeamsProto::OnContactDeleted(MCONTACT hContact, uint32_t flags) ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR CTeamsProto::BlockContact(WPARAM hContact, LPARAM) -{ - if (!IsOnline()) return 1; - - if (IDYES == MessageBox(NULL, TranslateT("Are you sure?"), TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)) - PushRequest(new BlockContactRequest(this, hContact)); - return 0; -} - void CTeamsProto::OnBlockContact(MHttpResponse *response, AsyncHttpRequest *pRequest) { MCONTACT hContact = (DWORD_PTR)pRequest->pUserInfo; @@ -273,12 +264,21 @@ void CTeamsProto::OnBlockContact(MHttpResponse *response, AsyncHttpRequest *pReq Contact::Hide(hContact); } -INT_PTR CTeamsProto::UnblockContact(WPARAM hContact, LPARAM) +INT_PTR CTeamsProto::BlockContact(WPARAM hContact, LPARAM) { - PushRequest(new UnblockContactRequest(this, hContact)); + if (!IsOnline()) return 1; + + if (IDYES == MessageBox(NULL, TranslateT("Are you sure?"), TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)) { + auto *pReq = new AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, "/users/SELF/contacts/blocklist/" + mir_urlEncode(getId(hContact)), &CTeamsProto::OnBlockContact); + pReq->m_szParam = "{\"report_abuse\":\"false\",\"ui_version\":\"skype.com\"}"; + pReq->pUserInfo = (void *)hContact; + PushRequest(pReq); + } return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + void CTeamsProto::OnUnblockContact(MHttpResponse *response, AsyncHttpRequest *pRequest) { if (response == nullptr) @@ -288,3 +288,14 @@ void CTeamsProto::OnUnblockContact(MHttpResponse *response, AsyncHttpRequest *pR Contact::Hide(hContact, false); delSetting(hContact, "IsBlocked"); } + +INT_PTR CTeamsProto::UnblockContact(WPARAM hContact, LPARAM) +{ + if (!IsOnline()) return 1; + + auto *pReq = new AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, "/users/SELF/contacts/blocklist/" + mir_urlEncode(getId(hContact)), &CTeamsProto::OnUnblockContact); + pReq->pUserInfo = (void *)hContact; + pReq << CHAR_PARAM("reporterIp", "123.123.123.123") << CHAR_PARAM("uiVersion", g_szMirVer); // TODO: user ip address + PushRequest(pReq); + return 0; +} diff --git a/protocols/Teams/src/teams_endpoint.cpp b/protocols/Teams/src/teams_endpoint.cpp index ead0857bf0..b304cd135b 100644 --- a/protocols/Teams/src/teams_endpoint.cpp +++ b/protocols/Teams/src/teams_endpoint.cpp @@ -136,7 +136,7 @@ void CTeamsProto::OnCapabilitiesSended(MHttpResponse *response, AsyncHttpRequest skypenames.destroy(); ReceiveAvatar(0); - PushRequest(new GetContactListRequest()); + PushRequest(new AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/users/SELF/contacts", &CTeamsProto::LoadContactList)); PushRequest(new SyncConversations()); JSONNode root = JSONNode::parse(response->body); diff --git a/protocols/Teams/src/teams_http.cpp b/protocols/Teams/src/teams_http.cpp index cc448b3a1d..a24b44bfbc 100644 --- a/protocols/Teams/src/teams_http.cpp +++ b/protocols/Teams/src/teams_http.cpp @@ -23,7 +23,7 @@ AsyncHttpRequest::AsyncHttpRequest(int type, SkypeHost host, LPCSTR url, MTHttpR switch (host) { case HOST_API: m_szUrl = "api.skype.com"; break; case HOST_PEOPLE: m_szUrl = "people.skype.com/v2"; break; - case HOST_CONTACTS: m_szUrl = "edge.skype.com/pcs/contacts/v2"; break; + case HOST_CONTACTS: m_szUrl = "contacts.skype.com/contacts/v2"; break; case HOST_GRAPH: m_szUrl = "skypegraph.skype.com"; break; case HOST_LOGIN: m_szUrl = "login.microsoftonline.com"; break; case HOST_TEAMS: m_szUrl = "teams.live.com"; break; diff --git a/protocols/Teams/src/teams_proto.cpp b/protocols/Teams/src/teams_proto.cpp index 422904ad2e..9999e41c2e 100644 --- a/protocols/Teams/src/teams_proto.cpp +++ b/protocols/Teams/src/teams_proto.cpp @@ -167,7 +167,7 @@ int CTeamsProto::Authorize(MEVENT hDbEvent) if (hContact == INVALID_CONTACT_ID) return 1; - PushRequest(new AuthAcceptRequest(getId(hContact))); + PushRequest(new AsyncHttpRequest(REQUEST_POST, HOST_CONTACTS, "/users/SELF/invites/" + mir_urlEncode(getId(hContact)) + "/accept")); return 0; } @@ -177,7 +177,7 @@ int CTeamsProto::AuthDeny(MEVENT hDbEvent, const wchar_t *) if (hContact == INVALID_CONTACT_ID) return 1; - PushRequest(new AuthDeclineRequest(getId(hContact))); + PushRequest(new AsyncHttpRequest(REQUEST_POST, HOST_CONTACTS, "/users/SELF/invites/" + mir_urlEncode(getId(hContact)) + "/decline")); return 0; } @@ -191,7 +191,15 @@ int CTeamsProto::AuthRequest(MCONTACT hContact, const wchar_t *szMessage) if (hContact == INVALID_CONTACT_ID) return 1; - PushRequest(new AddContactRequest(getId(hContact), T2Utf(szMessage))); + auto *pReq = new AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, "/users/SELF/contacts"); + + JSONNode node; + node << CHAR_PARAM("mri", getId(hContact)); + if (mir_wstrlen(szMessage)) + node << WCHAR_PARAM("greeting", szMessage); + pReq->m_szParam = node.write().c_str(); + + PushRequest(pReq); return 0; } |
