From 2333bdb98ae88b9a6018bf4b11479a241ea77f0e Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 5 Oct 2023 10:23:58 +0900 Subject: fix(backend): sinceIdやsinceDateを利用してTLを取得することができない MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #11961 --- packages/backend/src/server/api/endpoints/users/notes.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'packages/backend/src/server/api/endpoints/users/notes.ts') diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 4374863f2b..23c2811fb9 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -80,7 +80,7 @@ export default class extends Endpoint { // eslint- let timeline: MiNote[] = []; - const limit = ps.limit + (ps.untilId ? 1 : 0); // untilIdに指定したものも含まれるため+1 + const limit = ps.limit + (ps.untilId ? 1 : 0) + (ps.sinceId ? 1 : 0); // untilIdに指定したものも含まれるため+1 let noteIdsRes: [string, string[]][] = []; let repliesNoteIdsRes: [string, string[]][] = []; let channelNoteIdsRes: [string, string[]][] = []; @@ -90,29 +90,29 @@ export default class extends Endpoint { // eslint- this.redisForTimelines.xrevrange( ps.withFiles ? `userTimelineWithFiles:${ps.userId}` : `userTimeline:${ps.userId}`, ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+', - '-', + ps.sinceId ? this.idService.parse(ps.sinceId).date.getTime() : ps.sinceDate ?? '-', 'COUNT', limit), ps.withReplies ? this.redisForTimelines.xrevrange( `userTimelineWithReplies:${ps.userId}`, ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+', - '-', + ps.sinceId ? this.idService.parse(ps.sinceId).date.getTime() : ps.sinceDate ?? '-', 'COUNT', limit) : Promise.resolve([]), ps.withChannelNotes ? this.redisForTimelines.xrevrange( `userTimelineWithChannel:${ps.userId}`, ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+', - '-', + ps.sinceId ? this.idService.parse(ps.sinceId).date.getTime() : ps.sinceDate ?? '-', 'COUNT', limit) : Promise.resolve([]), ]); } let noteIds = Array.from(new Set([ - ...noteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId), - ...repliesNoteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId), - ...channelNoteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId), + ...noteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId && x !== ps.sinceId), + ...repliesNoteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId && x !== ps.sinceId), + ...channelNoteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId && x !== ps.sinceId), ])); noteIds.sort((a, b) => a > b ? -1 : 1); noteIds = noteIds.slice(0, ps.limit); -- cgit v1.2.3-freya