1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-23 22:56:53 +09:00

コンディショナルロールもバッジとして表示可能に

This commit is contained in:
syuilo 2023-02-11 09:03:43 +09:00
parent 7b29e36d64
commit 9351fb9617
2 changed files with 17 additions and 2 deletions

View File

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

View File

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