mirror of
https://github.com/MisskeyIO/misskey
synced 2024-11-27 06:18:40 +09:00
enhance(backend): 公開バッジのみをpackするように (MisskeyIO#652)
This commit is contained in:
parent
2b2975c0dd
commit
b8a90659f3
@ -500,13 +500,16 @@ export class UserEntityService implements OnModuleInit {
|
||||
} : undefined) : undefined,
|
||||
emojis: this.customEmojiService.populateEmojis(user.emojis, user.host),
|
||||
onlineStatus: this.getOnlineStatus(user),
|
||||
// パフォーマンス上の理由でローカルユーザーのみ
|
||||
badgeRoles: user.host == null ? this.roleService.getUserBadgeRoles(user.id).then(rs => rs.sort((a, b) => b.displayOrder - a.displayOrder).map(r => ({
|
||||
name: r.name,
|
||||
iconUrl: r.iconUrl,
|
||||
displayOrder: r.displayOrder,
|
||||
behavior: r.badgeBehavior ?? undefined,
|
||||
}))) : undefined,
|
||||
badgeRoles: this.roleService.getUserBadgeRoles(user.id).then((rs) => rs
|
||||
.filter((r) => r.isPublic || iAmModerator)
|
||||
.sort((a, b) => b.displayOrder - a.displayOrder)
|
||||
.map((r) => ({
|
||||
name: r.name,
|
||||
iconUrl: r.iconUrl,
|
||||
displayOrder: r.displayOrder,
|
||||
behavior: r.badgeBehavior ?? undefined,
|
||||
})),
|
||||
),
|
||||
|
||||
...(isDetailed ? {
|
||||
url: profile!.url,
|
||||
|
@ -231,7 +231,7 @@ describe('ユーザー', () => {
|
||||
rolePublic = await role(root, { isPublic: true, name: 'Public Role' });
|
||||
await api('admin/roles/assign', { userId: userRolePublic.id, roleId: rolePublic.id }, root);
|
||||
userRoleBadge = await signup({ username: 'userRoleBadge' });
|
||||
roleBadge = await role(root, { asBadge: true, name: 'Badge Role' });
|
||||
roleBadge = await role(root, { asBadge: true, name: 'Badge Role', isPublic: true });
|
||||
await api('admin/roles/assign', { userId: userRoleBadge.id, roleId: roleBadge.id }, root);
|
||||
userSilenced = await signup({ username: 'userSilenced' });
|
||||
await post(userSilenced, { text: 'test' });
|
||||
@ -665,7 +665,16 @@ describe('ユーザー', () => {
|
||||
displayOrder: roleBadge.displayOrder,
|
||||
}]);
|
||||
}
|
||||
assert.deepStrictEqual(response.roles, []); // バッヂだからといってrolesが取れるとは限らない
|
||||
assert.deepStrictEqual(response.roles, [{
|
||||
id: roleBadge.id,
|
||||
name: roleBadge.name,
|
||||
color: roleBadge.color,
|
||||
iconUrl: roleBadge.iconUrl,
|
||||
description: roleBadge.description,
|
||||
isModerator: roleBadge.isModerator,
|
||||
isAdministrator: roleBadge.isAdministrator,
|
||||
displayOrder: roleBadge.displayOrder,
|
||||
}]);
|
||||
});
|
||||
test('をID指定のリスト形式で取得することができる(空)', async () => {
|
||||
const parameters = { userIds: [] };
|
||||
|
Loading…
Reference in New Issue
Block a user