[backend] Remove /api/i/get-unsecure endpoint

This commit is contained in:
Laura Hausmann 2023-10-04 23:14:57 +02:00
parent ad7c58b8d7
commit f87712040d
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 0 additions and 52 deletions

View file

@ -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],

View file

@ -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;
});