mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
✨ Add NextCloud user invite functionality
This commit is contained in:
parent
785b0e385e
commit
710ba33d77
|
@ -88,6 +88,10 @@ export class NextCloud implements INodeType {
|
||||||
name: 'Folder',
|
name: 'Folder',
|
||||||
value: 'folder',
|
value: 'folder',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'User',
|
||||||
|
value: 'user',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
default: 'file',
|
default: 'file',
|
||||||
description: 'The resource to operate on.',
|
description: 'The resource to operate on.',
|
||||||
|
@ -182,7 +186,27 @@ export class NextCloud implements INodeType {
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Add',
|
||||||
|
value: 'add',
|
||||||
|
description: 'Add a user to a NextCloud organization',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'add',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// file
|
// file
|
||||||
|
@ -478,6 +502,76 @@ export class NextCloud implements INodeType {
|
||||||
description: 'The path of which to list the content.',
|
description: 'The path of which to list the content.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// user
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// user:add
|
||||||
|
// ----------------------------------
|
||||||
|
{
|
||||||
|
displayName: 'User ID',
|
||||||
|
name: 'userId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'add',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
placeholder: 'john',
|
||||||
|
description: 'The user to add.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Email',
|
||||||
|
name: 'email',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'add',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
placeholder: 'john@email.com',
|
||||||
|
description: 'The email of the user to add.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Additional Fields',
|
||||||
|
name: 'additionalFields',
|
||||||
|
type: 'collection',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'user',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'add',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Display name',
|
||||||
|
name: 'displayName',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'The display name of the user to add.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -506,7 +600,7 @@ export class NextCloud implements INodeType {
|
||||||
let requestMethod = '';
|
let requestMethod = '';
|
||||||
let responseData: any; // tslint:disable-line:no-any
|
let responseData: any; // tslint:disable-line:no-any
|
||||||
|
|
||||||
let body: string | Buffer = '';
|
let body: string | Buffer | IDataObject = '';
|
||||||
const headers: IDataObject = {};
|
const headers: IDataObject = {};
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
@ -598,6 +692,32 @@ export class NextCloud implements INodeType {
|
||||||
headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`;
|
headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (resource === 'user') {
|
||||||
|
|
||||||
|
if (operation === 'add') {
|
||||||
|
// ----------------------------------
|
||||||
|
// user:add
|
||||||
|
// ----------------------------------
|
||||||
|
requestMethod = 'POST';
|
||||||
|
|
||||||
|
endpoint = `/ocs/v1.php/cloud/users`;
|
||||||
|
|
||||||
|
headers['OCS-APIRequest'] = true;
|
||||||
|
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||||
|
|
||||||
|
const userid = this.getNodeParameter('userId', i) as string;
|
||||||
|
const email = this.getNodeParameter('email', i) as string;
|
||||||
|
|
||||||
|
body = `userid=${userid}&email=${email}`;
|
||||||
|
|
||||||
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
|
||||||
|
if (additionalFields.displayName) {
|
||||||
|
body += `&displayName=${additionalFields.displayName}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`The resource "${resource}" is not known!`);
|
throw new Error(`The resource "${resource}" is not known!`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue