カスタム絵文字インポート時もemojiAddedイベントを発行するように

This commit is contained in:
syuilo 2021-06-23 13:42:02 +09:00
parent f26aeee819
commit d97fc9ce4e

View File

@ -7,6 +7,7 @@ import { ApiError } from '../../../error';
import { DriveFile } from '../../../../../models/entities/drive-file';
import { ID } from '@/misc/cafy-id';
import uploadFromUrl from '../../../../../services/drive/upload-from-url';
import { publishBroadcastStream } from '@/services/stream';
export const meta = {
tags: ['admin'],
@ -57,7 +58,7 @@ export default define(meta, async (ps, me) => {
throw new ApiError();
}
const copied = await Emojis.save({
const copied = await Emojis.insert({
id: genId(),
updatedAt: new Date(),
name: emoji.name,
@ -66,10 +67,14 @@ export default define(meta, async (ps, me) => {
url: driveFile.url,
type: driveFile.type,
fileId: driveFile.id,
});
}).then(x => Emojis.findOneOrFail(x.identifiers[0]));
await getConnection().queryResultCache!.remove(['meta_emojis']);
publishBroadcastStream('emojiAdded', {
emoji: await Emojis.pack(copied.id)
});
return {
id: copied.id
};