Update project-bot-service.ts

This commit is contained in:
Daniel Hougaard
2024-02-22 05:00:25 +01:00
parent 37645ba126
commit 45327f10b1
@@ -1,5 +1,4 @@
import { ForbiddenError } from "@casl/ability"; import { ForbiddenError } from "@casl/ability";
import { Knex } from "knex";
import { SecretKeyEncoding } from "@app/db/schemas"; import { SecretKeyEncoding } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service"; import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
@@ -106,16 +105,12 @@ export const projectBotServiceFactory = ({ projectBotDAL, permissionService }: T
if (!botKey?.nonce || !botKey?.encryptedKey) { if (!botKey?.nonce || !botKey?.encryptedKey) {
throw new BadRequestError({ message: "Failed to set bot active - missing bot key" }); throw new BadRequestError({ message: "Failed to set bot active - missing bot key" });
} }
const doc = await projectBotDAL.updateById( const doc = await projectBotDAL.updateById(botId, {
botId,
{
isActive: true, isActive: true,
encryptedProjectKey: botKey.encryptedKey, encryptedProjectKey: botKey.encryptedKey,
encryptedProjectKeyNonce: botKey.nonce, encryptedProjectKeyNonce: botKey.nonce,
senderId: actorId senderId: actorId
}, });
tx
);
if (!doc) throw new BadRequestError({ message: "Failed to update bot active state" }); if (!doc) throw new BadRequestError({ message: "Failed to update bot active state" });
return doc; return doc;
} }