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) {
|
if (webhookData.webhookDescription['responseHeaders'] !== undefined) {
|
||||||
const responseHeaders = workflow.getComplexParameterValue(workflowStartNode, webhookData.webhookDescription['responseHeaders'], undefined) as {
|
const responseHeaders = workflow.getComplexParameterValue(workflowStartNode, webhookData.webhookDescription['responseHeaders'], undefined) as {
|
||||||
entries?: Array<{
|
entries?: Array<{
|
||||||
|
|
|
@ -6,15 +6,12 @@ import {
|
||||||
//https://api.slack.com/authentication/oauth-v2
|
//https://api.slack.com/authentication/oauth-v2
|
||||||
const userScopes = [
|
const userScopes = [
|
||||||
'chat:write',
|
'chat:write',
|
||||||
'conversations:history',
|
|
||||||
'conversations:read',
|
|
||||||
'files:read',
|
'files:read',
|
||||||
'files:write',
|
'files:write',
|
||||||
'stars:read',
|
'stars:read',
|
||||||
'stars:write',
|
'stars:write',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
export class SlackOAuth2Api implements ICredentialType {
|
export class SlackOAuth2Api implements ICredentialType {
|
||||||
name = 'slackOAuth2Api';
|
name = 'slackOAuth2Api';
|
||||||
extends = [
|
extends = [
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
IHookFunctions,
|
IHookFunctions,
|
||||||
|
ILoadOptionsFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -16,7 +17,7 @@ import {
|
||||||
* @param {object} body
|
* @param {object} body
|
||||||
* @returns {Promise<any>}
|
* @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');
|
const credentials = this.getCredentials('gitlabApi');
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new Error('No credentials got returned!');
|
throw new Error('No credentials got returned!');
|
||||||
|
@ -34,7 +35,9 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request(options);
|
//@ts-ignore
|
||||||
|
return await this.helpers?.request(options);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.statusCode === 401) {
|
if (error.statusCode === 401) {
|
||||||
// Return a clear error
|
// Return a clear error
|
||||||
|
|
|
@ -135,7 +135,10 @@ export class GitlabTrigger implements INodeType {
|
||||||
// Webhook got created before so check if it still exists
|
// Webhook got created before so check if it still exists
|
||||||
const owner = this.getNodeParameter('owner') as string;
|
const owner = this.getNodeParameter('owner') as string;
|
||||||
const repository = this.getNodeParameter('repository') 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 {
|
try {
|
||||||
await gitlabApiRequest.call(this, 'GET', endpoint, {});
|
await gitlabApiRequest.call(this, 'GET', endpoint, {});
|
||||||
|
@ -175,15 +178,22 @@ export class GitlabTrigger implements INodeType {
|
||||||
events[`${e}_events`] = true;
|
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 = {
|
const body = {
|
||||||
url: webhookUrl,
|
url: webhookUrl,
|
||||||
events,
|
...events,
|
||||||
enable_ssl_verification: false,
|
enable_ssl_verification: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let responseData;
|
let responseData;
|
||||||
try {
|
try {
|
||||||
responseData = await gitlabApiRequest.call(this, 'POST', endpoint, body);
|
responseData = await gitlabApiRequest.call(this, 'POST', endpoint, body);
|
||||||
|
@ -208,7 +218,10 @@ export class GitlabTrigger implements INodeType {
|
||||||
if (webhookData.webhookId !== undefined) {
|
if (webhookData.webhookId !== undefined) {
|
||||||
const owner = this.getNodeParameter('owner') as string;
|
const owner = this.getNodeParameter('owner') as string;
|
||||||
const repository = this.getNodeParameter('repository') 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 = {};
|
const body = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -177,6 +177,15 @@ export const eventFields = [
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The color of the event.',
|
description: 'The color of the event.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Description',
|
||||||
|
name: 'description',
|
||||||
|
type: 'string',
|
||||||
|
typeOptions: {
|
||||||
|
alwaysOpenEditWindow: true,
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Guests Can Invite Others',
|
displayName: 'Guests Can Invite Others',
|
||||||
name: 'guestsCanInviteOthers',
|
name: 'guestsCanInviteOthers',
|
||||||
|
@ -858,6 +867,15 @@ export const eventFields = [
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The color of the event.',
|
description: 'The color of the event.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Description',
|
||||||
|
name: 'description',
|
||||||
|
type: 'string',
|
||||||
|
typeOptions: {
|
||||||
|
alwaysOpenEditWindow: true,
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'End',
|
displayName: 'End',
|
||||||
name: 'end',
|
name: 'end',
|
||||||
|
|
|
@ -33,9 +33,15 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return await this.helpers.requestOAuth2.call(this, 'googleCalendarOAuth2Api', options);
|
return await this.helpers.requestOAuth2.call(this, 'googleCalendarOAuth2Api', options);
|
||||||
} catch (error) {
|
} 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
|
// 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;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,16 +97,16 @@ export class GoogleCalendar implements INodeType {
|
||||||
this: ILoadOptionsFunctions
|
this: ILoadOptionsFunctions
|
||||||
): Promise<INodePropertyOptions[]> {
|
): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
const { calendar } = await googleApiRequest.call(
|
const { event } = await googleApiRequest.call(
|
||||||
this,
|
this,
|
||||||
'GET',
|
'GET',
|
||||||
'/calendar/v3/colors'
|
'/calendar/v3/colors'
|
||||||
);
|
);
|
||||||
for (const key of Object.keys(calendar)) {
|
for (const key of Object.keys(event)) {
|
||||||
const colorName = calendar[key].background;
|
const colorName = `Background: ${event[key].background} - Foreground: ${event[key].foreground}`;
|
||||||
const colorId = key;
|
const colorId = key;
|
||||||
returnData.push({
|
returnData.push({
|
||||||
name: `${colorName} - ${colorId}`,
|
name: `${colorName}`,
|
||||||
value: colorId
|
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',
|
displayName: 'JSON parameters',
|
||||||
|
@ -486,26 +486,6 @@ export const messageFields = [
|
||||||
},
|
},
|
||||||
description: `Timestamp of the message to be updated.`,
|
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',
|
displayName: 'Update Fields',
|
||||||
name: 'updateFields',
|
name: 'updateFields',
|
||||||
|
|
|
@ -454,6 +454,10 @@ export class Slack implements INodeType {
|
||||||
body.username = this.getNodeParameter('username', i) as string;
|
body.username = this.getNodeParameter('username', i) as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore body.as_user as it's deprecated
|
||||||
|
|
||||||
|
delete body.as_user;
|
||||||
|
|
||||||
if (!jsonParameters) {
|
if (!jsonParameters) {
|
||||||
const attachments = this.getNodeParameter('attachments', i, []) as unknown as Attachment[];
|
const attachments = this.getNodeParameter('attachments', i, []) as unknown as Attachment[];
|
||||||
const blocksUi = (this.getNodeParameter('blocksUi', i, []) as IDataObject).blocksValues as IDataObject[];
|
const blocksUi = (this.getNodeParameter('blocksUi', i, []) as IDataObject).blocksValues as IDataObject[];
|
||||||
|
@ -691,10 +695,6 @@ export class Slack implements INodeType {
|
||||||
ts,
|
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
|
// The node does save the fields data differently than the API
|
||||||
// expects so fix the data befre we send the request
|
// expects so fix the data befre we send the request
|
||||||
for (const attachment of attachments) {
|
for (const attachment of attachments) {
|
||||||
|
|
Loading…
Reference in a new issue