From 2312c416918d391dccdf3630fe516d6d58dc887d Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 28 Nov 2023 17:11:29 +0900 Subject: [PATCH 1/5] fix: includeSensitiveChannel not working for funout timeline --- packages/backend/src/server/api/endpoints/users/notes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 671af8a870b0..a53d1e5ce603 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -123,7 +123,7 @@ export default class extends Endpoint { // eslint- } } - if (note.channel?.isSensitive && !isSelf) return false; + if (note.channel?.isSensitive && !ps.includeSensitiveChannel) return false; if (note.visibility === 'specified' && (!me || (me.id !== note.userId && !note.visibleUserIds.some(v => v === me.id)))) return false; if (note.visibility === 'followers' && !isFollowing && !isSelf) return false; From bd0fcc30dea3c167bd3c966e71573f8eaa925ce6 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 28 Nov 2023 17:20:05 +0900 Subject: [PATCH 2/5] =?UTF-8?q?docs(changelog):=20Fix:=20includeSensitiveC?= =?UTF-8?q?hannel=E3=81=8Cfunout=20timeline=E3=81=AE=E7=AF=84=E5=9B=B2?= =?UTF-8?q?=E3=81=A7=E3=81=AF=E6=A9=9F=E8=83=BD=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2157ce35d734..f161748b7ca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ ### Client ### Server +- Fix: includeSensitiveChannelがfunout timelineの範囲では機能しない問題 ## 2023.11.1-kinel.2 From 3307614bb84fe758d0126ba07bd6d7017a4b91b6 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 28 Nov 2023 17:51:51 +0900 Subject: [PATCH 3/5] chore: include sensitive channel by default for self --- packages/backend/src/server/api/endpoints/users/notes.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index a53d1e5ce603..5daa5bce18a3 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -53,7 +53,7 @@ export const paramDef = { untilDate: { type: 'integer' }, withFiles: { type: 'boolean', default: false }, excludeNsfw: { type: 'boolean', default: false }, - includeSensitiveChannel: { type: 'boolean', default: false }, + includeSensitiveChannel: { type: 'boolean' }, }, required: ['userId'], } as const; @@ -78,6 +78,7 @@ export default class extends Endpoint { // eslint- const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const isRangeSpecified = untilId != null && sinceId != null; const isSelf = me && (me.id === ps.userId); + const includeSensitiveChannel = ps.includeSensitiveChannel ?? isSelf; if (isRangeSpecified || sinceId == null) { const [ @@ -123,7 +124,7 @@ export default class extends Endpoint { // eslint- } } - if (note.channel?.isSensitive && !ps.includeSensitiveChannel) return false; + if (note.channel?.isSensitive && !includeSensitiveChannel) return false; if (note.visibility === 'specified' && (!me || (me.id !== note.userId && !note.visibleUserIds.some(v => v === me.id)))) return false; if (note.visibility === 'followers' && !isFollowing && !isSelf) return false; @@ -151,7 +152,7 @@ export default class extends Endpoint { // eslint- .leftJoinAndSelect('renote.user', 'renoteUser'); if (ps.withChannelNotes) { - if (!ps.includeSensitiveChannel) query.andWhere(new Brackets(qb => { + if (!includeSensitiveChannel) query.andWhere(new Brackets(qb => { qb.orWhere('note.channelId IS NULL'); qb.orWhere('channel.isSensitive = false'); })); From ce38a12426f5bc71db0335252b9c04edfcc30388 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 28 Nov 2023 17:57:04 +0900 Subject: [PATCH 4/5] chore: add test for includeSensitiveChannel? --- packages/backend/test/e2e/timelines.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts index 73c446444be4..d81eae62e560 100644 --- a/packages/backend/test/e2e/timelines.ts +++ b/packages/backend/test/e2e/timelines.ts @@ -1209,6 +1209,32 @@ describe('Timelines', () => { assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true); }); + test.concurrent('[withChannelNotes: true, includeSensitiveChannel: true] 他人が取得した場合もセンシティブチャンネル投稿が含まれる', async () => { + const [alice, bob] = await Promise.all([signup(), signup()]); + + const channel = await api('/channels/create', { name: 'channel', isSensitive: true }, bob).then(x => x.body); + const bobNote = await post(bob, { text: 'hi', channelId: channel.id }); + + await waitForPushToTl(); + + const res = await api('/users/notes', { userId: bob.id, withChannelNotes: true, includeSensitiveChannel: true }, alice); + + assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true); + }); + + test.concurrent('[withChannelNotes: true, includeSensitiveChannel: false] 自分が取得したも場合センシティブチャンネル投稿が含まれない', async () => { + const [bob] = await Promise.all([signup()]); + + const channel = await api('/channels/create', { name: 'channel', isSensitive: true }, bob).then(x => x.body); + const bobNote = await post(bob, { text: 'hi', channelId: channel.id }); + + await waitForPushToTl(); + + const res = await api('/users/notes', { userId: bob.id, withChannelNotes: true, includeSensitiveChannel: false }, bob); + + assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false); + }); + test.concurrent('ミュートしているユーザーに関連する投稿が含まれない', async () => { const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]); From a2f50fff1d30bcaacf4cc76e88ae106cd7098cfb Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 28 Nov 2023 18:26:20 +0900 Subject: [PATCH 5/5] test: fix test name Co-authored-by: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> --- packages/backend/test/e2e/timelines.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts index d81eae62e560..0954274ea933 100644 --- a/packages/backend/test/e2e/timelines.ts +++ b/packages/backend/test/e2e/timelines.ts @@ -1222,7 +1222,7 @@ describe('Timelines', () => { assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true); }); - test.concurrent('[withChannelNotes: true, includeSensitiveChannel: false] 自分が取得したも場合センシティブチャンネル投稿が含まれない', async () => { + test.concurrent('[withChannelNotes: true, includeSensitiveChannel: false] 自分が取得した場合もセンシティブチャンネル投稿が含まれない', async () => { const [bob] = await Promise.all([signup()]); const channel = await api('/channels/create', { name: 'channel', isSensitive: true }, bob).then(x => x.body);