Minor improvement to NextCloud Node

This commit is contained in:
Jan Oberhauser 2021-01-23 12:57:30 +01:00
parent 2ca9c6de7d
commit 1cfdae389e
2 changed files with 9 additions and 5 deletions

View file

@ -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<any> { // tslint:disable-line:no-any export async function nextCloudApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object | string | Buffer, headers?: object, encoding?: null | undefined, query?: object): Promise<any> { // tslint:disable-line:no-any
const resource = this.getNodeParameter('resource', 0); const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0); const operation = this.getNodeParameter('operation', 0);
const options : OptionsWithUri = { const options: OptionsWithUri = {
headers, headers,
method, method,
body, body,

View file

@ -695,7 +695,6 @@ export class NextCloud implements INodeType {
} }
} else if (resource === 'user') { } else if (resource === 'user') {
if (operation === 'create') { if (operation === 'create') {
// ---------------------------------- // ----------------------------------
// user:create // user:create
@ -774,7 +773,12 @@ export class NextCloud implements INodeType {
if (err) { if (err) {
return reject(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') { if (resource === 'file' && operation === 'download') {
// For file downloads the files get attached to the existing items // For file downloads the files get attached to the existing items
return this.prepareOutputData(items); return this.prepareOutputData(items);
} else { } else {
// For all other ones does the output get replaced // For all other ones does the output get replaced
return [this.helpers.returnJsonArray(returnData)]; return [this.helpers.returnJsonArray(returnData)];
} }