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 diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 671af8a870b0..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 && !isSelf) 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'); })); diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts index 73c446444be4..0954274ea933 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()]);