feat(Slack Node): Revamp the node with more functionalities in a new version (#4587)

* 🔥 Remove useless tooltips

* Slack change additional fields to Options in node

* 🥅 Add error handeling for out of Scope request

* ♻️ Refactor channel visibility

* ♻️ refactor user ressource

* Update user profile

* 🔥 remove JSON parameter

* 🔥 remove attchmant json and block json

* 🎨 refactors message post

* 🎨 refactor ts property into timestamps

* 🎨 change action name for messages

*  add new operation to message ressouce

*  add search backend logic + channel RLC

* 🎨 improve timestamp description and plaecholder

* 🎨 change timestamp disaplay name

*  add RLC for channels

*  add versioning

* 🐛 Fix imports for versioning

*  Add RLC for users when sending messages

*  RLC for user presence

*  Add json builder for slack blocks

* 🐛 Fix option in search query

* Add loadoption for search in channels

* Fix indentation issue

*  Add more scopes to Oauth2

* 🐛 Fix lint issue

* 🐛 oauth fix

*  Merge user and user profile

*  Improve reactions and star resource

* ️Merges ephemeral operation into one

* ️Merge image and emoji in profile picture

* 🐛Fix bug for replying to messages

* ️Add username type to User Rlc

* 🐛 Fix typo

* 🎨 Improves tooltip and naming for ephemeral messages

* 🎨 Improve display name and description

* ️Add the ability to delete within username channel

* 🎨 Add informations on how to use the emojis and add doc

* 🎨 Fix typos and improve display names

*  Improve FE validation for timestamp

* 🎨 Change block description

* 🚨 Fix linting

* 🚨 More lint fixes

* 🐛 Fix timestamps bug

* 🐛 Fix timestamp not showing up

* 🐛 More small fixes

* 🐛 Fix logic error

* Add searchable to slack rlc channels and users

* Fix lint rules

* ️Message Search -> fix limit request using qs count

* ️Message Search -> sort by relevance use qs score

* Fix messages by username rlc

* 🐛 fix messages search all operation

* Add error when using username with ephemeral message

* 🎨 fix linting errors

* 🎨 send message ephemeral error message improvement

---------

Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
agobrech 2023-02-03 17:04:37 +01:00 committed by GitHub
parent 8a224c0c89
commit 4df69428f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 6857 additions and 1389 deletions

View file

@ -68,5 +68,12 @@ export class SlackOAuth2Api implements ICredentialType {
type: 'hidden',
default: 'body',
},
{
displayName:
'If you get an Invalid Scopes error, make sure you add the correct one <a target="_blank" href="https://docs.n8n.io/integrations/builtin/credentials/slack/#using-oauth">here</a> to your Slack integration',
name: 'notice',
type: 'notice',
default: '',
},
];
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,286 @@
import type { INodeProperties } from 'n8n-workflow';
export const fileOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['file'],
},
},
options: [
{
name: 'Get',
value: 'get',
action: 'Get a file',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get & filters team files',
action: 'Get many files',
},
{
name: 'Upload',
value: 'upload',
description: 'Create or upload an existing file',
action: 'Upload a file',
},
],
default: 'upload',
},
];
export const fileFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* file:upload */
/* -------------------------------------------------------------------------- */
{
displayName: 'Binary Data',
name: 'binaryData',
type: 'boolean',
default: false,
displayOptions: {
show: {
operation: ['upload'],
resource: ['file'],
},
},
description: 'Whether the data to upload should be taken from binary field',
},
{
displayName: 'File Content',
name: 'fileContent',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['upload'],
resource: ['file'],
binaryData: [false],
},
},
placeholder: '',
},
{
displayName: 'Binary Property',
name: 'binaryPropertyName',
type: 'string',
default: 'data',
required: true,
displayOptions: {
show: {
operation: ['upload'],
resource: ['file'],
binaryData: [true],
},
},
placeholder: '',
description: 'Name of the binary property which contains the data for the file to be uploaded',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
operation: ['upload'],
resource: ['file'],
},
},
default: {},
description: 'Other options to set',
placeholder: 'Add options',
options: [
{
displayName: 'Channel Names or IDs',
name: 'channelIds',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
default: [],
description:
'The channels to send the file to. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'File Name',
name: 'fileName',
type: 'string',
default: '',
},
{
displayName: 'Initial Comment',
name: 'initialComment',
type: 'string',
default: '',
description: 'The message text introducing the file in specified channels',
},
{
displayName: 'Thread Timestamp',
name: 'threadTs',
type: 'string',
default: '',
description:
"Provide another message's Timestamp value to upload this file as a reply. Never use a reply's Timestamp value; use its parent instead.",
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
},
],
},
/* ----------------------------------------------------------------------- */
/* file:getAll */
/* ----------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['file'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['file'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['file'],
},
},
default: {},
placeholder: 'Add Field',
options: [
{
displayName: 'Channel Name or ID',
name: 'channelId',
type: 'options',
default: '',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
description:
'Channel containing the file to be listed. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Show Files Hidden By Limit',
name: 'showFilesHidden',
type: 'boolean',
default: false,
description:
'Whether to show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit',
},
{
displayName: 'Message Timestamp From',
name: 'tsFrom',
type: 'string',
default: '',
description: 'Filter files created after this timestamp (inclusive)',
},
{
displayName: 'Message Timestamp To',
name: 'tsTo',
type: 'string',
default: '',
description: 'Filter files created before this timestamp (inclusive)',
},
{
displayName: 'Types',
name: 'types',
type: 'multiOptions',
options: [
{
name: 'All',
value: 'all',
},
{
name: 'Google Docs',
value: 'gdocs',
},
{
name: 'Images',
value: 'images',
},
{
name: 'PDFs',
value: 'pdfs',
},
{
name: 'Snippets',
value: 'snippets',
},
{
name: 'Spaces',
value: 'spaces',
},
{
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
name: 'zips',
value: 'zips',
},
],
default: ['all'],
description: 'Filter files by type',
},
{
displayName: 'User Name or ID',
name: 'userId',
type: 'options',
default: '',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
description:
'Filter files created by a single user. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
],
},
/* ----------------------------------------------------------------------- */
/* file:get */
/* ----------------------------------------------------------------------- */
{
displayName: 'File ID',
name: 'fileId',
type: 'string',
displayOptions: {
show: {
resource: ['file'],
operation: ['get'],
},
},
default: '',
},
];

