Add first basic code for external hooks

This commit is contained in:
Jan Oberhauser
2020-05-04 08:56:01 +02:00
parent 582ff76799
commit a380a9a394
7 changed files with 126 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ import {
ActiveWorkflowRunner,
CredentialTypes,
Db,
ExternalHooks,
IActivationError,
ICustomRequest,
ICredentialsDb,
@@ -33,6 +34,7 @@ import {
IExecutionsListResponse,
IExecutionsStopData,
IExecutionsSummary,
IExternalHooks,
IN8nUISettings,
IPackageVersions,
IWorkflowBase,
@@ -93,6 +95,7 @@ class App {
testWebhooks: TestWebhooks.TestWebhooks;
endpointWebhook: string;
endpointWebhookTest: string;
externalHooks: IExternalHooks;
saveDataErrorExecution: string;
saveDataSuccessExecution: string;
saveManualExecutions: boolean;
@@ -124,6 +127,8 @@ class App {
this.protocol = config.get('protocol');
this.sslKey = config.get('ssl_key');
this.sslCert = config.get('ssl_cert');
this.externalHooks = ExternalHooks();
}
@@ -689,6 +694,8 @@ class App {
throw new ResponseHelper.ResponseError(`Credentials with the same type and name exist already.`, undefined, 400);
}
await this.externalHooks.run('credentials.new');
// Encrypt the data
const credentials = new Credentials(incomingData.name, incomingData.type, incomingData.nodesAccess);
credentials.setData(incomingData.data, encryptionKey);