diff --git a/src/controllers/api/accounts.ts b/src/controllers/api/accounts.ts index ecf71ea..9da0f66 100644 --- a/src/controllers/api/accounts.ts +++ b/src/controllers/api/accounts.ts @@ -14,7 +14,7 @@ import { lookupAccount } from '@/utils/lookup.ts'; import { renderAccounts, renderEventAccounts, renderStatuses } from '@/views.ts'; import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts'; import { renderRelationship } from '@/views/mastodon/relationships.ts'; -import { renderStatus } from '@/views/mastodon/statuses.ts'; +import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts'; import { hydrateEvents } from '@/storages/hydrate.ts'; import { bech32ToPubkey } from '@/utils.ts'; import { addTag, deleteTag, findReplyTag, getTagSet } from '@/utils/tags.ts'; @@ -192,7 +192,7 @@ const accountStatusesController: AppController = async (c) => { const filter: NostrFilter = { authors: [pubkey], - kinds: [1], + kinds: [1, 6], since, until, limit, @@ -206,7 +206,10 @@ const accountStatusesController: AppController = async (c) => { .then((events) => hydrateEvents({ events, store, signal })) .then((events) => { if (exclude_replies) { - return events.filter((event) => !findReplyTag(event.tags)); + return events.filter((event) => { + if (event.kind === 1) return !findReplyTag(event.tags); + return true; + }); } return events; }); @@ -214,7 +217,10 @@ const accountStatusesController: AppController = async (c) => { const viewerPubkey = await c.get('signer')?.getPublicKey(); const statuses = await Promise.all( - events.map((event) => renderStatus(event, { viewerPubkey })), + events.map((event) => { + if (event.kind === 6) return renderReblog(event, { viewerPubkey }); + return renderStatus(event, { viewerPubkey }); + }), ); return paginated(c, events, statuses); }; diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index b5ecf01..ce4cbfa 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 04039da..ed14c8e 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,