chore: Add transaction to integrations.update

This commit is contained in:
Tom Moor
2024-07-27 15:41:55 -04:00
parent 6e6a5014af
commit 93a89eeef3
@@ -115,11 +115,16 @@ router.post(
"integrations.update",
auth({ role: UserRole.Admin }),
validate(T.IntegrationsUpdateSchema),
transaction(),
async (ctx: APIContext<T.IntegrationsUpdateReq>) => {
const { id, events, settings } = ctx.input.body;
const { user } = ctx.state.auth;
const { transaction } = ctx.state;
const integration = await Integration.findByPk(id);
const integration = await Integration.findByPk(id, {
transaction,
lock: transaction.LOCK.UPDATE,
});
authorize(user, "update", integration);
if (integration.type === IntegrationType.Post) {
@@ -130,7 +135,7 @@ router.post(
integration.settings = settings;
await integration.save();
await integration.save({ transaction });
ctx.body = {
data: presentIntegration(integration),
@@ -152,6 +157,7 @@ router.post(
const integration = await Integration.findByPk(id, {
rejectOnEmpty: true,
transaction,
lock: transaction.LOCK.UPDATE,
});
authorize(user, "delete", integration);