diff options
| author | KanariKanaru <93921745+kanarikanaru@users.noreply.github.com> | 2023-12-07 18:15:38 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-07 18:15:38 +0900 |
| commit | e6d01e33e6b539dca784c5309158ae80836fac27 (patch) | |
| tree | 71c2e78c4e22ad1d799e856dd2b85b90c3d3d70b /packages/backend/src/server/api | |
| parent | enhance: meilisearchを有効にしてもミュートやブロックを考慮... (diff) | |
| download | sharkey-e6d01e33e6b539dca784c5309158ae80836fac27.tar.gz sharkey-e6d01e33e6b539dca784c5309158ae80836fac27.tar.bz2 sharkey-e6d01e33e6b539dca784c5309158ae80836fac27.zip | |
fix(backend): ブロックした相手から自分のノートが見えないように(/users/featured-notes, /users/notes) (#12511)
* fix: ブロックした相手から自分のノートが見えないように(ユーザー,チャンネル)
* Update CHANGELOG.md
* /users/featured-notesでもブロックを考慮するように
* cacheServiceを使うように
* /channels/timeline.tsで必要のないnoteFilterを持たないように
* Update CHANGELOG.md
* FanoutTimelineEndpointServiceへの対応
- ブロックされている場合は、/users/notesでノートが表示されない
- ミュートしている場合は、ノートが表示される
Diffstat (limited to 'packages/backend/src/server/api')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/users/featured-notes.ts | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/packages/backend/src/server/api/endpoints/users/featured-notes.ts b/packages/backend/src/server/api/endpoints/users/featured-notes.ts index dec0b7a122..f84148d727 100644 --- a/packages/backend/src/server/api/endpoints/users/featured-notes.ts +++ b/packages/backend/src/server/api/endpoints/users/featured-notes.ts @@ -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 { CacheService } from '@/core/CacheService.js'; +import { isUserRelated } from '@/misc/is-user-related.js'; export const meta = { tags: ['notes'], @@ -46,6 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- private noteEntityService: NoteEntityService, private featuredService: FeaturedService, + private cacheService: CacheService, ) { super(meta, paramDef, async (ps, me) => { let noteIds = await this.featuredService.getPerUserNotesRanking(ps.userId, 50); @@ -60,6 +63,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') @@ -69,10 +80,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, false)) return false; + if (me && isUserRelated(note, userIdsWhoMeMuting, true)) return false; - // TODO: ミュート等考慮 + return true; + }); + + notes.sort((a, b) => a.id > b.id ? -1 : 1); return await this.noteEntityService.packMany(notes, me); }); |