1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-05 10:18:38 +09:00
This commit is contained in:
NoriDev 2023-11-24 18:07:03 +09:00
parent 6a860a4725
commit 617dbfab2a
3 changed files with 13 additions and 9 deletions

View File

@ -4,16 +4,16 @@
*/
import { Inject, Injectable } from '@nestjs/common';
import { IsNull } from 'typeorm';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { EmojisRepository } from '@/models/index.js';
import type { EmojisRepository } from '@/models/_.js';
import { IdService } from '@/core/IdService.js';
import type { DriveFile } from '@/models/entities/DriveFile.js';
import type { MiDriveFile } from '@/models/DriveFile.js';
import { DI } from '@/di-symbols.js';
import { DriveService } from '@/core/DriveService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js';
import { ApiError } from '../../../error.js';
import { IsNull } from 'typeorm';
export const meta = {
tags: ['admin'],
@ -56,9 +56,10 @@ export const paramDef = {
required: ['name', 'host'],
} as const;
// TODO: ロジックをサービスに切り出す
@Injectable()
// eslint-disable-next-line import/no-default-export
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-next-line import/no-default-export
constructor(
@Inject(DI.emojisRepository)
private emojisRepository: EmojisRepository,
@ -80,16 +81,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
throw new ApiError(meta.errors.localEmojiAlreadyExists);
}
let driveFile: DriveFile;
let driveFile: MiDriveFile;
try {
// Create file
driveFile = await this.driveService.uploadFromUrl({ url: emoji.originalUrl, user: null, force: true });
} catch (e) {
throw new ApiError();
}
const copied = await this.emojisRepository.insert({
id: this.idService.genId(),
id: this.idService.gen(),
updatedAt: new Date(),
name: emoji.name,
host: null,

View File

@ -96,8 +96,8 @@ function onClick(ev: MouseEvent) {
}, ...(props.host && $i && ($i.isAdmin || $i.policies.canManageCustomEmojis) ? [{
text: i18n.ts.import,
icon: 'ti ti-plus',
action: async () => {
await os.apiWithDialog('admin/emoji/steal', {
action: () => {
os.apiWithDialog('admin/emoji/steal', {
name: customEmojiName.value,
host: props.host,
});

View File

@ -383,6 +383,8 @@ export default function(props: MfmProps) {
normal: props.plain,
host: props.author.host,
useOriginalSize: scale >= 2.5,
menu: props.enableEmojiMenu,
menuReaction: props.enableEmojiMenuReaction,
})];
}
}