From 9153b50b7815e27043cf4dedd6968c7901157cdf Mon Sep 17 00:00:00 2001 From: aunsane Date: Thu, 9 Mar 2017 23:41:08 +0300 Subject: Dropbox: chaged method that shares links: now it generates temporary direct linc to a file --- plugins/Dropbox/src/api/operations.h | 9 +++------ plugins/Dropbox/src/dropbox_commands.cpp | 5 ++--- plugins/Dropbox/src/dropbox_transfers.cpp | 5 ++--- 3 files changed, 7 insertions(+), 12 deletions(-) (limited to 'plugins/Dropbox/src') diff --git a/plugins/Dropbox/src/api/operations.h b/plugins/Dropbox/src/api/operations.h index 01f428c88a..c451e4190c 100644 --- a/plugins/Dropbox/src/api/operations.h +++ b/plugins/Dropbox/src/api/operations.h @@ -1,11 +1,11 @@ #ifndef _DROPBOX_API_OPERATIONS_H_ #define _DROPBOX_API_OPERATIONS_H_ -class ShareRequest : public HttpRequest +class GetTemporaryLinkRequest : public HttpRequest { public: - ShareRequest(const char *token, const char *path, time_t expires = 0) : - HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/sharing/create_shared_link_with_settings") + GetTemporaryLinkRequest(const char *token, const char *path) : + HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/get_temporary_link") { AddBearerAuthHeader(token); AddHeader("Content-Type", "application/json"); @@ -13,9 +13,6 @@ public: JSONNode root(JSON_NODE); root << JSONNode("path", path); - if (expires) - root << JSONNode("expires", (unsigned int)expires); - json_string data = root.write(); SetData(data.c_str(), data.length()); } diff --git a/plugins/Dropbox/src/dropbox_commands.cpp b/plugins/Dropbox/src/dropbox_commands.cpp index 469b17256f..350fd3d8c7 100644 --- a/plugins/Dropbox/src/dropbox_commands.cpp +++ b/plugins/Dropbox/src/dropbox_commands.cpp @@ -77,8 +77,7 @@ void CDropbox::CommandShare(void *arg) } ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); - //bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0; - ShareRequest request(token, path); + GetTemporaryLinkRequest request(token, path); NLHR_PTR response(request.Send(param->instance->hNetlibConnection)); if (response == NULL || response->resultCode != HTTP_STATUS_OK) { @@ -92,7 +91,7 @@ void CDropbox::CommandShare(void *arg) return; } - CMStringA link = root.at("url").as_string().c_str(); + CMStringA link = root.at("link").as_string().c_str(); ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); ProtoChainSend(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)link.GetBuffer()); } diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index 85f3d44592..556bccbcfc 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -76,8 +76,7 @@ void CDropbox::CreateFolder(const char *path) void CDropbox::CreateDownloadUrl(const char *path, char *url) { ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); - //bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0; - ShareRequest request(token, path); + GetTemporaryLinkRequest request(token, path); NLHR_PTR response(request.Send(hNetlibConnection)); HandleJsonResponseError(response); @@ -86,7 +85,7 @@ void CDropbox::CreateDownloadUrl(const char *path, char *url) if (root.empty()) return; - JSONNode node = root.at("url"); + JSONNode node = root.at("link"); mir_strcpy(url, node.as_string().c_str()); } -- cgit v1.2.3