mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Small improvements
This commit is contained in:
parent
233a390075
commit
2ca9c6de7d
|
@ -17,6 +17,9 @@ import {
|
||||||
* @returns {Promise<any>}
|
* @returns {Promise<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
|
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 operation = this.getNodeParameter('operation', 0);
|
||||||
|
|
||||||
const options : OptionsWithUri = {
|
const options : OptionsWithUri = {
|
||||||
headers,
|
headers,
|
||||||
method,
|
method,
|
||||||
|
@ -46,9 +49,6 @@ export async function nextCloudApiRequest(this: IHookFunctions | IExecuteFunctio
|
||||||
|
|
||||||
options.uri = `${credentials.webDavUrl}/${encodeURI(endpoint)}`;
|
options.uri = `${credentials.webDavUrl}/${encodeURI(endpoint)}`;
|
||||||
|
|
||||||
const resource = this.getNodeParameter('resource', 0);
|
|
||||||
const operation = this.getNodeParameter('operation', 0);
|
|
||||||
|
|
||||||
if (resource === 'user' && operation === 'create') {
|
if (resource === 'user' && operation === 'create') {
|
||||||
options.uri = options.uri.replace('/remote.php/webdav', '');
|
options.uri = options.uri.replace('/remote.php/webdav', '');
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,13 @@ export async function nextCloudApiRequest(this: IHookFunctions | IExecuteFunctio
|
||||||
|
|
||||||
options.uri = `${credentials.webDavUrl}/${encodeURI(endpoint)}`;
|
options.uri = `${credentials.webDavUrl}/${encodeURI(endpoint)}`;
|
||||||
|
|
||||||
|
if (resource === 'user' && operation === 'create') {
|
||||||
|
options.uri = options.uri.replace('/remote.php/webdav', '');
|
||||||
|
}
|
||||||
|
|
||||||
return await this.helpers.requestOAuth2!.call(this, 'nextCloudOAuth2Api', options);
|
return await this.helpers.requestOAuth2!.call(this, 'nextCloudOAuth2Api', options);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
throw new Error(`NextCloud Error. Status Code: ${error.statusCode}. Message: ${error.message}`);
|
throw new Error(`NextCloud Error. Status Code: ${error.statusCode}. Message: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ export class NextCloud implements INodeType {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Create',
|
name: 'Create',
|
||||||
value: 'Create',
|
value: 'create',
|
||||||
description: 'Invite a user to a NextCloud organization',
|
description: 'Invite a user to a NextCloud organization',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -510,7 +510,7 @@ export class NextCloud implements INodeType {
|
||||||
// user:create
|
// user:create
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'User ID',
|
displayName: 'Username',
|
||||||
name: 'userId',
|
name: 'userId',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -526,7 +526,7 @@ export class NextCloud implements INodeType {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
placeholder: 'john',
|
placeholder: 'john',
|
||||||
description: 'The ID of the user to invite.',
|
description: 'Username the user will have.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Email',
|
displayName: 'Email',
|
||||||
|
@ -551,6 +551,7 @@ export class NextCloud implements INodeType {
|
||||||
displayName: 'Additional Fields',
|
displayName: 'Additional Fields',
|
||||||
name: 'additionalFields',
|
name: 'additionalFields',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
|
Loading…
Reference in a new issue