diff --git a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts index cc60a8db9b..9a690e19f0 100644 --- a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts +++ b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts @@ -54,7 +54,7 @@ export function apiMastodonCompatible(router: Router): void { // displayed without being logged in try { const data = await client.getInstance(); - ctx.body = getInstance(data.data); + ctx.body = await getInstance(data.data); } catch (e: any) { console.error(e); ctx.status = 401; diff --git a/packages/backend/src/server/api/mastodon/endpoints/meta.ts b/packages/backend/src/server/api/mastodon/endpoints/meta.ts index a67edc5b2f..5fba6f8a63 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/meta.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/meta.ts @@ -1,6 +1,9 @@ import { Entity } from "@calckey/megalodon"; +import { fetchMeta } from "@/misc/fetch-meta.js"; + // TODO: add calckey features -export function getInstance(response: Entity.Instance) { +export async function getInstance(response: Entity.Instance) { + const meta = await fetchMeta(true); return { uri: response.uri, title: response.title || "", @@ -11,8 +14,8 @@ export function getInstance(response: Entity.Instance) { urls: response.urls, stats: response.stats, thumbnail: response.thumbnail || "", - languages: ["en", "de", "ja"], - registrations: response.registrations, + languages: meta.langs, + registrations: !meta.disableRegistration || response.registrations, approval_required: !response.registrations, invites_enabled: response.registrations, configuration: { @@ -77,17 +80,17 @@ export function getInstance(response: Entity.Instance) { bot: true, discoverable: false, group: false, - created_at: "1971-01-01T00:00:00.000Z", - note: "", - url: "https://http.cat/404", - avatar: "https://http.cat/404", - avatar_static: "https://http.cat/404", + created_at: Math.floor(new Date().getTime() / 1000), + note: "Please refer to the original instance for the actual admin contact.", + url: "/", + avatar: "/static-assets/badges/info.png", + avatar_static: "/static-assets/badges/info.png", header: "https://http.cat/404", header_static: "https://http.cat/404", followers_count: -1, following_count: 0, statuses_count: 0, - last_status_at: "1971-01-01T00:00:00.000Z", + last_status_at: Math.floor(new Date().getTime() / 1000), noindex: true, emojis: [], fields: [], diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index 2be79c73a7..a72ac2c7e0 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -404,7 +404,7 @@ async function getFirstReaction( ) { const accessTokenArr = accessTokens?.split(" ") ?? [null]; const accessToken = accessTokenArr[accessTokenArr.length - 1]; - let react = "👍"; + let react = "⭐"; try { const api = await axios.post(`${BASE_URL}/api/i/registry/get-unsecure`, { scope: ["client", "base"], @@ -412,7 +412,7 @@ async function getFirstReaction( i: accessToken, }); const reactRaw = api.data; - react = Array.isArray(reactRaw) ? api.data[0] : "👍"; + react = Array.isArray(reactRaw) ? api.data[0] : "⭐"; console.log(api.data); return react; } catch (e) { @@ -426,16 +426,16 @@ export function statusModel( emojis: MastodonEntity.Emoji[], content: string, ) { - const now = "1970-01-02T00:00:00.000Z"; + const now = Math.floor(new Date().getTime() / 1000); return { id: "9atm5frjhb", uri: "https://http.cat/404", // "" url: "https://http.cat/404", // "", account: { id: "9arzuvv0sw", - username: "ReactionBot", - acct: "ReactionBot", - display_name: "ReactionsToThisPost", + username: "Reactions", + acct: "Reactions", + display_name: "Reactions to this post", locked: false, created_at: now, followers_count: 0, @@ -443,8 +443,8 @@ export function statusModel( statuses_count: 0, note: "", url: "https://http.cat/404", - avatar: "https://http.cat/404", - avatar_static: "https://http.cat/404", + avatar: "/static-assets/badges/info.png", + avatar_static: "/static-assets/badges/info.png", header: "https://http.cat/404", // "" header_static: "https://http.cat/404", // "" emojis: [],