|
|
@ -49,7 +49,15 @@ class BaseModel<T extends BaseApiBuilder<any>> extends BaseModelSql { |
|
|
|
public async beforeUpdate(data: any, _trx: any, req): Promise<void> { |
|
|
|
public async beforeUpdate(data: any, _trx: any, req): Promise<void> { |
|
|
|
req = req || {}; |
|
|
|
req = req || {}; |
|
|
|
req['oldData'] = await this.readByPk(req['params'].id); |
|
|
|
req['oldData'] = await this.readByPk(req['params'].id); |
|
|
|
if(req.query?.ignoreWebhook === undefined || req.query?.ignoreWebhook == 'false') await this.handleHooks('before.update', data, req); |
|
|
|
const ignoreWebhook = req.query?.ignoreWebhook; |
|
|
|
|
|
|
|
if (ignoreWebhook) { |
|
|
|
|
|
|
|
if (ignoreWebhook != 'true' && ignoreWebhook != 'false') { |
|
|
|
|
|
|
|
throw new Error('ignoreWebhook value can be either true or false'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (ignoreWebhook === undefined || ignoreWebhook === 'false') { |
|
|
|
|
|
|
|
await this.handleHooks('before.update', data, req); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async afterUpdate(data: any, _trx: any, req): Promise<void> { |
|
|
|
public async afterUpdate(data: any, _trx: any, req): Promise<void> { |
|
|
@ -74,7 +82,15 @@ class BaseModel<T extends BaseApiBuilder<any>> extends BaseModelSql { |
|
|
|
user: req.user?.email |
|
|
|
user: req.user?.email |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
if(req.query?.ignoreWebhook === undefined || req.query?.ignoreWebhook == 'false') await this.handleHooks('after.update', data, req); |
|
|
|
const ignoreWebhook = req.query?.ignoreWebhook; |
|
|
|
|
|
|
|
if (ignoreWebhook) { |
|
|
|
|
|
|
|
if (ignoreWebhook != 'true' && ignoreWebhook != 'false') { |
|
|
|
|
|
|
|
throw new Error('ignoreWebhook value can be either true or false'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (ignoreWebhook === undefined || ignoreWebhook === 'false') { |
|
|
|
|
|
|
|
await this.handleHooks('after.update', data, req); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private _updateAuditDescription(id, oldData: any, data: any) { |
|
|
|
private _updateAuditDescription(id, oldData: any, data: any) { |
|
|
|