This commit is contained in:
tamaina 2023-05-26 07:18:15 +00:00
parent 0ef7a3db0f
commit ce5faa8ff5
4 changed files with 76 additions and 48 deletions

View file

@ -24,11 +24,12 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/emoji/remove-aliases-bulk'> {
name = 'admin/emoji/remove-aliases-bulk' as const;
constructor(
private customEmojiService: CustomEmojiService,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
await this.customEmojiService.removeAliasesBulk(ps.ids, ps.aliases);
});
}

View file

@ -2,33 +2,14 @@ import { Inject, 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',
} as const;
export const paramDef = {
type: 'object',
properties: {
ids: { type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
aliases: { type: 'array', items: {
type: 'string',
} },
},
required: ['ids', 'aliases'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/emoji/set-aliases-bulk'> {
name = 'admin/emoji/set-aliases-bulk' as const;
constructor(
private customEmojiService: CustomEmojiService,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
await this.customEmojiService.setAliasesBulk(ps.ids, ps.aliases);
});
}

View file

@ -2,35 +2,14 @@ import { Inject, 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',
} as const;
export const paramDef = {
type: 'object',
properties: {
ids: { type: 'array', items: {
type: 'string', format: 'misskey:id',
} },
category: {
type: 'string',
nullable: true,
description: 'Use `null` to reset the category.',
},
},
required: ['ids'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/emoji/set-category-bulk'> {
name = 'admin/emoji/set-category-bulk' as const
constructor(
private customEmojiService: CustomEmojiService,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
await this.customEmojiService.setCategoryBulk(ps.ids, ps.category ?? null);
});
}

View file

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