From 2b4f5c6c785ab6ffc7198f60369886c44dea6ef2 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Fri, 19 Aug 2022 16:35:01 +0300 Subject: [PATCH] fix(next-cloud-node): Fix issue with credential verification and sharing file --- packages/nodes-base/nodes/NextCloud/GenericFunctions.ts | 8 ++++++-- packages/nodes-base/nodes/NextCloud/NextCloud.node.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts index d8636d7c94..5e862b0674 100644 --- a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts @@ -21,8 +21,7 @@ export async function nextCloudApiRequest( headers?: object, encoding?: null | undefined, query?: object, - // tslint:disable-next-line:no-any -): Promise { +) { const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); const authenticationMethod = this.getNodeParameter('authentication', 0); @@ -49,10 +48,15 @@ export async function nextCloudApiRequest( } options.uri = `${credentials.webDavUrl}/${encodeURI(endpoint)}`; + if (resource === 'user' && operation === 'create') { options.uri = options.uri.replace('/remote.php/webdav', ''); } + if (resource === 'file' && operation === 'share') { + options.uri = options.uri.replace('/remote.php/webdav', ''); + } + const credentialType = authenticationMethod === 'accessToken' ? 'nextCloudApi' : 'nextCloudOAuth2Api'; diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index a2a80f3bab..0dd92f654b 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -1,5 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { NodeApiError } from 'n8n-workflow'; +import { IBinaryKeyData, NodeApiError } from 'n8n-workflow'; import { IDataObject, @@ -1139,7 +1139,7 @@ export class NextCloud implements INodeType { // Create a shallow copy of the binary data so that the old // data references which do not get changed still stay behind // but the incoming data does not get changed. - Object.assign(newItem.binary, items[i].binary); + Object.assign(newItem.binary as IBinaryKeyData, items[i].binary); } items[i] = newItem;