From 1cfdae389e374b3df25011685b3328db4fe95a38 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sat, 23 Jan 2021 12:57:30 +0100 Subject: [PATCH] :zap: Minor improvement to NextCloud Node --- .../nodes-base/nodes/NextCloud/GenericFunctions.ts | 4 ++-- packages/nodes-base/nodes/NextCloud/NextCloud.node.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts index 673a24100bf..68bc908f921 100644 --- a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts @@ -19,8 +19,8 @@ import { export async function nextCloudApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object | string | Buffer, headers?: object, encoding?: null | undefined, query?: object): Promise { // tslint:disable-line:no-any const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); - - const options : OptionsWithUri = { + + const options: OptionsWithUri = { headers, method, body, diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index 39f8f569bd9..096b39427f1 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -695,7 +695,6 @@ export class NextCloud implements INodeType { } } else if (resource === 'user') { - if (operation === 'create') { // ---------------------------------- // user:create @@ -774,7 +773,12 @@ export class NextCloud implements INodeType { if (err) { return reject(err); } - resolve(data as IDataObject); + + if (data.ocs.meta.status !== 'ok') { + return reject(new Error(data.ocs.meta.message)); + } + + resolve(data.ocs.data as IDataObject); }); }); @@ -841,7 +845,7 @@ export class NextCloud implements INodeType { if (resource === 'file' && operation === 'download') { // For file downloads the files get attached to the existing items return this.prepareOutputData(items); - } else { + } else { // For all other ones does the output get replaced return [this.helpers.returnJsonArray(returnData)]; }