Johann150 78df3dc484
enhance: improve documentation for /users/ endpoints (#8790)
* docs: category & description for reset password

* docs: category & description for testing

* docs: descriptions for groups endpoints

* docs: descriptions for drive file endpoints

* docs: descriptions for sw endpoints

* docs: descriptions for user list endpoints

* docs: descriptions & result type for gallery posts

* docs: descriptions & result type for user endpoints

* docs: add return type for stats
2022-06-10 14:25:20 +09:00

44 lines
908 B
TypeScript

import define from '../../../define.js';
import { ApiError } from '../../../error.js';
import { UserGroups } from '@/models/index.js';
export const meta = {
tags: ['groups'],
requireCredential: true,
kind: 'write:user-groups',
description: 'Delete an existing group.',
errors: {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: '63dbd64c-cd77-413f-8e08-61781e210b38',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
groupId: { type: 'string', format: 'misskey:id' },
},
required: ['groupId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const userGroup = await UserGroups.findOneBy({
id: ps.groupId,
userId: user.id,
});
if (userGroup == null) {
throw new ApiError(meta.errors.noSuchGroup);
}
await UserGroups.delete(userGroup.id);
});