diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-10-05 09:48:45 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-10-05 09:48:45 +0900 |
| commit | 5b00fa6f825d5cf498ecf14c1a005762f84b923d (patch) | |
| tree | 9e8068d3e6b02d64c1af24ef50bf23cd32b7c31f /packages/backend/src/server/api/endpoints/users | |
| parent | add more tests (diff) | |
| download | sharkey-5b00fa6f825d5cf498ecf14c1a005762f84b923d.tar.gz sharkey-5b00fa6f825d5cf498ecf14c1a005762f84b923d.tar.bz2 sharkey-5b00fa6f825d5cf498ecf14c1a005762f84b923d.zip | |
enhance(backend): users/notesでチャンネル投稿を含めるオプション
Resolve #11965
Diffstat (limited to 'packages/backend/src/server/api/endpoints/users')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/users/notes.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 09adcf20aa..4374863f2b 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -44,6 +44,7 @@ export const paramDef = { userId: { type: 'string', format: 'misskey:id' }, withReplies: { type: 'boolean', default: false }, withRenotes: { type: 'boolean', default: true }, + withChannelNotes: { type: 'boolean', default: false }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, @@ -82,9 +83,10 @@ 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[]][] = []; + let channelNoteIdsRes: [string, string[]][] = []; if (!ps.sinceId && !ps.sinceDate) { - [noteIdsRes, repliesNoteIdsRes] = await Promise.all([ + [noteIdsRes, repliesNoteIdsRes, channelNoteIdsRes] = 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 ?? '+', @@ -97,12 +99,20 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- '-', 'COUNT', limit) : Promise.resolve([]), + ps.withChannelNotes + ? this.redisForTimelines.xrevrange( + `userTimelineWithChannel:${ps.userId}`, + ps.untilId ? this.idService.parse(ps.untilId).date.getTime() : ps.untilDate ?? '+', + '-', + '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), ])); noteIds.sort((a, b) => a > b ? -1 : 1); noteIds = noteIds.slice(0, ps.limit); |