summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/users/notes.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-10-04 11:24:46 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-10-04 11:24:46 +0900
commita40734d417f589ad1e25f58c00cdc0616f962e8e (patch)
tree444ade920a458fd8c3f2d1fb1937288bd933c033 /packages/backend/src/server/api/endpoints/users/notes.ts
parentrefactor (diff)
downloadsharkey-a40734d417f589ad1e25f58c00cdc0616f962e8e.tar.gz
sharkey-a40734d417f589ad1e25f58c00cdc0616f962e8e.tar.bz2
sharkey-a40734d417f589ad1e25f58c00cdc0616f962e8e.zip
fix(backend): [2023.10.1.beta-1] [ノート]タブでは見える投稿が[全て]タブに出てこない
Fix #11960
Diffstat (limited to 'packages/backend/src/server/api/endpoints/users/notes.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/users/notes.ts27
1 files changed, 21 insertions, 6 deletions
diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts
index abcc02eace..4613bfcf2a 100644
--- a/packages/backend/src/server/api/endpoints/users/notes.ts
+++ b/packages/backend/src/server/api/endpoints/users/notes.ts
@@ -76,16 +76,31 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const limit = ps.limit + (ps.untilId ? 1 : 0); // untilIdに指定したものも含まれるため+1
let noteIdsRes: [string, string[]][] = [];
+ let repliesNoteIdsRes: [string, string[]][] = [];
if (!ps.sinceId && !ps.sinceDate) {
- noteIdsRes = await this.redisForTimelines.xrevrange(
- ps.withFiles ? `userTimelineWithFiles:${ps.userId}` : ps.withReplies ? `userTimelineWithReplies:${ps.userId}` : `userTimeline:${ps.userId}`,
- ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+',
- '-',
- 'COUNT', limit);
+ [noteIdsRes, repliesNoteIdsRes] = await Promise.all([
+ this.redisForTimelines.xrevrange(
+ ps.withFiles ? `userTimelineWithFiles:${ps.userId}` : `userTimeline:${ps.userId}`,
+ ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+',
+ '-',
+ 'COUNT', limit),
+ ps.withReplies
+ ? this.redisForTimelines.xrevrange(
+ `userTimelineWithReplies:${ps.userId}`,
+ ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+',
+ '-',
+ 'COUNT', limit)
+ : Promise.resolve([]),
+ ]);
}
- const noteIds = noteIdsRes.map(x => x[1][1]).filter(x => x !== ps.untilId);
+ 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),
+ ]));
+ noteIds.sort((a, b) => a > b ? -1 : 1);
+ noteIds = noteIds.slice(0, ps.limit);
if (noteIds.length === 0) {
return [];