mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-19 22:20:25 +01:00
e314be5b59
* Fix avatar/banner proxy Co-authored-by: mei23 <m@m544.net> * use getAvatarUrl * fix * join avatar and banner to improve performance * join * Update hybrid-timeline.ts * fix Co-authored-by: mei23 <m@m544.net> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
33 lines
1 KiB
TypeScript
33 lines
1 KiB
TypeScript
import { EntityRepository, Repository } from 'typeorm';
|
|
import { NoteReaction } from '@/models/entities/note-reaction.js';
|
|
import { Notes, Users } from '../index.js';
|
|
import { Packed } from '@/misc/schema.js';
|
|
import { convertLegacyReaction } from '@/misc/reaction-lib.js';
|
|
import { User } from '@/models/entities/user.js';
|
|
|
|
@EntityRepository(NoteReaction)
|
|
export class NoteReactionRepository extends Repository<NoteReaction> {
|
|
public async pack(
|
|
src: NoteReaction['id'] | NoteReaction,
|
|
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 {
|
|
id: reaction.id,
|
|
createdAt: reaction.createdAt.toISOString(),
|
|
user: await Users.pack(reaction.user ?? reaction.userId, me),
|
|
type: convertLegacyReaction(reaction.reaction),
|
|
...(opts.withNote ? {
|
|
note: await Notes.pack(reaction.note ?? reaction.noteId, me),
|
|
} : {}),
|
|
};
|
|
}
|
|
}
|