Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { UserGroups } from "../../../../../models/index.js";
|
||||
import define from "../../../define.js";
|
||||
import { ApiError } from "../../../error.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"
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
groupId: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"groupId"
|
||||
]
|
||||
};
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user