View file

@ -0,0 +1,137 @@
import type { OptionsWithUri } from 'request';
import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
import type { IDataObject, IOAuth2Options } from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';
import _ from 'lodash';
export async function slackApiRequest(
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
method: string,
resource: string,
body: object = {},
query: object = {},
headers: {} | undefined = undefined,
option: {} = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string;
let options: OptionsWithUri = {
method,
headers: headers ?? {
'Content-Type': 'application/json; charset=utf-8',
},
body,
qs: query,
uri: `https://slack.com/api${resource}`,
json: true,
};
options = Object.assign({}, options, option);
if (Object.keys(body).length === 0) {
delete options.body;
}
if (Object.keys(query).length === 0) {
delete options.qs;
}
const oAuth2Options: IOAuth2Options = {
tokenType: 'Bearer',
property: 'authed_user.access_token',
};
const credentialType = authenticationMethod === 'accessToken' ? 'slackApi' : 'slackOAuth2Api';
const response = await this.helpers.requestWithAuthentication.call(
this,
credentialType,
options,
{
oauth2: oAuth2Options,
},
);
if (response.ok === false) {
if (response.error === 'paid_teams_only') {
throw new NodeOperationError(
this.getNode(),
`Your current Slack plan does not include the resource '${
this.getNodeParameter('resource', 0) as string
}'`,
{
description:
'Hint: Upgrate to the Slack plan that includes the funcionality you want to use.',
},
);
} else if (response.error === 'missing_scope') {
throw new NodeOperationError(
this.getNode(),
'Your Slack credential is missing required Oauth Scopes',
{
description: `Add the following scope(s) to your Slack App: ${response.needed}`,
},
);
}
throw new NodeOperationError(
this.getNode(),
'Slack error response: ' + JSON.stringify(response.error),
);
}
if (response.ts !== undefined) {
Object.assign(response, { message_timestamp: response.ts });
delete response.ts;
}
return response;
}
export async function slackApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions,
propertyName: string,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
query.page = 1;
//if the endpoint uses legacy pagination use count
//https://api.slack.com/docs/pagination#classic
if (endpoint.includes('files.list')) {
query.count = 100;
} else {
query.limit = 100;
}
do {
responseData = await slackApiRequest.call(this, method, endpoint, body, query);
query.cursor = _.get(responseData, 'response_metadata.next_cursor');
query.page++;
returnData.push.apply(
returnData,
responseData[propertyName].matches ?? responseData[propertyName],
);
} while (
(responseData.response_metadata?.next_cursor !== undefined &&
responseData.response_metadata.next_cursor !== '' &&
responseData.response_metadata.next_cursor !== null) ||
(responseData.paging?.pages !== undefined &&
responseData.paging.page !== undefined &&
responseData.paging.page < responseData.paging.pages) ||
(responseData[propertyName].paging?.pages !== undefined &&
responseData[propertyName].paging.page !== undefined &&
responseData[propertyName].paging.page < responseData[propertyName].paging.pages)
);
return returnData;
}
// tslint:disable-next-line:no-any
export function validateJSON(json: string | undefined): any {
let result;
try {
result = JSON.parse(json!);
} catch (exception) {
result = undefined;
}
return result;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,5 @@
export interface IAttachment {
fields: {
item?: object[];
};
}

View file

@ -0,0 +1,131 @@
import type { INodeProperties } from 'n8n-workflow';
export const reactionOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['reaction'],
},
},
options: [
{
name: 'Add',
value: 'add',
description: 'Adds a reaction to a message',
action: 'Add a reaction',
},
{
name: 'Get',
value: 'get',
description: 'Get the reactions of a message',
action: 'Get a reaction',
},
{
name: 'Remove',
value: 'remove',
description: 'Remove a reaction of a message',
action: 'Remove a reaction',
},
],
default: 'add',
},
];
export const reactionFields: INodeProperties[] = [
{
displayName: 'Channel',
name: 'channelId',
type: 'resourceLocator',
default: { mode: 'list', value: '' },
placeholder: 'Select a channel...',
modes: [
{
displayName: 'From List',
name: 'list',
type: 'list',
placeholder: 'Select a channel...',
typeOptions: {
searchListMethod: 'getChannels',
searchable: true,
},
},
{
displayName: 'By ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
regex: '[a-zA-Z0-9]{2,}',
errorMessage: 'Not a valid Slack Channel ID',
},
},
],
placeholder: 'C0122KQ70S7E',
},
{
displayName: 'By URL',
name: 'url',
type: 'string',
placeholder: 'https://app.slack.com/client/TS9594PZK/B0556F47Z3A',
validation: [
{
type: 'regex',
properties: {
regex: 'http(s)?://app.slack.com/client/.*/([a-zA-Z0-9]{2,})',
errorMessage: 'Not a valid Slack Channel URL',
},
},
],
extractValue: {
type: 'regex',
regex: 'https://app.slack.com/client/.*/([a-zA-Z0-9]{2,})',
},
},
],
required: true,
displayOptions: {
show: {
resource: ['reaction'],
operation: ['add', 'get', 'remove'],
},
},
description: 'The Slack channel to get the reactions from',
},
{
displayName: 'Message Timestamp',
name: 'timestamp',
required: true,
type: 'number',
default: undefined,
displayOptions: {
show: {
resource: ['reaction'],
operation: ['add', 'get', 'remove'],
},
},
description: 'Timestamp of the message to add, get or remove',
placeholder: '1663233118.856619',
},
{
displayName: 'Emoji Code',
name: 'name',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['reaction'],
operation: ['add', 'remove'],
},
},
description:
'Emoji code to use for the message reaction. Use emoji codes like +1, not an actual emoji like 👍. <a target="_blank" href=" https://www.webfx.com/tools/emoji-cheat-sheet/">List of common emoji codes</a>',
placeholder: '+1',
},
];

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,268 @@
import type { INodeProperties } from 'n8n-workflow';
export const starOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['star'],
},
},
options: [
{
name: 'Add',
value: 'add',
description: 'Add a star to an item',
action: 'Add a star',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a star from an item',
action: 'Delete a star',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many stars of autenticated user',
action: 'Get many stars',
},
],
default: 'add',
},
];
export const starFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* star:add */
/* -------------------------------------------------------------------------- */
{
displayName: 'Item to Add Star',
name: 'target',
type: 'options',
required: true,
description: 'Choose whether to add a star to a message or a file',
default: '',
placeholder: 'Select...',
displayOptions: {
show: {
operation: ['add'],
resource: ['star'],
},
},
options: [
{
name: 'Message',
value: 'message',
},
{
name: 'File',
value: 'file',
},
],
},
{
displayName: 'Channel',
name: 'channelId',
type: 'resourceLocator',
default: { mode: 'list', value: '' },
placeholder: 'Select a channel...',
description: 'The Slack channel to add a star to',
displayOptions: {
show: {
resource: ['star'],
operation: ['add'],
target: ['message', 'file'],
},
},
modes: [
{
displayName: 'From List',
name: 'list',
type: 'list',
placeholder: 'Select a channel...',
typeOptions: {
searchListMethod: 'getChannels',
searchable: true,
},
},
{
displayName: 'By ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
regex: '[a-zA-Z0-9]{2,}',
errorMessage: 'Not a valid Slack Channel ID',
},
},
],
placeholder: 'C0122KQ70S7E',
},
{
displayName: 'By URL',
name: 'url',
type: 'string',
placeholder: 'https://app.slack.com/client/TS9594PZK/B0556F47Z3A',
validation: [
{
type: 'regex',
properties: {
regex: 'http(s)?://app.slack.com/client/.*/([a-zA-Z0-9]{2,})',
errorMessage: 'Not a valid Slack Channel URL',
},
},
],
extractValue: {
type: 'regex',
regex: 'https://app.slack.com/client/.*/([a-zA-Z0-9]{2,})',
},
},
],
},
{
displayName: 'File ID',
name: 'fileId',
type: 'string',
default: '',
displayOptions: {
show: {
resource: ['star'],
operation: ['add'],
target: ['file'],
},
},
description: 'File to add star to',
},
{
displayName: 'Message Timestamp',
name: 'timestamp',
type: 'number',
default: undefined,
displayOptions: {
show: {
resource: ['star'],
operation: ['add'],
target: ['message'],
},
},
description: 'Timestamp of the message to add',
placeholder: '1663233118.856619',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
operation: ['add'],
resource: ['star'],
},
},
default: {},
description: 'Options to set',
placeholder: 'Add options',
options: [
{
displayName: 'File Comment',
name: 'fileComment',
type: 'string',
default: '',
description: 'File comment to add star to',
},
],
},
/* ----------------------------------------------------------------------- */
/* star:delete */
/* ----------------------------------------------------------------------- */
{
displayName: 'Options',
name: 'options',
type: 'collection',
displayOptions: {
show: {
operation: ['delete'],
resource: ['star'],
},
},
default: {},
description: 'Options to set',
placeholder: 'Add options',
options: [
{
displayName: 'Channel Name or ID',
name: 'channelId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
default: '',
description:
'Channel to add star to, or channel where the message to add star to was posted (used with timestamp). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'File ID',
name: 'fileId',
type: 'string',
default: '',
description: 'File to add star to',
},
{
displayName: 'File Comment',
name: 'fileComment',
type: 'string',
default: '',
description: 'File comment to add star to',
},
{
displayName: 'Message Timestamp',
name: 'timestamp',
type: 'number',
default: 0,
description: 'Timestamp of the message to delete',
placeholder: '1663233118.856619',
},
],
},
/* -------------------------------------------------------------------------- */
/* star:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['star'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['star'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
];

View file

@ -0,0 +1,297 @@
import type { INodeProperties } from 'n8n-workflow';
export const userOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['user'],
},
},
options: [
{
name: 'Get',
value: 'info',
description: 'Get information about a user',
action: 'Get information about a user',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get a list of many users',
action: 'Get many users',
},
{
name: "Get User's Status",
value: 'getPresence',
description: 'Get online status of a user',
action: "Get a user's presence status",
},
{
name: "Update User's Profile",
value: 'updateProfile',
description: "Update a user's profile",
action: "Update a user's profile",
},
],
default: 'info',
},
];
export const userFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* user:info */
/* -------------------------------------------------------------------------- */
{
displayName: 'User',
name: 'user',
type: 'resourceLocator',
default: { mode: 'list', value: '' },
placeholder: 'Select a user...',
description: 'The ID of the user to get information about',
displayOptions: {
show: {
operation: ['info'],
resource: ['user'],
},
},
modes: [
{
displayName: 'From List',
name: 'list',
type: 'list',
placeholder: 'Select a user...',
typeOptions: {
searchListMethod: 'getUsers',
searchable: true,
},
},
{
displayName: 'By ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
regex: '[a-zA-Z0-9]{2,}',
errorMessage: 'Not a valid Slack User ID',
},
},
],
placeholder: 'U123AB45JGM',
},
],
},
/* -------------------------------------------------------------------------- */
/* user:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['user'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['user'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
/* -------------------------------------------------------------------------- */
/* user:getPresence */
/* -------------------------------------------------------------------------- */
{
displayName: 'User',
name: 'user',
type: 'resourceLocator',
default: { mode: 'list', value: '' },
placeholder: 'Select a user...',
description: 'The ID of the user to get the online status of',
displayOptions: {
show: {
operation: ['getPresence'],
resource: ['user'],
},
},
modes: [
{
displayName: 'From List',
name: 'list',
type: 'list',
placeholder: 'Select a user...',
typeOptions: {
searchListMethod: 'getUsers',
searchable: true,
},
},
{
displayName: 'By ID',
name: 'id',
type: 'string',
validation: [
{
type: 'regex',
properties: {
regex: '[a-zA-Z0-9]{2,}',
errorMessage: 'Not a valid Slack User ID',
},
},
],
placeholder: 'U123AB45JGM',
},
],
},
/* -------------------------------------------------------------------------- */
/* user:update user profile */
/* -------------------------------------------------------------------------- */
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['user'],
operation: ['updateProfile'],
},
},
options: [
{
displayName: 'Custom Fields',
name: 'customFieldUi',
placeholder: 'Add Custom Fields',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'customFieldValues',
displayName: 'Custom Field',
values: [
{
displayName: 'Field Name or ID',
name: 'id',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTeamFields',
},
default: '',
description:
'ID of the field to set. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Field Value',
name: 'value',
type: 'string',
default: '',
description: 'Value of the field to set',
},
{
displayName: 'Alt',
name: 'alt',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
default: '',
description: 'This field can only be changed by admins for users on paid teams',
},
{
displayName: 'First Name',
name: 'first_name',
type: 'string',
default: '',
},
{
displayName: 'Last Name',
name: 'last_name',
type: 'string',
default: '',
},
{
displayName: 'Set Status',
name: 'status',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
placeholder: 'Set Status',
options: [
{
displayName: 'Set Status',
name: 'set_status',
values: [
{
displayName: 'Status Emoji',
name: 'status_emoji',
type: 'string',
default: '',
description:
'Is a string referencing an emoji enabled for the Slack team, such as :mountain_railway:',
},
{
displayName: 'Status Expiration',
name: 'status_expiration',
type: 'dateTime',
default: '',
description:
'The number of minutes to wait until this status expires and is cleared. Optional.',
},
{
displayName: 'Status Text',
name: 'status_text',
type: 'string',
default: '',
description: 'Allows up to 100 characters, though we strongly encourage brevity',
},
],
},
],
},
{
displayName: 'User ID',
name: 'user',
type: 'string',
default: '',
description:
'ID of user to change. This argument may only be specified by team admins on paid teams.',
},
],
},
];

