50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
|
|
|
export const meta = {
|
|
tags: ['admin'],
|
|
|
|
requireCredential: true,
|
|
requireRolePolicy: 'canManageCustomEmojis',
|
|
|
|
errors: {
|
|
noSuchEmoji: {
|
|
message: 'No such emoji.',
|
|
code: 'NO_SUCH_EMOJI',
|
|
id: 'be83669b-773a-44b7-b1f8-e5e5170ac3c2',
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', format: 'misskey:id' },
|
|
},
|
|
required: ['id'],
|
|
} as const;
|
|
|
|
@Injectable()
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
|
constructor(
|
|
private customEmojiService: CustomEmojiService,
|
|
) {
|
|
super(meta, paramDef, async (ps, me) => {
|
|
const emoji = await this.customEmojiService.getEmojiById(ps.id);
|
|
const RequestEmoji = await this.customEmojiService.getEmojiRequestById(ps.id);
|
|
if (emoji != null) {
|
|
await this.customEmojiService.delete(ps.id, me);
|
|
}
|
|
if (RequestEmoji != null) {
|
|
await this.customEmojiService.RequestDelete(ps.id);
|
|
}
|
|
});
|
|
}
|
|
}
|