From 46252336fb544acc8288180255c60ffeb8bdf7a5 Mon Sep 17 00:00:00 2001 From: yukineko <27853966+hideki0403@users.noreply.github.com> Date: Thu, 23 Nov 2023 23:40:07 +0900 Subject: [PATCH] =?UTF-8?q?add:=20RedisNote=E3=81=AE=E5=9E=8B=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/core/FunoutTimelineService.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/FunoutTimelineService.ts b/packages/backend/src/core/FunoutTimelineService.ts index 5446cad47e34..df23f90cf091 100644 --- a/packages/backend/src/core/FunoutTimelineService.ts +++ b/packages/backend/src/core/FunoutTimelineService.ts @@ -10,6 +10,18 @@ import { bindThis } from '@/decorators.js'; import { IdService } from '@/core/IdService.js'; import type { Packed } from '@/misc/json-schema.js'; +type RedisNote = { + id: string; + userId: string; + renoteUserId: string; + replyUserId: string; + isNotQuote: boolean; + isReplyToFollowers: boolean; + isSensitive: boolean; + visibility: string; + visibleUserIds: string[]; +}; + @Injectable() export class FunoutTimelineService { constructor( @@ -71,15 +83,10 @@ export class FunoutTimelineService { if (res == null) return []; const tls = res.map(r => r[1] as string[]); - - // 取得した各タイムラインの中で最も古いIDを取得し、古いIDの中で最も新しいIDを取得する - const noteLimitId = tls.map(tl => tl[tl.length - 1].split(':')[0]).sort((a, b) => a > b ? -1 : 1)[0]; - const limitId = sinceId ? sinceId > noteLimitId ? sinceId : noteLimitId : noteLimitId; - - let notes: Record[] = []; + let notes: RedisNote[] = []; tls.forEach(tl => { - notes.push(...this.filter(tl, untilId, limitId)); + notes.push(...this.filter(tl, untilId, sinceId)); }); notes = Array.from(new Map(notes.map(note => [note.id, note])).values()); @@ -89,7 +96,7 @@ export class FunoutTimelineService { } @bindThis - private filter(notes: string[], untilId?: string | null, sinceId?: string | null) { + private filter(notes: string[], untilId?: string | null, sinceId?: string | null): RedisNote[] { let parsedItems = notes.map(item => item.split(':')); if (untilId && sinceId) {