Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { UserGroups } from "../../../../../models/index.js";
|
||||
import define from "../../../define.js";
|
||||
import { ApiError } from "../../../error.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"groups"
|
||||
],
|
||||
requireCredential: false,
|
||||
requireCredentialPrivateMode: true,
|
||||
res: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "UserGroup"
|
||||
},
|
||||
errors: {
|
||||
noSuchGroup: {
|
||||
message: "No such group.",
|
||||
code: "NO_SUCH_GROUP",
|
||||
id: "e2eb1dcc-d778-4a5f-b3c1-f7a0c7c3f9ad"
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
username: {
|
||||
type: "string",
|
||||
minLength: 1,
|
||||
maxLength: 64
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"username"
|
||||
]
|
||||
};
|
||||
export default define(meta, paramDef, async (ps)=>{
|
||||
const group = await UserGroups.findOneBy({
|
||||
username: ps.username.toLowerCase(),
|
||||
isPrivate: false
|
||||
});
|
||||
if (!group) throw new ApiError(meta.errors.noSuchGroup);
|
||||
return UserGroups.pack(group);
|
||||
});
|
||||
Reference in New Issue
Block a user