Feature/slack node extended (#1239)

* Added reaction method to message

* Increased limit for channels on getChannels, removed unused fields in the code

* Using own operation for reactions

* Registering reaction fields and operations

* Added Operation "Reaction" to Slack.node.ts

* Fixing variable name for emoji

* now removing reaction on "remove" instead of "add"

* Using GET for reactions.get and passing arguments as query

* Added members operation

* Fixed typo in timestamp

* Added user.info and user.getPresence

* Fixed: wrong operation name

*  Improvements to #1238

*  Add field resolve data when retrieving channel members

*  Minor improvements to Slack-Node

Co-authored-by: Andreas Scherren <ascherren@brightfuture.de>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ricardo Espinoza 2020-12-13 04:47:52 -05:00 committed by GitHub
parent 5e56dcb037
commit 532503b69f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 509 additions and 126 deletions

View file

@ -8,13 +8,15 @@ const userScopes = [
'chat:write', 'chat:write',
'files:read', 'files:read',
'files:write', 'files:write',
'groups:read',
'im:read',
'mpim:read',
'reactions:read',
'reactions:write',
'stars:read', 'stars:read',
'stars:write', 'stars:write',
'users.profile:read', 'users.profile:read',
'users.profile:write', 'users.profile:write',
'groups:read',
'im:read',
'mpim:read',
]; ];
export class SlackOAuth2Api implements ICredentialType { export class SlackOAuth2Api implements ICredentialType {

View file

@ -1,4 +1,6 @@
import { INodeProperties } from 'n8n-workflow'; import {
INodeProperties,
} from 'n8n-workflow';
export const channelOperations = [ export const channelOperations = [
{ {
@ -63,6 +65,11 @@ export const channelOperations = [
value: 'leave', value: 'leave',
description: 'Leaves a conversation.', description: 'Leaves a conversation.',
}, },
{
name: 'Member',
value: 'member',
description: 'List members of a conversation.',
},
{ {
name: 'Open', name: 'Open',
value: 'open', value: 'open',
@ -101,9 +108,9 @@ export const channelOperations = [
export const channelFields = [ export const channelFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* channel:archive */ /* channel:archive */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -125,9 +132,10 @@ export const channelFields = [
required: true, required: true,
description: 'The name of the channel to archive.', description: 'The name of the channel to archive.',
}, },
/* -------------------------------------------------------------------------- */
/* channel:close */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:close */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -149,9 +157,10 @@ export const channelFields = [
required: true, required: true,
description: 'The name of the channel to close.', description: 'The name of the channel to close.',
}, },
/* -------------------------------------------------------------------------- */
/* channel:create */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:create */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -197,9 +206,10 @@ export const channelFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* channel:invite */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:invite */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -242,9 +252,10 @@ export const channelFields = [
required: true, required: true,
description: 'The ID of the user to invite into channel.', description: 'The ID of the user to invite into channel.',
}, },
/* -------------------------------------------------------------------------- */
/* channel:get */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:get */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -288,9 +299,10 @@ export const channelFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* channel:kick */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:kick */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -332,9 +344,10 @@ export const channelFields = [
}, },
default: '', default: '',
}, },
/* -------------------------------------------------------------------------- */
/* channel:join */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:join */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -356,9 +369,10 @@ export const channelFields = [
}, },
required: true, required: true,
}, },
/* -------------------------------------------------------------------------- */
/* channel:getAll */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:getAll */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Return All', displayName: 'Return All',
name: 'returnAll', name: 'returnAll',
@ -451,9 +465,10 @@ export const channelFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* channel:history */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:history */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -557,9 +572,10 @@ export const channelFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* channel:leave */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:leave */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -581,9 +597,89 @@ export const channelFields = [
required: true, required: true,
description: 'The name of the channel to leave.', description: 'The name of the channel to leave.',
}, },
/* -------------------------------------------------------------------------- */
/* channel:open */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:member */
/* -------------------------------------------------------------------------- */
{
displayName: 'Channel',
name: 'channelId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
default: '',
displayOptions: {
show: {
operation: [
'member',
],
resource: [
'channel',
],
},
},
required: true,
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: [
'channel',
],
operation: [
'member',
],
},
},
default: false,
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 100,
placeholder: 'Limit',
displayOptions: {
show: {
operation: [
'member',
],
resource: [
'channel',
],
returnAll: [
false,
],
},
},
required: false,
},
{
displayName: 'Resolve Data',
name: 'resolveData',
type: 'boolean',
default: false,
displayOptions: {
show: {
resource: [
'channel',
],
operation: [
'member',
],
},
},
description: 'By default the response only contain the ID to resource. If this<br />option gets activated it will resolve the data automatically.',
},
/* -------------------------------------------------------------------------- */
/* channel:open */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',
@ -627,9 +723,10 @@ export const channelFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* channel:rename */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:rename */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -669,9 +766,10 @@ export const channelFields = [
required: true, required: true,
description: 'New name for conversation.', description: 'New name for conversation.',
}, },
/* -------------------------------------------------------------------------- */
/* channel:replies */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:replies */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -793,9 +891,10 @@ export const channelFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* channel:setPurpose */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:setPurpose */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -835,9 +934,10 @@ export const channelFields = [
required: true, required: true,
description: 'A new, specialer purpose', description: 'A new, specialer purpose',
}, },
/* -------------------------------------------------------------------------- */
/* channel:setTopic */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:setTopic */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',
@ -877,9 +977,10 @@ export const channelFields = [
required: true, required: true,
description: 'The new topic string. Does not support formatting or linkification.', description: 'The new topic string. Does not support formatting or linkification.',
}, },
/* -------------------------------------------------------------------------- */
/* channel:unarchive */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* channel:unarchive */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',

