mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Slack Node): Add blocks to slack message update (#2182)
* Adding blocks to slack message update * Fixing lint * Adding blocks to slack message update * Fixing lint * ⚡ added toggle to display json inputs in update operation * ⚡ Improvements * feat(Markdown Node): Add new node to covert between Markdown <> HTML (#1728) * ✨ Markdown Node * Tweaked wording * ⬆️ Bump showdown to latest version * ⚡ Small improvement * 👕 Fix linting issue * ⚡ Small improvements * 🔨 added options, added continue on fail, some clean up * ⚡ removed test code * ⚡ added missing semicolumn * 🔨 wip * 🔨 replaced library for converting html to markdown, added options * ⚡ lock file fix * 🔨 clean up Co-authored-by: sirdavidoff <1670123+sirdavidoff@users.noreply.github.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Ricardo Espinoza <ricardo@n8n.io> Co-authored-by: sirdavidoff <1670123+sirdavidoff@users.noreply.github.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import {
|
||||
IDataObject,
|
||||
IOAuth2Options,
|
||||
JsonObject,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
@@ -36,23 +37,16 @@ export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFu
|
||||
if (Object.keys(query).length === 0) {
|
||||
delete options.qs;
|
||||
}
|
||||
|
||||
const oAuth2Options: IOAuth2Options = {
|
||||
tokenType: 'Bearer',
|
||||
property: 'authed_user.access_token',
|
||||
};
|
||||
|
||||
try {
|
||||
let response: any; // tslint:disable-line:no-any
|
||||
|
||||
if (authenticationMethod === 'accessToken') {
|
||||
const credentials = await this.getCredentials('slackApi');
|
||||
options.headers!.Authorization = `Bearer ${credentials.accessToken}`;
|
||||
//@ts-ignore
|
||||
response = await this.helpers.request(options);
|
||||
} else {
|
||||
|
||||
const oAuth2Options: IOAuth2Options = {
|
||||
tokenType: 'Bearer',
|
||||
property: 'authed_user.access_token',
|
||||
};
|
||||
//@ts-ignore
|
||||
response = await this.helpers.requestOAuth2.call(this, 'slackOAuth2Api', options, oAuth2Options);
|
||||
}
|
||||
const credentialType = authenticationMethod === 'accessToken' ? 'slackApi' : 'slackOAuth2Api';
|
||||
response = await this.helpers.requestWithAuthentication.call(this, credentialType, options, { oauth2: oAuth2Options });
|
||||
|
||||
if (response.ok === false) {
|
||||
if (response.error === 'paid_teams_only') {
|
||||
@@ -66,7 +60,7 @@ export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFu
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user