1
0
forked from mirror/misskey

enhance(backend): LTLでフォローしているユーザーからの自分への返信が含まれるように

This commit is contained in:
syuilo 2023-10-11 17:29:24 +09:00
parent 566cb35370
commit a26d9ea132
2 changed files with 3 additions and 7 deletions

View File

@ -95,15 +95,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.withFiles) { if (ps.withFiles) {
noteIds = await this.redisTimelineService.get('localTimelineWithFiles', untilId, sinceId); noteIds = await this.redisTimelineService.get('localTimelineWithFiles', untilId, sinceId);
} else if (ps.withReplies) { } else {
const [nonReplyNoteIds, replyNoteIds] = await this.redisTimelineService.getMulti([ const [nonReplyNoteIds, replyNoteIds] = await this.redisTimelineService.getMulti([
'localTimeline', 'localTimeline',
'localTimelineWithReplies', 'localTimelineWithReplies',
], untilId, sinceId); ], untilId, sinceId);
noteIds = Array.from(new Set([...nonReplyNoteIds, ...replyNoteIds])); noteIds = Array.from(new Set([...nonReplyNoteIds, ...replyNoteIds]));
noteIds.sort((a, b) => a > b ? -1 : 1); noteIds.sort((a, b) => a > b ? -1 : 1);
} else {
noteIds = await this.redisTimelineService.get('localTimeline', untilId, sinceId);
} }
noteIds = noteIds.slice(0, ps.limit); noteIds = noteIds.slice(0, ps.limit);
@ -127,6 +125,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (me && (note.userId === me.id)) { if (me && (note.userId === me.id)) {
return true; return true;
} }
if (!ps.withReplies && note.replyId && (me == null || note.replyUserId !== me.id)) return false;
if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false; if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false;
if (me && isUserRelated(note, userIdsWhoMeMuting)) return false; if (me && isUserRelated(note, userIdsWhoMeMuting)) return false;
if (note.renoteId) { if (note.renoteId) {

View File

@ -19,7 +19,7 @@ function genHost() {
} }
function waitForPushToTl() { function waitForPushToTl() {
return sleep(300); return sleep(500);
} }
let app: INestApplicationContext; let app: INestApplicationContext;
@ -619,7 +619,6 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false); assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
}); });
/*
test.concurrent('withReplies: false でフォローしているユーザーからの自分への返信が含まれる', async () => { test.concurrent('withReplies: false でフォローしているユーザーからの自分への返信が含まれる', async () => {
const [alice, bob] = await Promise.all([signup(), signup()]); const [alice, bob] = await Promise.all([signup(), signup()]);
@ -635,7 +634,6 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true); assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true); assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
}); });
*/
test.concurrent('[withReplies: true] 他人の他人への返信が含まれる', async () => { test.concurrent('[withReplies: true] 他人の他人への返信が含まれる', async () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]); const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
@ -786,7 +784,6 @@ describe('Timelines', () => {
const res = await api('/notes/hybrid-timeline', { withReplies: true }, alice); const res = await api('/notes/hybrid-timeline', { withReplies: true }, alice);
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true); assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
}); });
test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => { test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => {