2020-03-30 19:15:04 -05:00
|
|
|
import { EntityRepository, Repository } from 'typeorm';
|
2021-08-19 08:04:15 -05:00
|
|
|
import { Emoji } from '@/models/entities/emoji';
|
2021-09-22 08:35:55 -05:00
|
|
|
import { Packed } from '@/misc/schema';
|
2020-03-30 19:15:04 -05:00
|
|
|
|
|
|
|
@EntityRepository(Emoji)
|
|
|
|
export class EmojiRepository extends Repository<Emoji> {
|
|
|
|
public async pack(
|
|
|
|
src: Emoji['id'] | Emoji,
|
2021-09-22 08:35:55 -05:00
|
|
|
): Promise<Packed<'Emoji'>> {
|
2021-02-13 00:33:38 -06:00
|
|
|
const emoji = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
2020-03-30 19:15:04 -05:00
|
|
|
|
|
|
|
return {
|
|
|
|
id: emoji.id,
|
|
|
|
aliases: emoji.aliases,
|
|
|
|
name: emoji.name,
|
|
|
|
category: emoji.category,
|
|
|
|
host: emoji.host,
|
|
|
|
url: emoji.url,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public packMany(
|
|
|
|
emojis: any[],
|
|
|
|
) {
|
|
|
|
return Promise.all(emojis.map(x => this.pack(x)));
|
|
|
|
}
|
|
|
|
}
|