From eda82780de0a6619dfbd36ebed1900d836405748 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 16:19:13 -0700 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=E2=9C=A8=20searchFilters=20meta=20?= =?UTF-8?q?property?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/server/api/endpoints/meta.ts | 4 ++-- packages/backend/src/server/nodeinfo.ts | 3 +++ packages/client/src/scripts/search.ts | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 14256eb7bf..f6c978b2de 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -323,7 +323,7 @@ export const meta = { optional: false, nullable: false, }, - elasticsearch: { + searchFilters: { type: "boolean", optional: false, nullable: false, @@ -521,7 +521,7 @@ export default define(meta, paramDef, async (ps, me) => { recommendedTimeline: !instance.disableRecommendedTimeline, globalTimeLine: !instance.disableGlobalTimeline, emailRequiredForSignup: instance.emailRequiredForSignup, - elasticsearch: config.elasticsearch ? true : false, + searchFilters: config.meilisearch ? true : false, hcaptcha: instance.enableHcaptcha, recaptcha: instance.enableRecaptcha, objectStorage: instance.useObjectStorage, diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 2a0e1981a4..18e04f4209 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -82,6 +82,9 @@ const nodeinfo2 = async () => { disableRecommendedTimeline: meta.disableRecommendedTimeline, disableGlobalTimeline: meta.disableGlobalTimeline, emailRequiredForSignup: meta.emailRequiredForSignup, + searchFilters: config.meilisearch ? true : false, + postEditing: meta.experimentalFeatures?.postEditing || false, + postImports: meta.experimentalFeatures?.postImports || false, enableHcaptcha: meta.enableHcaptcha, enableRecaptcha: meta.enableRecaptcha, maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, diff --git a/packages/client/src/scripts/search.ts b/packages/client/src/scripts/search.ts index 03f61f1f0b..a0382532f6 100644 --- a/packages/client/src/scripts/search.ts +++ b/packages/client/src/scripts/search.ts @@ -1,6 +1,7 @@ import * as os from "@/os"; import { i18n } from "@/i18n"; import { mainRouter } from "@/router"; +// import { instance } from "@/instance"; export async function search() { // const searchOptions = @@ -14,6 +15,8 @@ export async function search() { // "filter:following => show results only from users you follow\n" + // "filter:followers => show results only from followers\n"; + // const searchFiltersAvailable = instance.searchFilters; + const { canceled, result: query } = await os.inputText({ title: i18n.ts.search, placeholder: i18n.ts.searchPlaceholder, From 71d4f5d5162cf1767b64f9b1c130a552ef40dec6 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 16:54:41 -0700 Subject: [PATCH 2/8] chore: update patrons --- patrons.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/patrons.json b/patrons.json index cd20886f6e..d5e039696c 100644 --- a/patrons.json +++ b/patrons.json @@ -47,6 +47,11 @@ "@natalie@prismst.one", "@KelsonV@wandering.shop", "@breakfastmtn@calckey.social", + "@richardazia@mastodon.social", + "@joestone@calckey.social", + "@aj@calckey.social", + "@zepfanman@ramblingreaders.org", + "@kimby@stop.voring.me", "\nInterkosmos Link" ] } From 0c5be99d77c807a7e8c4f0868f3fbd413f15185a Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 18:47:06 -0700 Subject: [PATCH 3/8] perf: limit number of antennas --- .../src/server/api/endpoints/antennas/create.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index c1ba7bcdfd..a25b32b404 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -23,6 +23,12 @@ export const meta = { code: "NO_SUCH_USER_GROUP", id: "aa3c0b9a-8cae-47c0-92ac-202ce5906682", }, + + tooManyAntennas: { + message: "Too many antennas.", + code: "TOO_MANY_ANTENNAS", + id: "c3a5a51e-04d4-11ee-be56-0242ac120002", + }, }, res: { @@ -97,6 +103,14 @@ export default define(meta, paramDef, async (ps, user) => { let userList; let userGroupJoining; + const antennas = await Antennas.findBy({ + userId: user.id, + }); + if (antennas.length > 5 && !user.isAdmin) { + throw new ApiError(meta.errors.tooManyAntennas) + } + + if (ps.src === "list" && ps.userListId) { userList = await UserLists.findOneBy({ id: ps.userListId, From 23d59b634ba8d4dcdbd3ddc1664918a52d2c51ec Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 19:08:41 -0700 Subject: [PATCH 4/8] fix: only show meili in metrics if available --- packages/client/src/widgets/server-metric/index.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/client/src/widgets/server-metric/index.vue b/packages/client/src/widgets/server-metric/index.vue index 1eb9f56b8a..b44cca714a 100644 --- a/packages/client/src/widgets/server-metric/index.vue +++ b/packages/client/src/widgets/server-metric/index.vue @@ -39,7 +39,7 @@ :meta="meta" /> @@ -67,6 +67,7 @@ import { GetFormResultType } from "@/scripts/form"; import * as os from "@/os"; import { stream } from "@/stream"; import { i18n } from "@/i18n"; +import { instance } from "@/instance"; const name = "serverMetric"; From abe84748833a00ef399e7a38781b9e599ff03b9b Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 19:10:43 -0700 Subject: [PATCH 5/8] fix server metric iteration --- packages/client/src/widgets/server-metric/index.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/client/src/widgets/server-metric/index.vue b/packages/client/src/widgets/server-metric/index.vue index b44cca714a..8ecdeb1965 100644 --- a/packages/client/src/widgets/server-metric/index.vue +++ b/packages/client/src/widgets/server-metric/index.vue @@ -109,7 +109,10 @@ os.api("server-info", {}).then((res) => { }); const toggleView = () => { - if (widgetProps.view === 5) { + if ( + (widgetProps.view === 5 && instance.searchFilters) || + (widgetProps.view === 4 && !instance.searchFilters) + ) { widgetProps.view = 0; } else { widgetProps.view++; From 90c0e4e9ed7f44ec2530aa2df3ea5128e7f83636 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 21:00:16 -0700 Subject: [PATCH 6/8] allow iframes for notes --- packages/backend/src/server/api/endpoints/antennas/create.ts | 3 +-- packages/backend/src/server/web/index.ts | 4 ++++ rome.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index a25b32b404..f69501ae20 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -107,10 +107,9 @@ export default define(meta, paramDef, async (ps, user) => { userId: user.id, }); if (antennas.length > 5 && !user.isAdmin) { - throw new ApiError(meta.errors.tooManyAntennas) + throw new ApiError(meta.errors.tooManyAntennas); } - if (ps.src === "list" && ps.userListId) { userList = await UserLists.findOneBy({ id: ps.userListId, diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 0d4034f55d..c876635a3c 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -422,6 +422,10 @@ router.get("/notes/:note", async (ctx, next) => { }); ctx.set("Cache-Control", "public, max-age=15"); + ctx.set( + "Content-Security-Policy", + "default-src 'self'; frame-ancestors '*'", + ); return; } diff --git a/rome.json b/rome.json index 09db5f75e2..37d738b553 100644 --- a/rome.json +++ b/rome.json @@ -13,7 +13,7 @@ "packages/*/package-lock.json", "packages/backend/src/server/web/manifest.ts", "packages/backend/built/", - "packages/backend/nsfw-model/", + "*/model.json", "packages/client/src/emojilist.json", "*.md", "**/tsconfig.json", From ca5ae3a4c97052de7617d233494f65b2b0d6f229 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 21:01:28 -0700 Subject: [PATCH 7/8] chore: lint sw --- packages/sw/src/scripts/create-notification.ts | 8 +++++--- packages/sw/src/scripts/lang.ts | 4 ++-- packages/sw/src/scripts/notification-read.ts | 2 +- packages/sw/src/scripts/operations.ts | 2 +- packages/sw/src/sw.ts | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts index 01b9ab5888..03ce2a60d5 100644 --- a/packages/sw/src/scripts/create-notification.ts +++ b/packages/sw/src/scripts/create-notification.ts @@ -1,7 +1,7 @@ /* * Notification manager for SW */ -declare var self: ServiceWorkerGlobalScope; +declare let self: ServiceWorkerGlobalScope; import { swLang } from "@/scripts/lang"; import { cli } from "@/scripts/operations"; @@ -45,7 +45,7 @@ async function composeNotification( */ case "notification": switch (data.body.type) { - case "follow": + case "follow": { // users/showの型定義をswos.apiへ当てはめるのが困難なのでapiFetch.requestを直接使用 const account = await getAccountFromId(data.userId); if (!account) return null; @@ -71,6 +71,7 @@ async function composeNotification( ], }, ]; + } case "mention": return [ @@ -157,7 +158,7 @@ async function composeNotification( }, ]; - case "reaction": + case "reaction": { let reaction = data.body.reaction; let badge: string | undefined; @@ -214,6 +215,7 @@ async function composeNotification( ], }, ]; + } case "pollVote": return [ diff --git a/packages/sw/src/scripts/lang.ts b/packages/sw/src/scripts/lang.ts index da4f315266..31cfb7bd3e 100644 --- a/packages/sw/src/scripts/lang.ts +++ b/packages/sw/src/scripts/lang.ts @@ -1,7 +1,7 @@ /* * Language manager for SW */ -declare var self: ServiceWorkerGlobalScope; +declare let self: ServiceWorkerGlobalScope; import { get, set } from "idb-keyval"; import { I18n } from "@/scripts/i18n"; @@ -23,7 +23,7 @@ class SwLang { public i18n: Promise> | null = null; public fetchLocale() { - return (this.i18n = this._fetch()); + return this.i18n === this._fetch(); } private async _fetch() { diff --git a/packages/sw/src/scripts/notification-read.ts b/packages/sw/src/scripts/notification-read.ts index 5b2030d989..9ea4528776 100644 --- a/packages/sw/src/scripts/notification-read.ts +++ b/packages/sw/src/scripts/notification-read.ts @@ -1,4 +1,4 @@ -declare var self: ServiceWorkerGlobalScope; +declare let self: ServiceWorkerGlobalScope; import { get } from "idb-keyval"; import { pushNotificationDataMap } from "@/types"; diff --git a/packages/sw/src/scripts/operations.ts b/packages/sw/src/scripts/operations.ts index a192a9bd7e..ae76d6ecff 100644 --- a/packages/sw/src/scripts/operations.ts +++ b/packages/sw/src/scripts/operations.ts @@ -2,7 +2,7 @@ * Operations * 各種操作 */ -declare var self: ServiceWorkerGlobalScope; +declare let self: ServiceWorkerGlobalScope; import * as Misskey from "calckey-js"; import { SwMessage, swMessageOrderType } from "@/types"; diff --git a/packages/sw/src/sw.ts b/packages/sw/src/sw.ts index 0733400fc3..74603d67ca 100644 --- a/packages/sw/src/sw.ts +++ b/packages/sw/src/sw.ts @@ -1,4 +1,4 @@ -declare var self: ServiceWorkerGlobalScope; +declare let self: ServiceWorkerGlobalScope; import { createEmptyNotification, From e13af49118443be8d88089c87aa56c19e234830e Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 21:02:02 -0700 Subject: [PATCH 8/8] dont lint in format --- packages/sw/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sw/package.json b/packages/sw/package.json index f64bbfd0a4..001803825a 100644 --- a/packages/sw/package.json +++ b/packages/sw/package.json @@ -5,7 +5,7 @@ "build": "webpack", "watch": "pnpm swc src -d built -D -w", "lint": "pnpm rome check \"src/**/*.ts\"", - "format": "pnpm rome format * --write && pnpm rome check --apply *" + "format": "pnpm rome format * --write" }, "devDependencies": { "@swc/cli": "^0.1.62",