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,108 @@
import define from "../../../define.js";
import { Announcements } from "../../../../../models/index.js";
import { genId } from "../../../../../misc/gen-id.js";
import { publishBroadcastStream } from "../../../../../services/stream.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true,
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"
},
updatedAt: {
type: "string",
optional: false,
nullable: true,
format: "date-time"
},
title: {
type: "string",
optional: false,
nullable: false
},
text: {
type: "string",
optional: false,
nullable: false
},
imageUrl: {
type: "string",
optional: false,
nullable: true
},
showPopup: {
type: "boolean",
optional: true,
nullable: false
},
isGoodNews: {
type: "boolean",
optional: true,
nullable: false
}
}
}
};
export const paramDef = {
type: "object",
properties: {
title: {
type: "string",
minLength: 1
},
text: {
type: "string",
minLength: 1
},
imageUrl: {
type: "string",
nullable: true,
minLength: 1
},
showPopup: {
type: "boolean"
},
isGoodNews: {
type: "boolean"
}
},
required: [
"title",
"text",
"imageUrl"
]
};
export default define(meta, paramDef, async (ps)=>{
const announcement = await Announcements.insert({
id: genId(),
createdAt: new Date(),
updatedAt: null,
title: ps.title,
text: ps.text,
imageUrl: ps.imageUrl,
showPopup: ps.showPopup ?? false,
isGoodNews: ps.isGoodNews ?? false
}).then((x)=>Announcements.findOneByOrFail(x.identifiers[0]));
publishBroadcastStream("announcementAdded", announcement);
return Object.assign({}, announcement, {
createdAt: announcement.createdAt.toISOString(),
updatedAt: null
});
});
@@ -0,0 +1,38 @@
import define from "../../../define.js";
import { Announcements } from "../../../../../models/index.js";
import { ApiError } from "../../../error.js";
import { publishBroadcastStream } from "../../../../../services/stream.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true,
errors: {
noSuchAnnouncement: {
message: "No such announcement.",
code: "NO_SUCH_ANNOUNCEMENT",
id: "ecad8040-a276-4e85-bda9-015a708d291e"
}
}
};
export const paramDef = {
type: "object",
properties: {
id: {
type: "string",
format: "misskey:id"
}
},
required: [
"id"
]
};
export default define(meta, paramDef, async (ps, me)=>{
const announcement = await Announcements.findOneBy({
id: ps.id
});
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
publishBroadcastStream("announcementDeleted", announcement.id);
await Announcements.delete(announcement.id);
});
@@ -0,0 +1,112 @@
import { Announcements, AnnouncementReads } from "../../../../../models/index.js";
import define from "../../../define.js";
import { makePaginationQuery } from "../../../common/make-pagination-query.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true,
res: {
type: "array",
optional: false,
nullable: false,
items: {
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"
},
updatedAt: {
type: "string",
optional: false,
nullable: true,
format: "date-time"
},
text: {
type: "string",
optional: false,
nullable: false
},
title: {
type: "string",
optional: false,
nullable: false
},
imageUrl: {
type: "string",
optional: false,
nullable: true
},
reads: {
type: "number",
optional: false,
nullable: false
},
showPopup: {
type: "boolean",
optional: true,
nullable: false
},
isGoodNews: {
type: "boolean",
optional: true,
nullable: false
}
}
}
}
};
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"
}
},
required: []
};
export default define(meta, paramDef, async (ps)=>{
const query = makePaginationQuery(Announcements.createQueryBuilder("announcement"), ps.sinceId, ps.untilId);
const announcements = await query.take(ps.limit).getMany();
const reads = new Map();
for (const announcement of announcements){
reads.set(announcement, await AnnouncementReads.countBy({
announcementId: announcement.id
}));
}
return announcements.map((announcement)=>({
id: announcement.id,
createdAt: announcement.createdAt.toISOString(),
updatedAt: announcement.updatedAt?.toISOString() ?? null,
title: announcement.title,
text: announcement.text,
imageUrl: announcement.imageUrl,
reads: reads.get(announcement),
showPopup: announcement.showPopup,
isGoodNews: announcement.isGoodNews
}));
});
@@ -0,0 +1,65 @@
import define from "../../../define.js";
import { Announcements } from "../../../../../models/index.js";
import { ApiError } from "../../../error.js";
export const meta = {
tags: [
"admin"
],
requireCredential: true,
requireModerator: true,
errors: {
noSuchAnnouncement: {
message: "No such announcement.",
code: "NO_SUCH_ANNOUNCEMENT",
id: "d3aae5a7-6372-4cb4-b61c-f511ffc2d7cc"
}
}
};
export const paramDef = {
type: "object",
properties: {
id: {
type: "string",
format: "misskey:id"
},
title: {
type: "string",
minLength: 1
},
text: {
type: "string",
minLength: 1
},
imageUrl: {
type: "string",
nullable: true,
minLength: 1
},
showPopup: {
type: "boolean"
},
isGoodNews: {
type: "boolean"
}
},
required: [
"id",
"title",
"text",
"imageUrl"
]
};
export default define(meta, paramDef, async (ps, me)=>{
const announcement = await Announcements.findOneBy({
id: ps.id
});
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
await Announcements.update(announcement.id, {
updatedAt: new Date(),
title: ps.title,
text: ps.text,
imageUrl: ps.imageUrl,
showPopup: ps.showPopup ?? false,
isGoodNews: ps.isGoodNews ?? false
});
});