fix (backend): 「みつける」のなかにミュートしたユーザが現れてしまう問題を修正 (#12559)
* fix (backend): 「みつける」のなかにミュートしたユーザが現れてしまう問題を修正 * fix
This commit is contained in:
		| @@ -9,6 +9,8 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; | ||||
| import { DI } from '@/di-symbols.js'; | ||||
| import { FeaturedService } from '@/core/FeaturedService.js'; | ||||
| import { isUserRelated } from '@/misc/is-user-related.js'; | ||||
| import { CacheService } from '@/core/CacheService.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['notes'], | ||||
| @@ -47,6 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 		@Inject(DI.notesRepository) | ||||
| 		private notesRepository: NotesRepository, | ||||
|  | ||||
| 		private cacheService: CacheService, | ||||
| 		private noteEntityService: NoteEntityService, | ||||
| 		private featuredService: FeaturedService, | ||||
| 	) { | ||||
| @@ -74,6 +77,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 				return []; | ||||
| 			} | ||||
|  | ||||
| 			const [ | ||||
| 				userIdsWhoMeMuting, | ||||
| 				userIdsWhoBlockingMe, | ||||
| 			] = me ? await Promise.all([ | ||||
| 				this.cacheService.userMutingsCache.fetch(me.id), | ||||
| 				this.cacheService.userBlockedCache.fetch(me.id), | ||||
| 			]) : [new Set<string>(), new Set<string>()]; | ||||
|  | ||||
| 			const query = this.notesRepository.createQueryBuilder('note') | ||||
| 				.where('note.id IN (:...noteIds)', { noteIds: noteIds }) | ||||
| 				.innerJoinAndSelect('note.user', 'user') | ||||
| @@ -83,10 +94,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 				.leftJoinAndSelect('renote.user', 'renoteUser') | ||||
| 				.leftJoinAndSelect('note.channel', 'channel'); | ||||
|  | ||||
| 			const notes = await query.getMany(); | ||||
| 			notes.sort((a, b) => a.id > b.id ? -1 : 1); | ||||
| 			const notes = (await query.getMany()).filter(note => { | ||||
| 				if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false; | ||||
| 				if (me && isUserRelated(note, userIdsWhoMeMuting)) return false; | ||||
|  | ||||
| 			// TODO: ミュート等考慮 | ||||
| 				return true; | ||||
| 			}); | ||||
|  | ||||
| 			notes.sort((a, b) => a.id > b.id ? -1 : 1); | ||||
|  | ||||
| 			return await this.noteEntityService.packMany(notes, me); | ||||
| 		}); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 おさむのひと
					おさむのひと