mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 05:23:08 +02:00
コンディショナルロールもバッジとして表示可能に
This commit is contained in:
parent
7b29e36d64
commit
9351fb9617
2 changed files with 17 additions and 2 deletions
|
@ -8,6 +8,15 @@
|
||||||
|
|
||||||
You should also include the user name that made the change.
|
You should also include the user name that made the change.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## 13.x.x (unreleased)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
- コンディショナルロールもバッジとして表示可能に
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
-
|
||||||
|
|
||||||
## 13.5.6 (2023/02/10)
|
## 13.5.6 (2023/02/10)
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
|
@ -211,8 +211,14 @@ export class RoleService implements OnApplicationShutdown {
|
||||||
const assignedRoleIds = assigns.map(x => x.roleId);
|
const assignedRoleIds = assigns.map(x => x.roleId);
|
||||||
const roles = await this.rolesCache.fetch(null, () => this.rolesRepository.findBy({}));
|
const roles = await this.rolesCache.fetch(null, () => this.rolesRepository.findBy({}));
|
||||||
const assignedBadgeRoles = roles.filter(r => r.asBadge && assignedRoleIds.includes(r.id));
|
const assignedBadgeRoles = roles.filter(r => r.asBadge && assignedRoleIds.includes(r.id));
|
||||||
// コンディショナルロールも含めるのは負荷高そうだから一旦無し
|
const badgeCondRoles = roles.filter(r => r.asBadge && (r.target === 'conditional'));
|
||||||
return assignedBadgeRoles;
|
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
|
@bindThis
|
||||||
|
|
Loading…
Reference in a new issue