View file

@ -0,0 +1,329 @@
import type { INodeProperties } from 'n8n-workflow';
export const userGroupOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['userGroup'],
},
},
options: [
{
name: 'Create',
value: 'create',
action: 'Create a user group',
},
{
name: 'Disable',
value: 'disable',
action: 'Disable a user group',
},
{
name: 'Enable',
value: 'enable',
action: 'Enable a user group',
},
{
name: 'Get Many',
value: 'getAll',
action: 'Get many user groups',
},
{
name: 'Update',
value: 'update',
action: 'Update a user group',
},
],
default: 'create',
},
];
export const userGroupFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* userGroup:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['create'],
resource: ['userGroup'],
},
},
required: true,
description: 'A name for the User Group. Must be unique among User Groups.',
},
{
displayName: 'Options',
name: 'Options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['userGroup'],
operation: ['create'],
},
},
options: [
{
displayName: 'Channel Names or IDs',
name: 'channelIds',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
default: [],
description:
'A comma-separated string of encoded channel IDs for which the User Group uses as a default. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'A short description of the User Group',
},
{
displayName: 'Handle',
name: 'handle',
type: 'string',
default: '',
description: 'A mention handle. Must be unique among channels, users and User Groups.',
},
{
displayName: 'Include Count',
name: 'include_count',
type: 'boolean',
default: true,
description: 'Whether to include the number of users in each User Group',
},
],
},
/* ----------------------------------------------------------------------- */
/* userGroup:disable */
/* ----------------------------------------------------------------------- */
{
displayName: 'User Group ID',
name: 'userGroupId',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['disable'],
resource: ['userGroup'],
},
},
required: true,
description: 'The encoded ID of the User Group to update',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['userGroup'],
operation: ['disable'],
},
},
options: [
{
displayName: 'Include Count',
name: 'include_count',
type: 'boolean',
default: true,
description: 'Whether to include the number of users in each User Group',
},
],
},
/* ----------------------------------------------------------------------- */
/* userGroup:enable */
/* ----------------------------------------------------------------------- */
{
displayName: 'User Group ID',
name: 'userGroupId',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['enable'],
resource: ['userGroup'],
},
},
required: true,
description: 'The encoded ID of the User Group to update',
},
{
displayName: 'Options',
name: 'option',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['userGroup'],
operation: ['enable'],
},
},
options: [
{
displayName: 'Include Count',
name: 'include_count',
type: 'boolean',
default: true,
description: 'Whether to include the number of users in each User Group',
},
],
},
/* -------------------------------------------------------------------------- */
/* userGroup:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['userGroup'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['userGroup'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 100,
description: 'Max number of results to return',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['userGroup'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Include Count',
name: 'include_count',
type: 'boolean',
default: true,
description: 'Whether to include the number of users in each User Group',
},
{
displayName: 'Include Disabled',
name: 'include_disabled',
type: 'boolean',
default: true,
description: 'Whether to include disabled User Groups',
},
{
displayName: 'Include Users',
name: 'include_users',
type: 'boolean',
default: true,
description: 'Whether to include the list of users for each User Group',
},
],
},
/* ----------------------------------------------------------------------- */
/* userGroup:update */
/* ----------------------------------------------------------------------- */
{
displayName: 'User Group ID',
name: 'userGroupId',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['update'],
resource: ['userGroup'],
},
},
required: true,
description: 'The encoded ID of the User Group to update',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['userGroup'],
operation: ['update'],
},
},
options: [
{
displayName: 'Channel Names or IDs',
name: 'channels',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
default: [],
description:
'A comma-separated string of encoded channel IDs for which the User Group uses as a default. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'A short description of the User Group',
},
{
displayName: 'Handle',
name: 'handle',
type: 'string',
default: '',
description: 'A mention handle. Must be unique among channels, users and User Groups.',
},
{
displayName: 'Include Count',
name: 'include_count',
type: 'boolean',
default: true,
description: 'Whether to include the number of users in each User Group',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'A name for the User Group. Must be unique among User Groups.',
},
],
},
];