From 4422bf6286ee335a04a31cafa429c2c73d790f45 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Tue, 4 Mar 2025 13:20:29 +0900 Subject: [PATCH] fix: handle v2 instance property correctly for mastodon v4.2 or lower (#3224) --- server/utils/shared.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/utils/shared.ts b/server/utils/shared.ts index 2e28a235..4ce64473 100644 --- a/server/utils/shared.ts +++ b/server/utils/shared.ts @@ -73,13 +73,15 @@ async function fetchAppInfo(origin: string, server: string) { .catch(() => null), ]) + // vapid.public_key prop is only available on Mastodon v4.3+ + const v2InstanceVapidKey: string | undefined = v2Instance?.configuration?.vapid?.public_key const app: AppInfo = { ...apps, // prefer vapid key from `/api/v2/instance` if available // since `vapid_key` from `/api/v1/apps` was deprecated on Mastodon v4.3.0+ // ref. apps API methods - Mastodon documentation // - https://docs.joinmastodon.org/methods/apps/#create - ...v2Instance ? { vapid_key: v2Instance.configuration.vapid.public_key } : {}, + ...v2InstanceVapidKey ? { vapid_key: v2InstanceVapidKey } : {}, } return app