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,17 @@
import define from "../../../define.js";
import { createCleanRemoteFilesJob } from "../../../../../queue/index.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true
};
export const paramDef = {
type: "object",
properties: {},
required: []
};
export default define(meta, paramDef, async (ps, me)=>{
createCleanRemoteFilesJob();
});
@@ -0,0 +1,24 @@
import { IsNull } from "typeorm";
import define from "../../../define.js";
import { deleteFile } from "../../../../../services/drive/delete-file.js";
import { DriveFiles } from "../../../../../models/index.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true
};
export const paramDef = {
type: "object",
properties: {},
required: []
};
export default define(meta, paramDef, async (ps, me)=>{
const files = await DriveFiles.findBy({
userId: IsNull()
});
for (const file of files){
deleteFile(file);
}
});
@@ -0,0 +1,102 @@
import { DriveFiles } from "../../../../../models/index.js";
import define from "../../../define.js";
import { makePaginationQuery } from "../../../common/make-pagination-query.js";
export const meta = {
tags: [
"admin"
],
requireCredential: false,
requireModerator: true,
res: {
type: "array",
optional: false,
nullable: false,
items: {
type: "object",
optional: false,
nullable: false,
ref: "DriveFile"
}
}
};
export const paramDef = {
type: "object",
properties: {
limit: {
type: "integer",
minimum: 1,
maximum: 100,
default: 10
},
sinceId: {
type: "string",
format: "misskey:id"
},
untilId: {
type: "string",
format: "misskey:id"
},
userId: {
type: "string",
format: "misskey:id",
nullable: true
},
type: {
type: "string",
nullable: true,
pattern: /^[a-zA-Z0-9\/\-*]+$/.toString().slice(1, -1)
},
origin: {
type: "string",
enum: [
"combined",
"local",
"remote"
],
default: "local"
},
hostname: {
type: "string",
nullable: true,
default: null,
description: "The local host is represented with `null`."
}
},
required: []
};
export default define(meta, paramDef, async (ps, me)=>{
const query = makePaginationQuery(DriveFiles.createQueryBuilder("file"), ps.sinceId, ps.untilId);
if (ps.userId) {
query.andWhere("file.userId = :userId", {
userId: ps.userId
});
} else {
if (ps.origin === "local") {
query.andWhere("file.userHost IS NULL");
} else if (ps.origin === "remote") {
query.andWhere("file.userHost IS NOT NULL");
}
if (ps.hostname) {
query.andWhere("file.userHost = :hostname", {
hostname: ps.hostname
});
}
}
if (ps.type) {
if (ps.type.endsWith("/*")) {
query.andWhere("file.type like :type", {
type: `${ps.type.replace("/*", "/")}%`
});
} else {
query.andWhere("file.type = :type", {
type: ps.type
});
}
}
const files = await query.take(ps.limit).getMany();
return await DriveFiles.packMany(files, {
detail: true,
withUser: true,
self: true
});
});
@@ -0,0 +1,227 @@
import { DriveFiles } from "../../../../../models/index.js";
import define from "../../../define.js";
import { ApiError } from "../../../error.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true,
errors: {
noSuchFile: {
message: "No such file.",
code: "NO_SUCH_FILE",
id: "caf3ca38-c6e5-472e-a30c-b05377dcc240"
}
},
res: {
type: "object",
optional: false,
nullable: false,
properties: {
id: {
type: "string",
optional: false,
nullable: false,
format: "id",
example: "xxxxxxxxxx"
},
createdAt: {
type: "string",
optional: false,
nullable: false,
format: "date-time"
},
userId: {
type: "string",
optional: false,
nullable: true,
format: "id",
example: "xxxxxxxxxx"
},
userHost: {
type: "string",
optional: false,
nullable: true,
description: "The local host is represented with `null`."
},
md5: {
type: "string",
optional: false,
nullable: false,
format: "md5",
example: "15eca7fba0480996e2245f5185bf39f2"
},
name: {
type: "string",
optional: false,
nullable: false,
example: "lenna.jpg"
},
type: {
type: "string",
optional: false,
nullable: false,
example: "image/jpeg"
},
size: {
type: "number",
optional: false,
nullable: false,
example: 51469
},
comment: {
type: "string",
optional: false,
nullable: true
},
blurhash: {
type: "string",
optional: false,
nullable: true
},
properties: {
type: "object",
optional: false,
nullable: false,
properties: {
width: {
type: "number",
optional: false,
nullable: false,
example: 1280
},
height: {
type: "number",
optional: false,
nullable: false,
example: 720
},
avgColor: {
type: "string",
optional: true,
nullable: false,
example: "rgb(40,65,87)"
}
}
},
storedInternal: {
type: "boolean",
optional: false,
nullable: true,
example: true
},
url: {
type: "string",
optional: false,
nullable: true,
format: "url"
},
thumbnailUrl: {
type: "string",
optional: false,
nullable: true,
format: "url"
},
webpublicUrl: {
type: "string",
optional: false,
nullable: true,
format: "url"
},
accessKey: {
type: "string",
optional: false,
nullable: false
},
thumbnailAccessKey: {
type: "string",
optional: false,
nullable: false
},
webpublicAccessKey: {
type: "string",
optional: false,
nullable: false
},
uri: {
type: "string",
optional: false,
nullable: true
},
src: {
type: "string",
optional: false,
nullable: true
},
folderId: {
type: "string",
optional: false,
nullable: true,
format: "id",
example: "xxxxxxxxxx"
},
isSensitive: {
type: "boolean",
optional: false,
nullable: false
},
isLink: {
type: "boolean",
optional: false,
nullable: false
}
}
}
};
export const paramDef = {
type: "object",
anyOf: [
{
properties: {
fileId: {
type: "string",
format: "misskey:id"
}
},
required: [
"fileId"
]
},
{
properties: {
url: {
type: "string"
}
},
required: [
"url"
]
}
]
};
export default define(meta, paramDef, async (ps, me)=>{
const file = ps.fileId ? await DriveFiles.findOneBy({
id: ps.fileId
}) : await DriveFiles.findOne({
where: [
{
url: ps.url
},
{
thumbnailUrl: ps.url
},
{
webpublicUrl: ps.url
}
]
});
if (file == null) {
throw new ApiError(meta.errors.noSuchFile);
}
if (!me.isAdmin) {
file.requestIp = undefined;
file.requestHeaders = undefined;
}
return file;
});