ローカルのカスタム絵文字については直接オリジナルURLにリクエストするように

This commit is contained in:
syuilo 2023-01-21 20:40:09 +09:00
parent bd469420fa
commit 3e112da486
5 changed files with 21 additions and 5 deletions

View file

@ -22,7 +22,7 @@ export class EmojiEntityService {
@bindThis
public async pack(
src: Emoji['id'] | Emoji,
opts: { omitHost?: boolean; omitId?: boolean; } = {},
opts: { omitHost?: boolean; omitId?: boolean; withUrl?: boolean; } = {},
): Promise<Packed<'Emoji'>> {
const emoji = typeof src === 'object' ? src : await this.emojisRepository.findOneByOrFail({ id: src });
@ -32,13 +32,15 @@ export class EmojiEntityService {
name: emoji.name,
category: emoji.category,
host: opts.omitHost ? undefined : emoji.host,
// ?? emoji.originalUrl してるのは後方互換性のため
url: opts.withUrl ? (emoji.publicUrl ?? emoji.originalUrl) : undefined,
};
}
@bindThis
public packMany(
emojis: any[],
opts: { omitHost?: boolean; omitId?: boolean; } = {},
opts: { omitHost?: boolean; omitId?: boolean; withUrl?: boolean; } = {},
) {
return Promise.all(emojis.map(x => this.pack(x, opts)));
}