diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-10-17 01:33:15 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-10-17 01:33:15 +0900 |
| commit | 835aad44bbf7245e039227ffa48e611b3bc330f2 (patch) | |
| tree | b2432eb3f5e59b7835205eef6bad6d7bfa1802d4 /src/models | |
| parent | 12.92.0 (diff) | |
| download | sharkey-835aad44bbf7245e039227ffa48e611b3bc330f2.tar.gz sharkey-835aad44bbf7245e039227ffa48e611b3bc330f2.tar.bz2 sharkey-835aad44bbf7245e039227ffa48e611b3bc330f2.zip | |
feat: ユーザーのリアクション一覧を見れるように
Diffstat (limited to 'src/models')
| -rw-r--r-- | src/models/repositories/note-reaction.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/models/repositories/note-reaction.ts b/src/models/repositories/note-reaction.ts index ba74076f6c..5d86065526 100644 --- a/src/models/repositories/note-reaction.ts +++ b/src/models/repositories/note-reaction.ts @@ -1,6 +1,6 @@ import { EntityRepository, Repository } from 'typeorm'; import { NoteReaction } from '@/models/entities/note-reaction'; -import { Users } from '../index'; +import { Notes, Users } from '../index'; import { Packed } from '@/misc/schema'; import { convertLegacyReaction } from '@/misc/reaction-lib'; import { User } from '@/models/entities/user'; @@ -9,8 +9,15 @@ import { User } from '@/models/entities/user'; export class NoteReactionRepository extends Repository<NoteReaction> { public async pack( src: NoteReaction['id'] | NoteReaction, - me?: { id: User['id'] } | null | undefined + me?: { id: User['id'] } | null | undefined, + options?: { + withNote: boolean; + }, ): Promise<Packed<'NoteReaction'>> { + const opts = Object.assign({ + withNote: false, + }, options); + const reaction = typeof src === 'object' ? src : await this.findOneOrFail(src); return { @@ -18,6 +25,9 @@ export class NoteReactionRepository extends Repository<NoteReaction> { createdAt: reaction.createdAt.toISOString(), user: await Users.pack(reaction.userId, me), type: convertLegacyReaction(reaction.reaction), + ...(opts.withNote ? { + note: await Notes.pack(reaction.noteId, me), + } : {}) }; } } |