mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
⚡ Minor improvements on NextCloud Node
This commit is contained in:
parent
d9f7ebdea9
commit
35e790b8dd
|
@ -699,11 +699,11 @@ export class NextCloud implements INodeType {
|
||||||
// user:update
|
// user:update
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Update Fields',
|
||||||
name: 'options',
|
name: 'updateFields',
|
||||||
type: 'fixedCollection',
|
type: 'fixedCollection',
|
||||||
typeOptions:{
|
typeOptions: {
|
||||||
multipleValues:false,
|
multipleValues: false,
|
||||||
},
|
},
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Option',
|
||||||
default: {},
|
default: {},
|
||||||
|
@ -719,8 +719,8 @@ export class NextCloud implements INodeType {
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Fields',
|
||||||
name: 'option',
|
name: 'field',
|
||||||
values: [
|
values: [
|
||||||
{
|
{
|
||||||
displayName: 'Key',
|
displayName: 'Key',
|
||||||
|
@ -728,46 +728,46 @@ export class NextCloud implements INodeType {
|
||||||
type: 'options',
|
type: 'options',
|
||||||
default: 'email',
|
default: 'email',
|
||||||
options:
|
options:
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name: 'Email',
|
name: 'Address',
|
||||||
value: 'email',
|
value: 'address',
|
||||||
description: 'The new email for the user.',
|
description: 'The new address for the user.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Display Name',
|
name: 'Display Name',
|
||||||
value: 'displayname',
|
value: 'displayname',
|
||||||
description: 'The new display name for the user.',
|
description: 'The new display name for the user.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Address',
|
name: 'Email',
|
||||||
value: 'address',
|
value: 'email',
|
||||||
description: 'The new address for the user.',
|
description: 'The new email for the user.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Website',
|
name: 'Password',
|
||||||
value: 'website',
|
value: 'password',
|
||||||
description: 'The new website for the user.',
|
description: 'The new password for the user.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Twitter',
|
name: 'Twitter',
|
||||||
value: 'twitter',
|
value: 'twitter',
|
||||||
description: 'The new twitter for the user.',
|
description: 'The new twitter handle for the user.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Password',
|
name: 'Website',
|
||||||
value: 'password',
|
value: 'website',
|
||||||
description: 'The new password for the user.',
|
description: 'The new website for the user.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
description: 'Key of the updated attribut.',
|
description: 'Key of the updated attribute.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Value',
|
displayName: 'Value',
|
||||||
name: 'value',
|
name: 'value',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Value of the updated attribut.',
|
description: 'Value of the updated attribute.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -900,6 +900,7 @@ export class NextCloud implements INodeType {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// user:create
|
// user:create
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'POST';
|
requestMethod = 'POST';
|
||||||
|
|
||||||
endpoint = 'ocs/v1.php/cloud/users';
|
endpoint = 'ocs/v1.php/cloud/users';
|
||||||
|
@ -922,6 +923,7 @@ export class NextCloud implements INodeType {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// user:delete
|
// user:delete
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'DELETE';
|
requestMethod = 'DELETE';
|
||||||
|
|
||||||
const userid = this.getNodeParameter('userId', i) as string;
|
const userid = this.getNodeParameter('userId', i) as string;
|
||||||
|
@ -934,6 +936,7 @@ export class NextCloud implements INodeType {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// user:get
|
// user:get
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
|
|
||||||
const userid = this.getNodeParameter('userId', i) as string;
|
const userid = this.getNodeParameter('userId', i) as string;
|
||||||
|
@ -946,6 +949,7 @@ export class NextCloud implements INodeType {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// user:getAll
|
// user:getAll
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
qs = this.getNodeParameter('options', i) as IDataObject;
|
qs = this.getNodeParameter('options', i) as IDataObject;
|
||||||
|
@ -959,15 +963,16 @@ export class NextCloud implements INodeType {
|
||||||
}
|
}
|
||||||
if (operation === 'update') {
|
if (operation === 'update') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// user:get
|
// user:update
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'PUT';
|
requestMethod = 'PUT';
|
||||||
|
|
||||||
const userid = this.getNodeParameter('userId', i) as string;
|
const userid = this.getNodeParameter('userId', i) as string;
|
||||||
endpoint = `ocs/v1.php/cloud/users/${userid}`;
|
endpoint = `ocs/v1.php/cloud/users/${userid}`;
|
||||||
|
|
||||||
body = Object.entries((this.getNodeParameter('options', i) as IDataObject).option as IDataObject).map(entry=> {
|
body = Object.entries((this.getNodeParameter('updateFields', i) as IDataObject).field as IDataObject).map(entry => {
|
||||||
const [key,value] = entry;
|
const [key, value] = entry;
|
||||||
return `${key}=${value}`;
|
return `${key}=${value}`;
|
||||||
}).join('&');
|
}).join('&');
|
||||||
|
|
||||||
|
@ -1022,9 +1027,9 @@ export class NextCloud implements INodeType {
|
||||||
|
|
||||||
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(responseData, endpoint);
|
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(responseData, endpoint);
|
||||||
|
|
||||||
} else if (resource === 'user' ) {
|
} else if (resource === 'user') {
|
||||||
|
|
||||||
if (operation !== 'getAll'){
|
if (operation !== 'getAll') {
|
||||||
|
|
||||||
const jsonResponseData: IDataObject = await new Promise((resolve, reject) => {
|
const jsonResponseData: IDataObject = await new Promise((resolve, reject) => {
|
||||||
parseString(responseData, { explicitArray: false }, (err, data) => {
|
parseString(responseData, { explicitArray: false }, (err, data) => {
|
||||||
|
@ -1036,7 +1041,7 @@ export class NextCloud implements INodeType {
|
||||||
return reject(new Error(data.ocs.meta.message || data.ocs.meta.status));
|
return reject(new Error(data.ocs.meta.message || data.ocs.meta.status));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation === 'delete' || operation === 'update'){
|
if (operation === 'delete' || operation === 'update') {
|
||||||
resolve(data.ocs.meta as IDataObject);
|
resolve(data.ocs.meta as IDataObject);
|
||||||
} else {
|
} else {
|
||||||
resolve(data.ocs.data as IDataObject);
|
resolve(data.ocs.data as IDataObject);
|
||||||
|
@ -1057,7 +1062,7 @@ export class NextCloud implements INodeType {
|
||||||
return reject(new Error(data.ocs.meta.message));
|
return reject(new Error(data.ocs.meta.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(data.ocs.data.users.element) === 'string') {
|
if (typeof (data.ocs.data.users.element) === 'string') {
|
||||||
resolve([data.ocs.data.users.element] as IDataObject[]);
|
resolve([data.ocs.data.users.element] as IDataObject[]);
|
||||||
} else {
|
} else {
|
||||||
resolve(data.ocs.data.users.element as IDataObject[]);
|
resolve(data.ocs.data.users.element as IDataObject[]);
|
||||||
|
@ -1066,7 +1071,7 @@ export class NextCloud implements INodeType {
|
||||||
});
|
});
|
||||||
|
|
||||||
jsonResponseData.forEach(value => {
|
jsonResponseData.forEach(value => {
|
||||||
returnData.push( {id:value} as IDataObject);
|
returnData.push({ id: value } as IDataObject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue