mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
Merge branch 'master' of https://github.com/n8n-io/n8n
This commit is contained in:
commit
aae7203b0a
|
@ -149,6 +149,9 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
|
|||
};
|
||||
}
|
||||
|
||||
// Save static data if it changed
|
||||
await WorkflowHelpers.saveStaticData(workflow);
|
||||
|
||||
if (webhookData.webhookDescription['responseHeaders'] !== undefined) {
|
||||
const responseHeaders = workflow.getComplexParameterValue(workflowStartNode, webhookData.webhookDescription['responseHeaders'], undefined) as {
|
||||
entries?: Array<{
|
||||
|
|
|
@ -6,15 +6,12 @@ import {
|
|||
//https://api.slack.com/authentication/oauth-v2
|
||||
const userScopes = [
|
||||
'chat:write',
|
||||
'conversations:history',
|
||||
'conversations:read',
|
||||
'files:read',
|
||||
'files:write',
|
||||
'stars:read',
|
||||
'stars:write',
|
||||
];
|
||||
|
||||
|
||||
export class SlackOAuth2Api implements ICredentialType {
|
||||
name = 'slackOAuth2Api';
|
||||
extends = [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
|
@ -16,7 +17,7 @@ import {
|
|||
* @param {object} body
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('gitlabApi');
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
|
@ -34,7 +35,9 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
|
|||
};
|
||||
|
||||
try {
|
||||
return await this.helpers.request(options);
|
||||
//@ts-ignore
|
||||
return await this.helpers?.request(options);
|
||||
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
|
|
|
@ -135,7 +135,10 @@ export class GitlabTrigger implements INodeType {
|
|||
// Webhook got created before so check if it still exists
|
||||
const owner = this.getNodeParameter('owner') as string;
|
||||
const repository = this.getNodeParameter('repository') as string;
|
||||
const endpoint = `/projects/${owner}%2F${repository}/hooks/${webhookData.webhookId}`;
|
||||
|
||||
const path = (`${owner}/${repository}`).replace(/\//g,'%2F');
|
||||
|
||||
const endpoint = `/projects/${path}/hooks/${webhookData.webhookId}`;
|
||||
|
||||
try {
|
||||
await gitlabApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
@ -175,15 +178,22 @@ export class GitlabTrigger implements INodeType {
|
|||
events[`${e}_events`] = true;
|
||||
}
|
||||
|
||||
const endpoint = `/projects/${owner}%2F${repository}/hooks`;
|
||||
// gitlab set the push_events to true when the field it's not sent.
|
||||
// set it to false when it's not picked by the user.
|
||||
if (events['push_events'] === undefined) {
|
||||
events['push_events'] = false;
|
||||
}
|
||||
|
||||
const path = (`${owner}/${repository}`).replace(/\//g,'%2F');
|
||||
|
||||
const endpoint = `/projects/${path}/hooks`;
|
||||
|
||||
const body = {
|
||||
url: webhookUrl,
|
||||
events,
|
||||
...events,
|
||||
enable_ssl_verification: false,
|
||||
};
|
||||
|
||||
|
||||
let responseData;
|
||||
try {
|
||||
responseData = await gitlabApiRequest.call(this, 'POST', endpoint, body);
|
||||
|
@ -208,7 +218,10 @@ export class GitlabTrigger implements INodeType {
|
|||
if (webhookData.webhookId !== undefined) {
|
||||
const owner = this.getNodeParameter('owner') as string;
|
||||
const repository = this.getNodeParameter('repository') as string;
|
||||
const endpoint = `/projects/${owner}%2F${repository}/hooks/${webhookData.webhookId}`;
|
||||
|
||||
const path = (`${owner}/${repository}`).replace(/\//g,'%2F');
|
||||
|
||||
const endpoint = `/projects/${path}/hooks/${webhookData.webhookId}`;
|
||||
const body = {};
|
||||
|
||||
try {
|
||||
|
|
|
@ -177,6 +177,15 @@ export const eventFields = [
|
|||
default: '',
|
||||
description: 'The color of the event.',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Guests Can Invite Others',
|
||||
name: 'guestsCanInviteOthers',
|
||||
|
@ -858,6 +867,15 @@ export const eventFields = [
|
|||
default: '',
|
||||
description: 'The color of the event.',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'End',
|
||||
name: 'end',
|
||||
|
|
|
@ -33,9 +33,15 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
|||
//@ts-ignore
|
||||
return await this.helpers.requestOAuth2.call(this, 'googleCalendarOAuth2Api', options);
|
||||
} catch (error) {
|
||||
if (error.response && error.response.body && error.response.body.message) {
|
||||
if (error.response && error.response.body && error.response.body.error) {
|
||||
|
||||
let errors = error.response.body.error.errors;
|
||||
|
||||
errors = errors.map((e: IDataObject) => e.message);
|
||||
// Try to return the error prettier
|
||||
throw new Error(`Google Calendar error response [${error.statusCode}]: ${error.response.body.message}`);
|
||||
throw new Error(
|
||||
`Google Calendar error response [${error.statusCode}]: ${errors.join('|')}`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
|
|
@ -97,16 +97,16 @@ export class GoogleCalendar implements INodeType {
|
|||
this: ILoadOptionsFunctions
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { calendar } = await googleApiRequest.call(
|
||||
const { event } = await googleApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/calendar/v3/colors'
|
||||
);
|
||||
for (const key of Object.keys(calendar)) {
|
||||
const colorName = calendar[key].background;
|
||||
for (const key of Object.keys(event)) {
|
||||
const colorName = `Background: ${event[key].background} - Foreground: ${event[key].foreground}`;
|
||||
const colorId = key;
|
||||
returnData.push({
|
||||
name: `${colorName} - ${colorId}`,
|
||||
name: `${colorName}`,
|
||||
value: colorId
|
||||
});
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ export const messageFields = [
|
|||
],
|
||||
},
|
||||
},
|
||||
description: 'Set the bot\'s user name.',
|
||||
description: 'Set the bot\'s user name. This field will be ignored if you are using a user token.',
|
||||
},
|
||||
{
|
||||
displayName: 'JSON parameters',
|
||||
|
@ -486,26 +486,6 @@ export const messageFields = [
|
|||
},
|
||||
description: `Timestamp of the message to be updated.`,
|
||||
},
|
||||
{
|
||||
displayName: 'As User',
|
||||
name: 'as_user',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
operation: [
|
||||
'update'
|
||||
],
|
||||
resource: [
|
||||
'message',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Pass true to update the message as the authed user. Bot users in this context are considered authed users.',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
|
|
|
@ -454,6 +454,10 @@ export class Slack implements INodeType {
|
|||
body.username = this.getNodeParameter('username', i) as string;
|
||||
}
|
||||
|
||||
// ignore body.as_user as it's deprecated
|
||||
|
||||
delete body.as_user;
|
||||
|
||||
if (!jsonParameters) {
|
||||
const attachments = this.getNodeParameter('attachments', i, []) as unknown as Attachment[];
|
||||
const blocksUi = (this.getNodeParameter('blocksUi', i, []) as IDataObject).blocksValues as IDataObject[];
|
||||
|
@ -691,10 +695,6 @@ export class Slack implements INodeType {
|
|||
ts,
|
||||
};
|
||||
|
||||
if (authentication === 'accessToken') {
|
||||
body.as_user = this.getNodeParameter('as_user', i) as boolean;
|
||||
}
|
||||
|
||||
// The node does save the fields data differently than the API
|
||||
// expects so fix the data befre we send the request
|
||||
for (const attachment of attachments) {
|
||||
|
|
Loading…
Reference in a new issue