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,53 @@
import define from "../../../define.js";
import { Users } from "../../../../../models/index.js";
import { signup } from "../../../common/signup.js";
import { IsNull } from "typeorm";
export const meta = {
tags: [
"admin"
],
res: {
type: "object",
optional: false,
nullable: false,
ref: "User",
properties: {
token: {
type: "string",
optional: false,
nullable: false
}
}
}
};
export const paramDef = {
type: "object",
properties: {
username: Users.localUsernameSchema,
password: Users.passwordSchema
},
required: [
"username",
"password"
]
};
export default define(meta, paramDef, async (ps, _me)=>{
const me = _me ? await Users.findOneByOrFail({
id: _me.id
}) : null;
const noUsers = await Users.countBy({
host: IsNull(),
isAdmin: true
}) === 0;
if (!(noUsers || me?.isAdmin)) throw new Error("access denied");
const { account, secret } = await signup({
username: ps.username,
password: ps.password
});
const res = await Users.pack(account, account, {
detail: true,
includeSecrets: true
});
res.token = secret;
return res;
});
@@ -0,0 +1,56 @@
import define from "../../../define.js";
import { Users } from "../../../../../models/index.js";
import { doPostSuspend } from "../../../../../services/suspend-user.js";
import { publishUserEvent } from "../../../../../services/stream.js";
import { createDeleteAccountJob } from "../../../../../queue/index.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true
};
export const paramDef = {
type: "object",
properties: {
userId: {
type: "string",
format: "misskey:id"
}
},
required: [
"userId"
]
};
export default define(meta, paramDef, async (ps, me)=>{
const user = await Users.findOneBy({
id: ps.userId
});
if (user == null) {
throw new Error("user not found");
}
if (user.isAdmin) {
throw new Error("cannot suspend admin");
}
if (user.isModerator) {
throw new Error("cannot suspend moderator");
}
if (Users.isLocalUser(user)) {
// 物理削除する前にDelete activityを送信する
await doPostSuspend(user).catch((e)=>{});
createDeleteAccountJob(user, {
soft: false
});
} else {
createDeleteAccountJob(user, {
soft: true
});
}
await Users.update(user.id, {
isDeleted: true
});
if (Users.isLocalUser(user)) {
// Terminate streaming
publishUserEvent(user.id, "terminate", {});
}
});
@@ -0,0 +1,109 @@
import config from "../../../../../config/index.js";
import { insertModerationLog } from "../../../../../services/insert-moderation-log.js";
import define from "../../../define.js";
import { Metas } 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 (ps, me)=>{
const hostedConfig = config.isManagedHosting;
const hosted = hostedConfig != null && hostedConfig === true;
if (hosted) {
const set = {};
if (config.deepl.managed != null && config.deepl.managed === true) {
if (typeof config.deepl.authKey === "boolean") {
set.deeplAuthKey = config.deepl.authKey;
}
if (typeof config.deepl.isPro === "boolean") {
set.deeplIsPro = config.deepl.isPro;
}
}
if (config.libreTranslate.managed != null && config.libreTranslate.managed === true) {
if (typeof config.libreTranslate.apiUrl === "string") {
set.libreTranslateApiUrl = config.libreTranslate.apiUrl;
}
if (typeof config.libreTranslate.apiKey === "string") {
set.libreTranslateApiKey = config.libreTranslate.apiKey;
}
}
if (config.email.managed != null && config.email.managed === true) {
set.enableEmail = true;
if (typeof config.email.address === "string") {
set.email = config.email.address;
}
if (typeof config.email.host === "string") {
set.smtpHost = config.email.host;
}
if (typeof config.email.port === "number") {
set.smtpPort = config.email.port;
}
if (typeof config.email.user === "string") {
set.smtpUser = config.email.user;
}
if (typeof config.email.pass === "string") {
set.smtpPass = config.email.pass;
}
if (typeof config.email.useImplicitSslTls === "boolean") {
set.smtpSecure = config.email.useImplicitSslTls;
}
}
if (config.objectStorage.managed != null && config.objectStorage.managed === true) {
set.useObjectStorage = true;
if (typeof config.objectStorage.baseUrl === "string") {
set.objectStorageBaseUrl = config.objectStorage.baseUrl;
}
if (typeof config.objectStorage.bucket === "string") {
set.objectStorageBucket = config.objectStorage.bucket;
}
if (typeof config.objectStorage.prefix === "string") {
set.objectStoragePrefix = config.objectStorage.prefix;
}
if (typeof config.objectStorage.endpoint === "string") {
set.objectStorageEndpoint = config.objectStorage.endpoint;
}
if (typeof config.objectStorage.region === "string") {
set.objectStorageRegion = config.objectStorage.region;
}
if (typeof config.objectStorage.accessKey === "string") {
set.objectStorageAccessKey = config.objectStorage.accessKey;
}
if (typeof config.objectStorage.secretKey === "string") {
set.objectStorageSecretKey = config.objectStorage.secretKey;
}
if (typeof config.objectStorage.useSsl === "boolean") {
set.objectStorageUseSSL = config.objectStorage.useSsl;
}
if (typeof config.objectStorage.connnectOverProxy === "boolean") {
set.objectStorageUseProxy = config.objectStorage.connnectOverProxy;
}
if (typeof config.objectStorage.setPublicReadOnUpload === "boolean") {
set.objectStorageSetPublicRead = config.objectStorage.setPublicReadOnUpload;
}
if (typeof config.objectStorage.s3ForcePathStyle === "boolean") {
set.objectStorageS3ForcePathStyle = config.objectStorage.s3ForcePathStyle;
}
}
if (config.summalyProxyUrl !== undefined) {
set.summalyProxy = config.summalyProxyUrl;
}
const meta = await Metas.findOne({
where: {},
order: {
id: "DESC"
}
});
if (meta) await Metas.update(meta.id, set);
else await Metas.save(set);
insertModerationLog(me, "updateMeta");
}
return hosted;
});