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,58 @@
import define from "../../../define.js";
import { genId } from "../../../../../misc/gen-id.js";
import { Webhooks } from "../../../../../models/index.js";
import { publishInternalEvent } from "../../../../../services/stream.js";
import { webhookEventTypes } from "../../../../../models/entities/webhook.js";
export const meta = {
tags: [
"webhooks"
],
requireCredential: true,
kind: "write:account"
};
export const paramDef = {
type: "object",
properties: {
name: {
type: "string",
minLength: 1,
maxLength: 100
},
url: {
type: "string",
minLength: 1,
maxLength: 1024
},
secret: {
type: "string",
minLength: 1,
maxLength: 1024
},
on: {
type: "array",
items: {
type: "string",
enum: webhookEventTypes
}
}
},
required: [
"name",
"url",
"secret",
"on"
]
};
export default define(meta, paramDef, async (ps, user)=>{
const webhook = await Webhooks.insert({
id: genId(),
createdAt: new Date(),
userId: user.id,
name: ps.name,
url: ps.url,
secret: ps.secret,
on: ps.on
}).then((x)=>Webhooks.findOneByOrFail(x.identifiers[0]));
publishInternalEvent("webhookCreated", webhook);
return webhook;
});
@@ -0,0 +1,41 @@
import define from "../../../define.js";
import { ApiError } from "../../../error.js";
import { Webhooks } from "../../../../../models/index.js";
import { publishInternalEvent } from "../../../../../services/stream.js";
export const meta = {
tags: [
"webhooks"
],
requireCredential: true,
kind: "write:account",
errors: {
noSuchWebhook: {
message: "No such webhook.",
code: "NO_SUCH_WEBHOOK",
id: "bae73e5a-5522-4965-ae19-3a8688e71d82"
}
}
};
export const paramDef = {
type: "object",
properties: {
webhookId: {
type: "string",
format: "misskey:id"
}
},
required: [
"webhookId"
]
};
export default define(meta, paramDef, async (ps, user)=>{
const webhook = await Webhooks.findOneBy({
id: ps.webhookId,
userId: user.id
});
if (webhook == null) {
throw new ApiError(meta.errors.noSuchWebhook);
}
await Webhooks.delete(webhook.id);
publishInternalEvent("webhookDeleted", webhook);
});
@@ -0,0 +1,21 @@
import define from "../../../define.js";
import { Webhooks } from "../../../../../models/index.js";
export const meta = {
tags: [
"webhooks",
"account"
],
requireCredential: true,
kind: "read:account"
};
export const paramDef = {
type: "object",
properties: {},
required: []
};
export default define(meta, paramDef, async (ps, me)=>{
const webhooks = await Webhooks.findBy({
userId: me.id
});
return webhooks;
});
@@ -0,0 +1,39 @@
import define from "../../../define.js";
import { ApiError } from "../../../error.js";
import { Webhooks } from "../../../../../models/index.js";
export const meta = {
tags: [
"webhooks"
],
requireCredential: true,
kind: "read:account",
errors: {
noSuchWebhook: {
message: "No such webhook.",
code: "NO_SUCH_WEBHOOK",
id: "50f614d9-3047-4f7e-90d8-ad6b2d5fb098"
}
}
};
export const paramDef = {
type: "object",
properties: {
webhookId: {
type: "string",
format: "misskey:id"
}
},
required: [
"webhookId"
]
};
export default define(meta, paramDef, async (ps, user)=>{
const webhook = await Webhooks.findOneBy({
id: ps.webhookId,
userId: user.id
});
if (webhook == null) {
throw new ApiError(meta.errors.noSuchWebhook);
}
return webhook;
});
@@ -0,0 +1,78 @@
import define from "../../../define.js";
import { ApiError } from "../../../error.js";
import { Webhooks } from "../../../../../models/index.js";
import { publishInternalEvent } from "../../../../../services/stream.js";
import { webhookEventTypes } from "../../../../../models/entities/webhook.js";
export const meta = {
tags: [
"webhooks"
],
requireCredential: true,
kind: "write:account",
errors: {
noSuchWebhook: {
message: "No such webhook.",
code: "NO_SUCH_WEBHOOK",
id: "fb0fea69-da18-45b1-828d-bd4fd1612518"
}
}
};
export const paramDef = {
type: "object",
properties: {
webhookId: {
type: "string",
format: "misskey:id"
},
name: {
type: "string",
minLength: 1,
maxLength: 100
},
url: {
type: "string",
minLength: 1,
maxLength: 1024
},
secret: {
type: "string",
minLength: 1,
maxLength: 1024
},
on: {
type: "array",
items: {
type: "string",
enum: webhookEventTypes
}
},
active: {
type: "boolean"
}
},
required: [
"webhookId",
"name",
"url",
"secret",
"on",
"active"
]
};
export default define(meta, paramDef, async (ps, user)=>{
const webhook = await Webhooks.findOneBy({
id: ps.webhookId,
userId: user.id
});
if (webhook == null) {
throw new ApiError(meta.errors.noSuchWebhook);
}
await Webhooks.update(webhook.id, {
name: ps.name,
url: ps.url,
secret: ps.secret,
on: ps.on,
active: ps.active
});
publishInternalEvent("webhookUpdated", webhook);
});