diff --git a/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts index 48508f503e..590453308c 100644 --- a/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts @@ -79,6 +79,16 @@ export async function slackApiRequest( level: 'warning', }, ); + } else if (response.error === 'not_admin') { + throw new NodeOperationError( + this.getNode(), + 'Need higher Role Level for this Operation (e.g. Owner or Admin Rights)', + { + description: + 'Hint: Check the Role of your Slack App Integration. For more information see the Slack Documentation - https://slack.com/help/articles/360018112273-Types-of-roles-in-Slack', + level: 'warning', + }, + ); } throw new NodeOperationError( @@ -86,6 +96,7 @@ export async function slackApiRequest( 'Slack error response: ' + JSON.stringify(response.error), ); } + if (response.ts !== undefined) { Object.assign(response, { message_timestamp: response.ts }); delete response.ts; diff --git a/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts b/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts index ed62328331..3ba8cca7b8 100644 --- a/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts +++ b/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts @@ -1299,18 +1299,29 @@ export class SlackV2 implements INodeType { options.fields = fields; } + Object.assign(body, options); + let requestBody: IDataObject = { profile: body }; + + let userId; + if (options.user) { + userId = options.user; + delete body.user; + requestBody = { profile: body, user: userId }; + } + responseData = await slackApiRequest.call( this, 'POST', '/users.profile.set', - { profile: body }, + requestBody, qs, ); responseData = responseData.profile; } } + if (resource === 'userGroup') { //https://api.slack.com/methods/usergroups.create if (operation === 'create') {