diff --git a/packages/backend/src/server/api/mastodon/converters.ts b/packages/backend/src/server/api/mastodon/converters.ts index ff0b7b654..3ff84327f 100644 --- a/packages/backend/src/server/api/mastodon/converters.ts +++ b/packages/backend/src/server/api/mastodon/converters.ts @@ -19,10 +19,6 @@ export function convertAttachmentId(attachment: MastodonEntity.Attachment) { return simpleConvertId(attachment); } -export function convertFilterId(filter: MastodonEntity.Filter) { - return simpleConvertId(filter); -} - export function convertListId(list: MastodonEntity.List) { return simpleConvertId(list); } diff --git a/packages/backend/src/server/api/mastodon/endpoints/filter.ts b/packages/backend/src/server/api/mastodon/endpoints/filter.ts index e90f007fa..a788eb7fd 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/filter.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/filter.ts @@ -1,89 +1,11 @@ import Router from "@koa/router"; -import { getClient } from "../index.js"; -import { convertId, IdType } from "../../index.js"; -import { convertFilterId } from "../converters.js"; export function setupEndpointsFilter(router: Router): void { - router.get("/v1/filters", async (ctx) => { - const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; - const accessTokens = ctx.request.headers.authorization; - const client = getClient(BASE_URL, accessTokens); - const body: any = ctx.request.body; - try { - const data = await client.getFilters(); - ctx.body = data.data.map((filter) => convertFilterId(filter)); - } catch (e: any) { - console.error(e); - ctx.status = 401; - ctx.body = e.response.data; - } + router.get(["/v1/filters", "/v2/filters"], async (ctx) => { + ctx.body = []; }); - - router.get("/v1/filters/:id", async (ctx) => { - const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; - const accessTokens = ctx.request.headers.authorization; - const client = getClient(BASE_URL, accessTokens); - const body: any = ctx.request.body; - try { - const data = await client.getFilter( - convertId(ctx.params.id, IdType.IceshrimpId), - ); - ctx.body = convertFilterId(data.data); - } catch (e: any) { - console.error(e); - ctx.status = 401; - ctx.body = e.response.data; - } - }); - - router.post("/v1/filters", async (ctx) => { - const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; - const accessTokens = ctx.request.headers.authorization; - const client = getClient(BASE_URL, accessTokens); - const body: any = ctx.request.body; - try { - const data = await client.createFilter(body.phrase, body.context, body); - ctx.body = convertFilterId(data.data); - } catch (e: any) { - console.error(e); - ctx.status = 401; - ctx.body = e.response.data; - } - }); - - router.post("/v1/filters/:id", async (ctx) => { - const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; - const accessTokens = ctx.request.headers.authorization; - const client = getClient(BASE_URL, accessTokens); - const body: any = ctx.request.body; - try { - const data = await client.updateFilter( - convertId(ctx.params.id, IdType.IceshrimpId), - body.phrase, - body.context, - ); - ctx.body = convertFilterId(data.data); - } catch (e: any) { - console.error(e); - ctx.status = 401; - ctx.body = e.response.data; - } - }); - - router.delete("/v1/filters/:id", async (ctx) => { - const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; - const accessTokens = ctx.request.headers.authorization; - const client = getClient(BASE_URL, accessTokens); - const body: any = ctx.request.body; - try { - const data = await client.deleteFilter( - convertId(ctx.params.id, IdType.IceshrimpId), - ); - ctx.body = data.data; - } catch (e: any) { - console.error(e); - ctx.status = 401; - ctx.body = e.response.data; - } + router.post(["/v1/filters", "/v2/filters"], async (ctx) => { + ctx.status = 400; + ctx.body = { error: "Please change word mute settings in the web frontend settings." }; }); } diff --git a/packages/backend/src/server/api/mastodon/endpoints/misc.ts b/packages/backend/src/server/api/mastodon/endpoints/misc.ts index 52c8a1a5c..5e157c0cd 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/misc.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/misc.ts @@ -1,10 +1,7 @@ import Router from "@koa/router"; import { getClient } from "@/server/api/mastodon/index.js"; import { convertId, IdType } from "@/misc/convert-id.js"; -import { convertAccountId, convertAnnouncementId, convertFilterId } from "@/server/api/mastodon/converters.js"; -import { Users } from "@/models/index.js"; -import { getInstance } from "@/server/api/mastodon/endpoints/meta.js"; -import { IsNull } from "typeorm"; +import { convertAnnouncementId } from "@/server/api/mastodon/converters.js"; import { MiscHelpers } from "@/server/api/mastodon/helpers/misc.js"; export function setupEndpointsMisc(router: Router): void { @@ -67,21 +64,6 @@ export function setupEndpointsMisc(router: Router): void { }, ); - router.get("/v1/filters", async (ctx) => { - const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; - const accessTokens = ctx.request.headers.authorization; - const client = getClient(BASE_URL, accessTokens); // we are using this here, because in private mode some info isnt - // displayed without being logged in - try { - const data = await client.getFilters(); - ctx.body = data.data.map((filter) => convertFilterId(filter)); - } catch (e: any) { - console.error(e); - ctx.status = 401; - ctx.body = e.response.data; - } - }); - router.get("/v1/trends", async (ctx) => { const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`; const accessTokens = ctx.request.headers.authorization;