View file

@ -36,9 +36,9 @@ export const fileOperations = [
export const fileFields = [ export const fileFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* file:upload */ /* file:upload */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Binary Data', displayName: 'Binary Data',
name: 'binaryData', name: 'binaryData',
@ -159,9 +159,10 @@ export const fileFields = [
}, },
], ],
}, },
/* ----------------------------------------------------------------------- */
/* file:getAll */ /* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */ /* file:getAll */
/* ----------------------------------------------------------------------- */
{ {
displayName: 'Return All', displayName: 'Return All',
name: 'returnAll', name: 'returnAll',
@ -261,29 +262,29 @@ export const fileFields = [
value: 'all', value: 'all',
}, },
{ {
name: 'Spaces', name: 'Google Docs',
value: 'spaces', value: 'gdocs',
},
{
name: 'Snippets',
value: 'snippets',
}, },
{ {
name: 'Images', name: 'Images',
value: 'images', value: 'images',
}, },
{ {
name: 'Google Docs', name: 'Snippets',
value: 'gdocs', value: 'snippets',
}, },
{ {
name: 'Zips', name: 'Spaces',
value: 'zips', value: 'spaces',
}, },
{ {
name: 'pdfs', name: 'pdfs',
value: 'pdfs', value: 'pdfs',
}, },
{
name: 'Zips',
value: 'zips',
},
], ],
default: ['all'], default: ['all'],
description: 'Filter files by type', description: 'Filter files by type',
@ -300,9 +301,10 @@ export const fileFields = [
}, },
], ],
}, },
/* ----------------------------------------------------------------------- */
/* file:get */ /* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */ /* file:get */
/* ----------------------------------------------------------------------- */
{ {
displayName: 'File ID', displayName: 'File ID',
name: 'fileId', name: 'fileId',

View file

@ -76,7 +76,7 @@ export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFu
} }
} }
export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];
let responseData; let responseData;
query.page = 1; query.page = 1;

View file

