ローカルのカスタム絵文字については直接オリジナルURLにリクエストするように
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
|
@@ -29,5 +29,9 @@ export const packedEmojiSchema = {
|
||||
optional: true, nullable: true,
|
||||
description: 'The local host is represented with `null`.',
|
||||
},
|
||||
url: {
|
||||
type: 'string',
|
||||
optional: true, nullable: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
@@ -83,6 +83,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
emojis: await this.emojiEntityService.packMany(emojis, {
|
||||
omitId: true,
|
||||
omitHost: true,
|
||||
withUrl: true,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
Reference in New Issue
Block a user