From 45dee962191265134b3cbae9d1bf086c8c5e0685 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 7 Jun 2024 10:01:08 -0500 Subject: [PATCH] Support `language` param with L tags --- src/controllers/api/statuses.ts | 5 +++++ src/views/mastodon/statuses.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index b5ecf01e..ce4cbfa9 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -104,6 +104,11 @@ const createStatusController: AppController = async (c) => { tags.push(['subject', data.spoiler_text]); } + if (data.language) { + tags.push(['L', 'ISO-639-1']); + tags.push(['l', data.language, 'ISO-639-1']); + } + const media = data.media_ids?.length ? await getUnattachedMediaByIds(kysely, data.media_ids) : []; const imeta: string[][] = media.map(({ data }) => { diff --git a/src/views/mastodon/statuses.ts b/src/views/mastodon/statuses.ts index 04039da9..ed14c8e3 100644 --- a/src/views/mastodon/statuses.ts +++ b/src/views/mastodon/statuses.ts @@ -100,7 +100,7 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise< sensitive: !!cw, spoiler_text: (cw ? cw[1] : subject?.[1]) || '', visibility: 'public', - language: event.tags.find((tag) => tag[0] === 'lang')?.[1] || null, + language: event.tags.find((tag) => tag[0] === 'l' && tag[2] === 'ISO-639-1')?.[1] || null, replies_count: event.event_stats?.replies_count ?? 0, reblogs_count: event.event_stats?.reposts_count ?? 0, favourites_count: event.event_stats?.reactions['+'] ?? 0,