@ -31,9 +31,9 @@ export const messageOperations = [
export const messageFields = [ export const messageFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* message:post */ /* message:post */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channel', name: 'channel',
@ -382,6 +382,13 @@ export const messageFields = [
default: '', default: '',
description: 'URL to an image to use as the icon for this message.', description: 'URL to an image to use as the icon for this message.',
}, },
{
displayName: 'Link Names',
name: 'link_names',
type: 'boolean',
default: false,
description: 'Find and link channel names and usernames.',
},
{ {
displayName: 'Make Reply', displayName: 'Make Reply',
name: 'thread_ts', name: 'thread_ts',
@ -389,20 +396,6 @@ export const messageFields = [
default: '', default: '',
description: 'Provide another message\'s ts value to make this message a reply.', description: 'Provide another message\'s ts value to make this message a reply.',
}, },
{
displayName: 'Unfurl Links',
name: 'unfurl_links',
type: 'boolean',
default: false,
description: 'Pass true to enable unfurling of primarily text-based content.',
},
{
displayName: 'Unfurl Media',
name: 'unfurl_media',
type: 'boolean',
default: true,
description: 'Pass false to disable unfurling of media content.',
},
{ {
displayName: 'Markdown', displayName: 'Markdown',
name: 'mrkdwn', name: 'mrkdwn',
@ -418,17 +411,25 @@ export const messageFields = [
description: 'Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation.', description: 'Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation.',
}, },
{ {
displayName: 'Link Names', displayName: 'Unfurl Links',
name: 'link_names', name: 'unfurl_links',
type: 'boolean', type: 'boolean',
default: false, default: false,
description: 'Find and link channel names and usernames.', description: 'Pass true to enable unfurling of primarily text-based content.',
},
{
displayName: 'Unfurl Media',
name: 'unfurl_media',
type: 'boolean',
default: true,
description: 'Pass false to disable unfurling of media content.',
}, },
], ],
}, },
/* ----------------------------------------------------------------------- */
/* message:update */ /* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */ /* message:update */
/* ----------------------------------------------------------------------- */
{ {
displayName: 'Channel', displayName: 'Channel',
name: 'channelId', name: 'channelId',

View file

@ -4,4 +4,3 @@ export interface IAttachment {
item?: object[]; item?: object[];
}; };
} }

View file

@ -0,0 +1,101 @@
import { INodeProperties } from 'n8n-workflow';
export const reactionOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'reaction',
],
},
},
options: [
{
name: 'Add',
value: 'add',
description: 'Adds a reaction to a message',
},
{
name: 'Get',
value: 'get',
description: 'Get the reactions of a message',
},
{
name: 'Remove',
value: 'remove',
description: 'Remove a reaction of a message',
},
],
default: 'add',
description: 'The operation to perform.',
},
] as INodeProperties[];
export const reactionFields = [
{
displayName: 'Channel',
name: 'channelId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getChannels',
},
required: true,
default: '',
displayOptions: {
show: {
resource: [
'reaction',
],
operation: [
'add',
'get',
'remove',
],
},
},
description: 'Channel containing the message.',
},
{
displayName: 'Emoji',
name: 'name',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'reaction',
],
operation: [
'add',
'remove',
],
},
},
description: 'Name of emoji.',
placeholder: '+1',
},
{
displayName: 'Timestamp',
name: 'timestamp',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'reaction',
],
operation: [
'add',
'get',
'remove',
],
},
},
description: `Timestamp of the message.`,
},
] as INodeProperties[];

View file

