From 9351fb9617948383111963d9d4c6779f57940e12 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 11 Feb 2023 09:03:43 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=87=E3=82=A3=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=8A=E3=83=AB=E3=83=AD=E3=83=BC=E3=83=AB=E3=82=82?= =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=B8=E3=81=A8=E3=81=97=E3=81=A6=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E5=8F=AF=E8=83=BD=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 +++++++++ packages/backend/src/core/RoleService.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6705535f00..bfd64a94b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,15 @@ You should also include the user name that made the change. --> + +## 13.x.x (unreleased) + +### Improvements +- コンディショナルロールもバッジとして表示可能に + +### Bugfixes +- + ## 13.5.6 (2023/02/10) ### Improvements diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index d15d8c0aee..9a782780d1 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -211,8 +211,14 @@ export class RoleService implements OnApplicationShutdown { const assignedRoleIds = assigns.map(x => x.roleId); const roles = await this.rolesCache.fetch(null, () => this.rolesRepository.findBy({})); const assignedBadgeRoles = roles.filter(r => r.asBadge && assignedRoleIds.includes(r.id)); - // コンディショナルロールも含めるのは負荷高そうだから一旦無し - return assignedBadgeRoles; + const badgeCondRoles = roles.filter(r => r.asBadge && (r.target === 'conditional')); + if (badgeCondRoles.length > 0) { + const user = roles.some(r => r.target === 'conditional') ? await this.userCacheService.findById(userId) : null; + const matchedBadgeCondRoles = badgeCondRoles.filter(r => this.evalCond(user!, r.condFormula)); + return [...assignedBadgeRoles, ...matchedBadgeCondRoles]; + } else { + return assignedBadgeRoles; + } } @bindThis