|
|
@ -1,4 +1,4 @@ |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { Inject, Injectable } from '@nestjs/common'; |
|
|
|
import { AppEvents } from 'nocodb-sdk'; |
|
|
|
import { AppEvents } from 'nocodb-sdk'; |
|
|
|
import View from '../models/View'; |
|
|
|
import View from '../models/View'; |
|
|
|
import type { HookReqType, HookTestReqType, HookType } from 'nocodb-sdk'; |
|
|
|
import type { HookReqType, HookTestReqType, HookType } from 'nocodb-sdk'; |
|
|
@ -13,12 +13,15 @@ import { |
|
|
|
import { invokeWebhook } from '~/helpers/webhookHelpers'; |
|
|
|
import { invokeWebhook } from '~/helpers/webhookHelpers'; |
|
|
|
import { ButtonColumn, Hook, HookLog, Model } from '~/models'; |
|
|
|
import { ButtonColumn, Hook, HookLog, Model } from '~/models'; |
|
|
|
import { DatasService } from '~/services/datas.service'; |
|
|
|
import { DatasService } from '~/services/datas.service'; |
|
|
|
|
|
|
|
import { JobTypes } from '~/interface/Jobs'; |
|
|
|
|
|
|
|
import { IJobsService } from '~/modules/jobs/jobs-service.interface'; |
|
|
|
|
|
|
|
|
|
|
|
@Injectable() |
|
|
|
@Injectable() |
|
|
|
export class HooksService { |
|
|
|
export class HooksService { |
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
protected readonly appHooksService: AppHooksService, |
|
|
|
protected readonly appHooksService: AppHooksService, |
|
|
|
protected readonly dataService: DatasService, |
|
|
|
protected readonly dataService: DatasService, |
|
|
|
|
|
|
|
@Inject('JobsService') protected readonly jobsService: IJobsService, |
|
|
|
) {} |
|
|
|
) {} |
|
|
|
|
|
|
|
|
|
|
|
validateHookPayload(notificationJsonOrObject: string | Record<string, any>) { |
|
|
|
validateHookPayload(notificationJsonOrObject: string | Record<string, any>) { |
|
|
@ -175,15 +178,13 @@ export class HooksService { |
|
|
|
const model = await Model.get(context, hook.fk_model_id); |
|
|
|
const model = await Model.get(context, hook.fk_model_id); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
await invokeWebhook(context, { |
|
|
|
await this.jobsService.add(JobTypes.HandleWebhook, { |
|
|
|
hook: hook, |
|
|
|
hookId: hook.id, |
|
|
|
model: model, |
|
|
|
modelId: model.id, |
|
|
|
view: null, |
|
|
|
viewId: null, |
|
|
|
prevData: null, |
|
|
|
prevData: null, |
|
|
|
newData: row, |
|
|
|
newData: row, |
|
|
|
user: param.req.user, |
|
|
|
user: param.req.user, |
|
|
|
throwErrorOnFailure: true, |
|
|
|
|
|
|
|
testHook: false, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
throw e; |
|
|
|
throw e; |
|
|
|