From cb8f1617c7e17e1eba013027d94f0dfdd5291a8b Mon Sep 17 00:00:00 2001 From: CaffeeLake Date: Mon, 5 Jun 2023 21:44:28 +0900 Subject: [PATCH 1/2] Fix: #10955 TypeError: JSON5.parse is not a function (#10956) * Fix: JSON5.parse is not a function * update changelog * update chglog --------- Co-authored-by: tamaina --- packages/backend/src/server/api/endpoints/meta.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index c603cb9acf..14256eb7bf 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -1,4 +1,4 @@ -import * as JSON5 from "json5"; +import JSON5 from "json5"; import { IsNull, MoreThan } from "typeorm"; import config from "@/config/index.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; From f621e58efa46ed7bf783609c85de4fd7b810ec02 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 6 Jun 2023 12:11:15 -0700 Subject: [PATCH 2/2] fix: post editing meta --- packages/backend/src/remote/activitypub/models/note.ts | 7 ++++++- packages/backend/src/server/api/endpoints/notes/edit.ts | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 3fff212433..c7a82a7203 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -52,7 +52,8 @@ import { UserProfiles } from "@/models/index.js"; import { In } from "typeorm"; import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; import { truncate } from "@/misc/truncate.js"; -import { type Size, getEmojiSize } from "@/misc/emoji-meta.js"; +import { type Size, getEmojiSize } from "@/misc/emoji-meta.js";\ +import { fetchMeta } from "@/misc/fetch-meta.js"; const logger = apLogger; @@ -544,6 +545,10 @@ function notEmpty(partial: Partial) { export async function updateNote(value: string | IObject, resolver?: Resolver) { const uri = typeof value === "string" ? value : value.id; if (!uri) throw new Error("Missing note uri"); + const instanceMeta = await fetchMeta(); + if (instanceMeta.experimentalFeatures?.postEdits === false) { + throw new Error("Post edits disabled."); + } // Skip if URI points to this server if (uri.startsWith(`${config.url}/`)) throw new Error("uri points local"); diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index 66db6f644f..28cfff6020 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -244,8 +244,9 @@ export default define(meta, paramDef, async (ps, user) => { if (user.movedToUri != null) throw new ApiError(meta.errors.accountLocked); const instanceMeta = await fetchMeta(); - if (instanceMeta.experimentalFeatures?.postImports === false) + if (instanceMeta.experimentalFeatures?.postEdits === false) { throw new ApiError(meta.errors.editsDisabled); + } if (!Users.isLocalUser(user)) { throw new ApiError(meta.errors.notLocalUser);