diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index ab7efe100e..40243a7fd6 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -5,10 +5,6 @@ import * as ep___admin_abuseUserReports from "./endpoints/admin/abuse-user-repor import * as ep___admin_accounts_create from "./endpoints/admin/accounts/create.js"; import * as ep___admin_accounts_delete from "./endpoints/admin/accounts/delete.js"; import * as ep___admin_accounts_hosted from "./endpoints/admin/accounts/hosted.js"; -import * as ep___admin_ad_create from "./endpoints/admin/ad/create.js"; -import * as ep___admin_ad_delete from "./endpoints/admin/ad/delete.js"; -import * as ep___admin_ad_list from "./endpoints/admin/ad/list.js"; -import * as ep___admin_ad_update from "./endpoints/admin/ad/update.js"; import * as ep___admin_announcements_create from "./endpoints/admin/announcements/create.js"; import * as ep___admin_announcements_delete from "./endpoints/admin/announcements/delete.js"; import * as ep___admin_announcements_list from "./endpoints/admin/announcements/list.js"; @@ -331,10 +327,6 @@ const eps = [ ["admin/accounts/create", ep___admin_accounts_create], ["admin/accounts/delete", ep___admin_accounts_delete], ["admin/accounts/hosted", ep___admin_accounts_hosted], - ["admin/ad/create", ep___admin_ad_create], - ["admin/ad/delete", ep___admin_ad_delete], - ["admin/ad/list", ep___admin_ad_list], - ["admin/ad/update", ep___admin_ad_update], ["admin/announcements/create", ep___admin_announcements_create], ["admin/announcements/delete", ep___admin_announcements_delete], ["admin/announcements/list", ep___admin_announcements_list], diff --git a/packages/backend/src/server/api/endpoints/admin/ad/create.ts b/packages/backend/src/server/api/endpoints/admin/ad/create.ts deleted file mode 100644 index db39f3eb27..0000000000 --- a/packages/backend/src/server/api/endpoints/admin/ad/create.ts +++ /dev/null @@ -1,46 +0,0 @@ -import define from "../../../define.js"; -import { Ads } from "@/models/index.js"; -import { genId } from "@/misc/gen-id.js"; - -export const meta = { - tags: ["admin"], - - requireCredential: true, - requireModerator: true, -} as const; - -export const paramDef = { - type: "object", - properties: { - url: { type: "string", minLength: 1 }, - memo: { type: "string" }, - place: { type: "string" }, - priority: { type: "string" }, - ratio: { type: "integer" }, - expiresAt: { type: "integer" }, - imageUrl: { type: "string", minLength: 1 }, - }, - required: [ - "url", - "memo", - "place", - "priority", - "ratio", - "expiresAt", - "imageUrl", - ], -} as const; - -export default define(meta, paramDef, async (ps) => { - await Ads.insert({ - id: genId(), - createdAt: new Date(), - expiresAt: new Date(ps.expiresAt), - url: ps.url, - imageUrl: ps.imageUrl, - priority: ps.priority, - ratio: ps.ratio, - place: ps.place, - memo: ps.memo, - }); -}); diff --git a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts b/packages/backend/src/server/api/endpoints/admin/ad/delete.ts deleted file mode 100644 index ee6d314de7..0000000000 --- a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts +++ /dev/null @@ -1,34 +0,0 @@ -import define from "../../../define.js"; -import { Ads } from "@/models/index.js"; -import { ApiError } from "../../../error.js"; - -export const meta = { - tags: ["admin"], - - requireCredential: true, - requireModerator: true, - - errors: { - noSuchAd: { - message: "No such ad.", - code: "NO_SUCH_AD", - id: "ccac9863-3a03-416e-b899-8a64041118b1", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - id: { type: "string", format: "misskey:id" }, - }, - required: ["id"], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - const ad = await Ads.findOneBy({ id: ps.id }); - - if (ad == null) throw new ApiError(meta.errors.noSuchAd); - - await Ads.delete(ad.id); -}); diff --git a/packages/backend/src/server/api/endpoints/admin/ad/list.ts b/packages/backend/src/server/api/endpoints/admin/ad/list.ts deleted file mode 100644 index 65944d31e9..0000000000 --- a/packages/backend/src/server/api/endpoints/admin/ad/list.ts +++ /dev/null @@ -1,32 +0,0 @@ -import define from "../../../define.js"; -import { Ads } from "@/models/index.js"; -import { makePaginationQuery } from "../../../common/make-pagination-query.js"; - -export const meta = { - tags: ["admin"], - - requireCredential: true, - requireModerator: true, -} as const; - -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: [], -} as const; - -export default define(meta, paramDef, async (ps) => { - const query = makePaginationQuery( - Ads.createQueryBuilder("ad"), - ps.sinceId, - ps.untilId, - ).andWhere("ad.expiresAt > :now", { now: new Date() }); - - const ads = await query.take(ps.limit).getMany(); - - return ads; -}); diff --git a/packages/backend/src/server/api/endpoints/admin/ad/update.ts b/packages/backend/src/server/api/endpoints/admin/ad/update.ts deleted file mode 100644 index 2c70387310..0000000000 --- a/packages/backend/src/server/api/endpoints/admin/ad/update.ts +++ /dev/null @@ -1,58 +0,0 @@ -import define from "../../../define.js"; -import { Ads } from "@/models/index.js"; -import { ApiError } from "../../../error.js"; - -export const meta = { - tags: ["admin"], - - requireCredential: true, - requireModerator: true, - - errors: { - noSuchAd: { - message: "No such ad.", - code: "NO_SUCH_AD", - id: "b7aa1727-1354-47bc-a182-3a9c3973d300", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - id: { type: "string", format: "misskey:id" }, - memo: { type: "string" }, - url: { type: "string", minLength: 1 }, - imageUrl: { type: "string", minLength: 1 }, - place: { type: "string" }, - priority: { type: "string" }, - ratio: { type: "integer" }, - expiresAt: { type: "integer" }, - }, - required: [ - "id", - "memo", - "url", - "imageUrl", - "place", - "priority", - "ratio", - "expiresAt", - ], -} as const; - -export default define(meta, paramDef, async (ps, me) => { - const ad = await Ads.findOneBy({ id: ps.id }); - - if (ad == null) throw new ApiError(meta.errors.noSuchAd); - - await Ads.update(ad.id, { - url: ps.url, - place: ps.place, - priority: ps.priority, - ratio: ps.ratio, - memo: ps.memo, - imageUrl: ps.imageUrl, - expiresAt: new Date(ps.expiresAt), - }); -});