From f87712040d5848968728ca4aed5e7926c913e40a Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 4 Oct 2023 23:14:57 +0200 Subject: [PATCH] [backend] Remove /api/i/get-unsecure endpoint --- packages/backend/src/server/api/endpoints.ts | 2 - .../api/endpoints/i/registry/get-unsecure.ts | 50 ------------------- 2 files changed, 52 deletions(-) delete mode 100644 packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index bb34e1a5e..c42bdde5d 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -201,7 +201,6 @@ import * as ep___i_readAnnouncement from "./endpoints/i/read-announcement.js"; import * as ep___i_regenerateToken from "./endpoints/i/regenerate-token.js"; import * as ep___i_registry_getAll from "./endpoints/i/registry/get-all.js"; import * as ep___i_registry_getDetail from "./endpoints/i/registry/get-detail.js"; -import * as ep___i_registry_getUnsecure from "./endpoints/i/registry/get-unsecure.js"; import * as ep___i_registry_get from "./endpoints/i/registry/get.js"; import * as ep___i_registry_keysWithType from "./endpoints/i/registry/keys-with-type.js"; import * as ep___i_registry_keys from "./endpoints/i/registry/keys.js"; @@ -551,7 +550,6 @@ const eps = [ ["i/regenerate-token", ep___i_regenerateToken], ["i/registry/get-all", ep___i_registry_getAll], ["i/registry/get-detail", ep___i_registry_getDetail], - ["i/registry/get-unsecure", ep___i_registry_getUnsecure], ["i/registry/get", ep___i_registry_get], ["i/registry/keys-with-type", ep___i_registry_keysWithType], ["i/registry/keys", ep___i_registry_keys], diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts b/packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts deleted file mode 100644 index a9bcf6935..000000000 --- a/packages/backend/src/server/api/endpoints/i/registry/get-unsecure.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { ApiError } from "../../../error.js"; -import define from "../../../define.js"; -import { RegistryItems } from "@/models/index.js"; - -export const meta = { - requireCredential: true, - - secure: false, - - errors: { - noSuchKey: { - message: "No such key.", - code: "NO_SUCH_KEY", - id: "ac3ed68a-62f0-422b-a7bc-d5e09e8f6a6a", - }, - }, -} as const; - -export const paramDef = { - type: "object", - properties: { - key: { type: "string" }, - scope: { - type: "array", - default: [], - items: { - type: "string", - pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1), - }, - }, - }, - required: ["key"], -} as const; - -export default define(meta, paramDef, async (ps, user) => { - if (ps.key !== "reactions" && ps.key !== "defaultNoteVisibility") return; - const query = RegistryItems.createQueryBuilder("item") - .where("item.domain IS NULL") - .andWhere("item.userId = :userId", { userId: user.id }) - .andWhere("item.key = :key", { key: ps.key }) - .andWhere("item.scope = :scope", { scope: ps.scope }); - - const item = await query.getOne(); - - if (item == null) { - throw new ApiError(meta.errors.noSuchKey); - } - - return item.value; -});