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,59 @@
import define from "../../../define.js";
import { Plans } from "../../../../../models/index.js";
import { genId } from "../../../../../misc/gen-id.js";
import { insertModerationLog } from "../../../../../services/insert-moderation-log.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireAdmin: true
};
export const paramDef = {
type: "object",
properties: {
name: {
type: "string",
minLength: 1,
maxLength: 128
},
icon: {
type: "string",
minLength: 1,
maxLength: 64
},
description: {
type: "string",
maxLength: 512,
default: ""
}
},
required: [
"name",
"icon"
]
};
export default define(meta, paramDef, async (ps, me)=>{
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) throw new Error("plan name already exists");
const plan = await Plans.insert({
id: genId(),
createdAt: new Date(),
updatedAt: null,
name,
icon,
description
}).then((x)=>Plans.findOneByOrFail(x.identifiers[0]));
insertModerationLog(me, "createPlan", {
planId: plan.id,
name
});
return await Plans.pack(plan);
});
@@ -0,0 +1,32 @@
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"
}
},
required: [
"planId"
]
};
export default define(meta, paramDef, async (ps, me)=>{
const plan = await Plans.findOneByOrFail({
id: ps.planId
});
await Plans.delete(plan.id);
insertModerationLog(me, "deletePlan", {
planId: plan.id,
name: plan.name
});
});
@@ -0,0 +1,22 @@
import define from "../../../define.js";
import { Plans } from "../../../../../models/index.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireAdmin: true
};
export const paramDef = {
type: "object",
properties: {},
required: []
};
export default define(meta, paramDef, async ()=>{
const plans = await Plans.find({
order: {
createdAt: "ASC"
}
});
return await Plans.packMany(plans);
});
@@ -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);
});