iceshrimp-legacy/packages/backend/src/server/api/endpoints/admin/update-user-note.ts

35 lines
661 B
TypeScript
Raw Normal View History

2023-01-13 05:40:33 +01:00
import { UserProfiles, Users } from "@/models/index.js";
import define from "../../define.js";
2022-07-02 17:15:03 +02:00
export const meta = {
2023-01-13 05:40:33 +01:00
tags: ["admin"],
2022-07-02 17:15:03 +02:00
requireCredential: true,
requireModerator: true,
} as const;
export const paramDef = {
2023-01-13 05:40:33 +01:00
type: "object",
2022-07-02 17:15:03 +02:00
properties: {
2023-01-13 05:40:33 +01:00
userId: { type: "string", format: "misskey:id" },
text: { type: "string" },
2022-07-02 17:15:03 +02:00
},
2023-01-13 05:40:33 +01:00
required: ["userId", "text"],
2022-07-02 17:15:03 +02:00
} as const;
2023-01-13 05:54:33 +01:00
2022-07-02 17:15:03 +02:00
export default define(meta, paramDef, async (ps, me) => {
const user = await Users.findOneBy({ id: ps.userId });
if (user == null) {
2023-01-13 05:40:33 +01:00
throw new Error("user not found");
2022-07-02 17:15:03 +02:00
}
2023-01-13 05:40:33 +01:00
await UserProfiles.update(
{ userId: user.id },
{
moderationNote: ps.text,
},
);
2022-07-02 17:15:03 +02:00
});