From e9d8da460aa13e47d3393133c40c9046bdeac07b Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 31 Mar 2025 09:51:59 +0400 Subject: [PATCH] Add exception to rules for ai bot in identity (#8397) Signed-off-by: Kristina Fefelova --- server/middleware/package.json | 1 + server/middleware/src/identity.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/middleware/package.json b/server/middleware/package.json index 748417a56d..92054c9a27 100644 --- a/server/middleware/package.json +++ b/server/middleware/package.json @@ -37,6 +37,7 @@ "@types/jest": "^29.5.5" }, "dependencies": { + "@hcengineering/ai-bot": "^0.6.0", "@hcengineering/core": "^0.6.32", "@hcengineering/platform": "^0.6.11", "@hcengineering/server-core": "^0.6.1", diff --git a/server/middleware/src/identity.ts b/server/middleware/src/identity.ts index c947268a20..3889ec0952 100644 --- a/server/middleware/src/identity.ts +++ b/server/middleware/src/identity.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // +import { aiBotAccountEmail } from '@hcengineering/ai-bot' import core, { MeasureContext, Tx, systemAccountUuid, type SessionData, type TxApplyIf } from '@hcengineering/core' import platform, { PlatformError, Severity, Status } from '@hcengineering/platform' import { BaseMiddleware, Middleware, TxMiddlewareResult, type PipelineContext } from '@hcengineering/server-core' @@ -34,7 +35,8 @@ export class IdentityMiddleware extends BaseMiddleware implements Middleware { tx (ctx: MeasureContext, txes: Tx[]): Promise { const account = ctx.contextData.account - if (account.uuid === systemAccountUuid) { + + if (account.uuid === systemAccountUuid || account.fullSocialIds.some((it) => it.value === aiBotAccountEmail)) { // TODO: We need to enhance allowed list in case of user service, on behalf of user activities. // We pass for system accounts and services.