@ -32,6 +32,16 @@ import {
fileOperations, fileOperations,
} from './FileDescription'; } from './FileDescription';
import {
reactionFields,
reactionOperations,
} from './ReactionDescription';
import {
userFields,
userOperations,
} from './UserDescription';
import { import {
userProfileFields, userProfileFields,
userProfileOperations, userProfileOperations,
@ -46,6 +56,7 @@ import {
import { import {
IAttachment, IAttachment,
} from './MessageInterface'; } from './MessageInterface';
import moment = require('moment'); import moment = require('moment');
interface Attachment { interface Attachment {
@ -163,10 +174,18 @@ export class Slack implements INodeType {
name: 'Message', name: 'Message',
value: 'message', value: 'message',
}, },
{
name: 'Reaction',
value: 'reaction',
},
{ {
name: 'Star', name: 'Star',
value: 'star', value: 'star',
}, },
{
name: 'User',
value: 'user',
},
{ {
name: 'User Profile', name: 'User Profile',
value: 'userProfile', value: 'userProfile',
@ -184,6 +203,10 @@ export class Slack implements INodeType {
...starFields, ...starFields,
...fileOperations, ...fileOperations,
...fileFields, ...fileFields,
...reactionOperations,
...reactionFields,
...userOperations,
...userFields,
...userProfileOperations, ...userProfileOperations,
...userProfileFields, ...userProfileFields,
], ],
@ -217,7 +240,7 @@ export class Slack implements INodeType {
// select them easily // select them easily
async getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> { async getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = []; const returnData: INodePropertyOptions[] = [];
const qs = { types: 'public_channel,private_channel' }; const qs = { types: 'public_channel,private_channel', limit: 1000 };
const channels = await slackApiRequestAllItems.call(this, 'channels', 'GET', '/conversations.list', {}, qs); const channels = await slackApiRequestAllItems.call(this, 'channels', 'GET', '/conversations.list', {}, qs);
for (const channel of channels) { for (const channel of channels) {
const channelName = channel.name; const channelName = channel.name;
@ -265,7 +288,7 @@ export class Slack implements INodeType {
const operation = this.getNodeParameter('operation', 0) as string; const operation = this.getNodeParameter('operation', 0) as string;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
responseData = { error: 'Resource ' + resource + ' / operation ' + operation + ' not found!'}; responseData = { error: 'Resource ' + resource + ' / operation ' + operation + ' not found!' };
qs = {}; qs = {};
if (resource === 'channel') { if (resource === 'channel') {
//https://api.slack.com/methods/conversations.archive //https://api.slack.com/methods/conversations.archive
@ -383,6 +406,29 @@ export class Slack implements INodeType {
}; };
responseData = await slackApiRequest.call(this, 'POST', '/conversations.leave', body, qs); responseData = await slackApiRequest.call(this, 'POST', '/conversations.leave', body, qs);
} }
//https://api.slack.com/methods/conversations.members
if (operation === 'member') {
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const resolveData = this.getNodeParameter('resolveData', 0) as boolean;
qs.channel = this.getNodeParameter('channelId', i) as string;
if (returnAll) {
responseData = await slackApiRequestAllItems.call(this, 'members', 'GET', '/conversations.members', {}, qs);
responseData = responseData.map((member: string) => ({ member }));
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await slackApiRequest.call(this, 'GET', '/conversations.members', {}, qs);
responseData = responseData.members.map((member: string) => ({ member }));
}
if (resolveData) {
const data: IDataObject[] = [];
for (const { member } of responseData) {
const { user } = await slackApiRequest.call(this, 'GET', '/users.info', {}, { user: member });
data.push(user);
}
responseData = data;
}
}
//https://api.slack.com/methods/conversations.open //https://api.slack.com/methods/conversations.open
if (operation === 'open') { if (operation === 'open') {
const options = this.getNodeParameter('options', i) as IDataObject; const options = this.getNodeParameter('options', i) as IDataObject;
@ -745,6 +791,36 @@ export class Slack implements INodeType {
responseData = await slackApiRequest.call(this, 'POST', '/chat.update', body, qs); responseData = await slackApiRequest.call(this, 'POST', '/chat.update', body, qs);
} }
} }
if (resource === 'reaction') {
const channel = this.getNodeParameter('channelId', i) as string;
const timestamp = this.getNodeParameter('timestamp', i) as string;
//https://api.slack.com/methods/reactions.add
if (operation === 'add') {
const name = this.getNodeParameter('name', i) as string;
const body: IDataObject = {
channel,
name,
timestamp,
};
responseData = await slackApiRequest.call(this, 'POST', '/reactions.add', body, qs);
}
//https://api.slack.com/methods/reactions.remove
if (operation === 'remove') {
const name = this.getNodeParameter('name', i) as string;
const body: IDataObject = {
channel,
name,
timestamp,
};
responseData = await slackApiRequest.call(this, 'POST', '/reactions.remove', body, qs);
}
//https://api.slack.com/methods/reactions.get
if (operation === 'get') {
qs.channel = channel;
qs.timestamp = timestamp;
responseData = await slackApiRequest.call(this, 'GET', '/reactions.get', {}, qs);
}
}
if (resource === 'star') { if (resource === 'star') {
//https://api.slack.com/methods/stars.add //https://api.slack.com/methods/stars.add
if (operation === 'add') { if (operation === 'add') {
@ -879,6 +955,19 @@ export class Slack implements INodeType {
responseData = responseData.file; responseData = responseData.file;
} }
} }
if (resource === 'user') {
//https://api.slack.com/methods/users.info
if (operation === 'info') {
qs.user = this.getNodeParameter('user', i) as string;
responseData = await slackApiRequest.call(this, 'GET', '/users.info', {}, qs);
responseData = responseData.user;
}
//https://api.slack.com/methods/users.getPresence
if (operation === 'getPresence') {
qs.user = this.getNodeParameter('user', i) as string;
responseData = await slackApiRequest.call(this, 'GET', '/users.getPresence', {}, qs);
}
}
if (resource === 'userProfile') { if (resource === 'userProfile') {
//https://api.slack.com/methods/users.profile.set //https://api.slack.com/methods/users.profile.set
if (operation === 'update') { if (operation === 'update') {

View file

@ -36,9 +36,9 @@ export const starOperations = [
export const starFields = [ export const starFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* star:add */ /* star:add */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',
@ -67,13 +67,6 @@ export const starFields = [
default: '', default: '',
description: 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp).', description: 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp).',
}, },
{
displayName: 'File ID',
name: 'fileId',
type: 'string',
default: '',
description: 'File to add star to.',
},
{ {
displayName: 'File Comment', displayName: 'File Comment',
name: 'fileComment', name: 'fileComment',
@ -81,6 +74,13 @@ export const starFields = [
default: '', default: '',
description: 'File comment to add star to.', description: 'File comment to add star to.',
}, },
{
displayName: 'File ID',
name: 'fileId',
type: 'string',
default: '',
description: 'File to add star to.',
},
{ {
displayName: 'Timestamp', displayName: 'Timestamp',
name: 'timestamp', name: 'timestamp',
@ -90,9 +90,10 @@ export const starFields = [
}, },
], ],
}, },
/* ----------------------------------------------------------------------- */
/* star:delete */ /* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */ /* star:delete */
/* ----------------------------------------------------------------------- */
{ {
displayName: 'Options', displayName: 'Options',
name: 'options', name: 'options',
@ -144,9 +145,10 @@ export const starFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* star:getAll */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* star:getAll */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Return All', displayName: 'Return All',
name: 'returnAll', name: 'returnAll',

View file

@ -0,0 +1,85 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const userOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'user',
],
},
},
options: [
{
name: 'Info',
value: 'info',
description: `Get information about a user`,
},
{
name: 'Get Presence',
value: 'getPresence',
description: `Get online status of a user`,
},
],
default: 'info',
description: 'The operation to perform.',
},
] as INodeProperties[];
export const userFields = [
/* -------------------------------------------------------------------------- */
/* user:info */
/* -------------------------------------------------------------------------- */
{
displayName: 'User ID',
name: 'user',
type: 'string',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
default: '',
displayOptions: {
show: {
operation: [
'info',
],
resource: [
'user',
],
},
},
required: true,
description: 'The ID of the user to get information about.',
},
/* -------------------------------------------------------------------------- */
/* user:getPresence */
/* -------------------------------------------------------------------------- */
{
displayName: 'User ID',
name: 'user',
type: 'string',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
default: '',
displayOptions: {
show: {
operation: [
'getPresence',
],
resource: [
'user',
],
},
},
required: true,
description: 'The ID of the user to get the online status of.',
},
] as INodeProperties[];

View file

@ -34,9 +34,9 @@ export const userProfileOperations = [
export const userProfileFields = [ export const userProfileFields = [
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* userProfile:update */ /* userProfile:update */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
{ {
displayName: 'Additional Fields', displayName: 'Additional Fields',
name: 'additionalFields', name: 'additionalFields',
@ -144,9 +144,10 @@ export const userProfileFields = [
}, },
], ],
}, },
/* -------------------------------------------------------------------------- */
/* userProfile:get */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* userProfile:get */
/* -------------------------------------------------------------------------- */
{ {
displayName: 'Additional Fields', displayName: 'Additional Fields',
name: 'additionalFields', name: 'additionalFields',