fix(backend): 一般ユーザーから見たユーザーのバッジの一覧に公開されていないものが含まれることがある問題を修正 (#14195)
* enhance(backend): 公開バッジのみをpackするように (MisskeyIO#652) (cherry picked from commit b8a90659f35fef49d1d00fb2f9b152226c97643c) * Update Changelog * fix * Update UserEntityService.ts --------- Co-authored-by: CyberRex <26585194+CyberRex0@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									b5fd6183d2
								
							
						
					
					
						commit
						58c596cacf
					
				
					 3 changed files with 22 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -46,6 +46,8 @@
 | 
			
		|||
  2. フォロー中かつ非アクティブなユーザ
 | 
			
		||||
  3. フォローしていないアクティブなユーザ
 | 
			
		||||
  4. フォローしていない非アクティブなユーザ
 | 
			
		||||
- Fix: 一般ユーザーから見たユーザーのバッジの一覧に公開されていないものが含まれることがある問題を修正  
 | 
			
		||||
  (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/652)
 | 
			
		||||
 | 
			
		||||
### Misskey.js
 | 
			
		||||
- Feat: `/drive/files/create` のリクエストに対応(`multipart/form-data`に対応)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -501,11 +501,15 @@ export class UserEntityService implements OnModuleInit {
 | 
			
		|||
			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,
 | 
			
		||||
			}))) : undefined,
 | 
			
		||||
			badgeRoles: user.host == null ? 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,
 | 
			
		||||
				}))
 | 
			
		||||
			) : 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' });
 | 
			
		||||
| 
						 | 
				
			
			@ -655,7 +655,16 @@ describe('ユーザー', () => {
 | 
			
		|||
			iconUrl: roleBadge.iconUrl,
 | 
			
		||||
			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…
	
	Add table
		Add a link
		
	
		Reference in a new issue