mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
fix(backend): RoleService.getAdministratorIds でユーザーIDが重複する問題を修正 (#17334)
* fix(backend): adminロールが複数付いてても通知が重複しないように
* add tests
* Update Changelog
* ✌️
Co-Authored-by: lqvp <183242690+lqvp@users.noreply.github.com>
---------
Co-authored-by: lqvp <183242690+lqvp@users.noreply.github.com>
This commit is contained in:
parent
8a85ee1d45
commit
3a3057a1b1
4 changed files with 17 additions and 2 deletions
|
|
@ -23,6 +23,8 @@
|
|||
- Fix: ID生成アルゴリズムにULIDを使用している場合にMisskeyが正しく動作しない問題を修正
|
||||
- Fix: リレー経由で届いたノートがリノートとして表示される問題を修正
|
||||
- Fix: robots.txtの内容を調整
|
||||
- Fix: 特定のユーザーに管理者権限を持つロールが複数ついている際に、取得できるユーザーIDが重複する問題を修正
|
||||
(Cherry-picked from https://github.com/lqvp/misskey-tempura/commit/17ed4108cec4b6bd2fd989db5a9091db91fa37a7)
|
||||
|
||||
## 2026.3.2
|
||||
|
||||
|
|
|
|||
|
|
@ -533,7 +533,8 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||
roleId: In(administratorRoles.map(r => r.id)),
|
||||
}) : [];
|
||||
// TODO: isRootなアカウントも含める
|
||||
return assigns.map(a => a.userId);
|
||||
// Setを経由して重複を除去(ユーザIDは重複する可能性があるので)
|
||||
return [...new Set(assigns.map(a => a.userId))].sort((x, y) => x.localeCompare(y));
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
|
|
|||
|
|
@ -164,4 +164,3 @@ export class SignupService {
|
|||
return { account, secret };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -696,6 +696,19 @@ describe('RoleService', () => {
|
|||
expect(adminIds).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('should not include duplicate user IDs if a user has multiple administrator roles', async () => {
|
||||
const adminUser = await createUser();
|
||||
const adminRole1 = await createRole({ name: 'admin1', isAdministrator: true });
|
||||
const adminRole2 = await createRole({ name: 'admin2', isAdministrator: true });
|
||||
|
||||
await roleService.assign(adminUser.id, adminRole1.id);
|
||||
await roleService.assign(adminUser.id, adminRole2.id);
|
||||
|
||||
const adminIds = await roleService.getAdministratorIds();
|
||||
|
||||
expect(adminIds).toEqual([adminUser.id]);
|
||||
});
|
||||
|
||||
// TODO: rootユーザーは現在実装に含まれていないため、テストもそれに倣う
|
||||
test('should not include the root user', async () => {
|
||||
const rootUser = await createUser();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue