This commit is contained in:
tamaina 2023-05-26 07:20:14 +00:00
parent ce5faa8ff5
commit bca9c54923
2 changed files with 26 additions and 24 deletions

View File

@ -2,35 +2,14 @@ import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
import { CustomEmojiService } from '@/core/CustomEmojiService.js'; import { CustomEmojiService } from '@/core/CustomEmojiService.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireRolePolicy: 'canManageCustomEmojis',
} as const;
export const paramDef = {
type: 'object',
properties: {
ids: { type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
license: {
type: 'string',
nullable: true,
description: 'Use `null` to reset the license.',
},
},
required: ['ids'],
} as const;
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
@Injectable() @Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { export default class extends Endpoint<'admin/emoji/set-license-bulk'> {
name = 'admin/emoji/set-license-bulk' as const;
constructor( constructor(
private customEmojiService: CustomEmojiService, private customEmojiService: CustomEmojiService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(async (ps, me) => {
await this.customEmojiService.setLicenseBulk(ps.ids, ps.license ?? null); await this.customEmojiService.setLicenseBulk(ps.ids, ps.license ?? null);
}); });
} }

View File

@ -725,6 +725,29 @@ export const endpoints = {
res: undefined, res: undefined,
}], }],
}, },
'admin/emoji/set-license-bulk': {
tags: ['admin'],
requireCredential: true,
requireRolePolicy: 'canManageCustomEmojis',
defines: [{
req: {
type: 'object',
properties: {
ids: { type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
license: {
type: ['string', 'null'],
description: 'Use `null` to reset the license.',
},
},
required: ['ids'],
},
res: undefined,
}],
},
} as const satisfies { [x: string]: IEndpointMeta; }; } as const satisfies { [x: string]: IEndpointMeta; };
export function getEndpointSchema(reqres: 'req' | 'res', key: keyof typeof endpoints) { export function getEndpointSchema(reqres: 'req' | 'res', key: keyof typeof endpoints) {