Add exception to rules for ai bot in identity (#8397)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2025-03-31 09:51:59 +04:00 committed by GitHub
parent b3a4be2933
commit e9d8da460a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -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",

View File

@ -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<SessionData>, txes: Tx[]): Promise<TxMiddlewareResult> {
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.