Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
@@ -0,0 +1,64 @@
import define from "../../../define.js";
import { Plans } from "../../../../../models/index.js";
import { insertModerationLog } from "../../../../../services/insert-moderation-log.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireAdmin: true
};
export const paramDef = {
type: "object",
properties: {
planId: {
type: "string",
format: "misskey:id"
},
name: {
type: "string",
minLength: 1,
maxLength: 128
},
icon: {
type: "string",
minLength: 1,
maxLength: 64
},
description: {
type: "string",
maxLength: 512,
default: ""
}
},
required: [
"planId",
"name",
"icon"
]
};
export default define(meta, paramDef, async (ps, me)=>{
const plan = await Plans.findOneByOrFail({
id: ps.planId
});
const name = ps.name.trim();
const icon = ps.icon.trim();
const description = ps.description.trim();
if (name === "") throw new Error("name is empty");
if (icon === "") throw new Error("icon is empty");
const exists = await Plans.findOneBy({
name
});
if (exists && exists.id !== plan.id) throw new Error("plan name already exists");
await Plans.update(plan.id, {
updatedAt: new Date(),
name,
icon,
description
});
insertModerationLog(me, "updatePlan", {
planId: plan.id,
name
});
return await Plans.pack(plan.id);
});