Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): ブロックした相手から自分のノートが見えないように(/users/featured-notes, /users/notes) #12511

Merged
merged 19 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fd6dc56
fix: ブロックした相手から自分のノートが見えないように(ユーザー,チャンネル)
kanarikanaru Nov 29, 2023
4f70cfe
Merge branch 'develop' into note-visibility
kanarikanaru Nov 29, 2023
18106cf
Merge branch 'develop' into note-visibility
kanarikanaru Nov 29, 2023
1862f9a
Merge branch 'develop' into note-visibility
kanarikanaru Nov 29, 2023
f1473f4
Merge branch 'develop' into note-visibility
kanarikanaru Nov 29, 2023
92b7960
Merge branch 'develop' into note-visibility
kanarikanaru Nov 30, 2023
ad9e0db
Merge branch 'develop' into note-visibility
kanarikanaru Nov 30, 2023
173718c
Update CHANGELOG.md
kanarikanaru Nov 30, 2023
c4bd1d0
Merge branch 'develop' into note-visibility
kanarikanaru Dec 1, 2023
61079c0
Merge remote-tracking branch 'upstream/develop' into note-visibility
kanarikanaru Dec 2, 2023
30ad519
Merge branch 'develop' into note-visibility
kanarikanaru Dec 2, 2023
216df2e
Merge remote-tracking branch 'upstream/develop' into note-visibility
kanarikanaru Dec 3, 2023
e04a7b0
Merge branch 'develop' into note-visibility
kanarikanaru Dec 3, 2023
a6d940d
/users/featured-notesでもブロックを考慮するように
kanarikanaru Dec 3, 2023
6459d0e
cacheServiceを使うように
kanarikanaru Dec 4, 2023
bfe09d7
Merge remote-tracking branch 'upstream/develop' into note-visibility
kanarikanaru Dec 4, 2023
fb8c43c
/channels/timeline.tsで必要のないnoteFilterを持たないように
kanarikanaru Dec 4, 2023
43816db
Update CHANGELOG.md
kanarikanaru Dec 4, 2023
dff81e7
FanoutTimelineEndpointServiceへの対応
kanarikanaru Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- Fix: ユーザのノート一覧にてインスタンスミュートが効かない問題
- Fix: チャンネルのノート一覧にてインスタンスミュートが効かない問題
- Fix: 「みつける」が年越し時に壊れる問題を修正
- Fix: アカウントをブロックした際に、自身のユーザーのページでノートが相手に表示される問題を修正

## 2023.11.1

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/core/FanoutTimelineEndpointService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type TimelineOptions = {
redisTimelines: FanoutTimelineName[],
noteFilter?: (note: MiNote) => boolean,
alwaysIncludeMyNotes?: boolean;
ignoreAuthorFromBlock?: boolean;
ignoreAuthorFromMute?: boolean;
excludeNoFiles?: boolean;
excludeReplies?: boolean;
Expand Down Expand Up @@ -109,7 +110,7 @@ export class FanoutTimelineEndpointService {

const parentFilter = filter;
filter = (note) => {
if (isUserRelated(note, userIdsWhoBlockingMe, ps.ignoreAuthorFromMute)) return false;
if (isUserRelated(note, userIdsWhoBlockingMe, ps.ignoreAuthorFromBlock)) return false;
if (isUserRelated(note, userIdsWhoMeMuting, ps.ignoreAuthorFromMute)) return false;
if (isPureRenote(note) && isUserRelated(note, userIdsWhoMeMutingRenotes, ps.ignoreAuthorFromMute)) return false;
if (isInstanceMuted(note, userMutedInstances)) return false;
Expand Down
21 changes: 18 additions & 3 deletions packages/backend/src/server/api/endpoints/users/featured-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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);
Expand All @@ -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')
Expand All @@ -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);
});
Expand Down
Loading