diff --git a/src/db/events.ts b/src/db/events.ts index b88d38d..4e3c020 100644 --- a/src/db/events.ts +++ b/src/db/events.ts @@ -224,8 +224,9 @@ type AuthorStats = Omit; type EventStats = Omit; interface DittoEvent extends Event { - author?: Event<0> & { stats?: AuthorStats }; - stats?: EventStats; + author?: DittoEvent<0>; + author_stats?: AuthorStats; + event_stats?: EventStats; } /** Get events for filters from the database. */ @@ -263,7 +264,7 @@ async function getFilters( }; if (typeof row.author_stats_followers_count === 'number') { - event.author.stats = { + event.author.author_stats = { followers_count: row.author_stats_followers_count, following_count: row.author_stats_following_count!, notes_count: row.author_stats_notes_count!, @@ -272,7 +273,7 @@ async function getFilters( } if (typeof row.stats_replies_count === 'number') { - event.stats = { + event.event_stats = { replies_count: row.stats_replies_count, reposts_count: row.stats_reposts_count!, reactions_count: row.stats_reactions_count!, diff --git a/src/views/mastodon/accounts.ts b/src/views/mastodon/accounts.ts index f2d2f58..bfcd7ef 100644 --- a/src/views/mastodon/accounts.ts +++ b/src/views/mastodon/accounts.ts @@ -45,8 +45,8 @@ async function renderAccount( emojis: renderEmojis(event), fields: [], follow_requests_count: 0, - followers_count: event.stats?.followers_count ?? 0, - following_count: event.stats?.following_count ?? 0, + followers_count: event.author_stats?.followers_count ?? 0, + following_count: event.author_stats?.following_count ?? 0, fqn: parsed05?.handle || npub, header: banner, header_static: banner, @@ -64,7 +64,7 @@ async function renderAccount( follow_requests_count: 0, } : undefined, - statuses_count: event.stats?.notes_count ?? 0, + statuses_count: event.author_stats?.notes_count ?? 0, url: Conf.local(`/users/${pubkey}`), username: parsed05?.nickname || npub.substring(0, 8), pleroma: { diff --git a/src/views/mastodon/statuses.ts b/src/views/mastodon/statuses.ts index 88596d2..380682d 100644 --- a/src/views/mastodon/statuses.ts +++ b/src/views/mastodon/statuses.ts @@ -63,9 +63,9 @@ async function renderStatus(event: eventsDB.DittoEvent<1>, viewerPubkey?: string spoiler_text: (cw ? cw[1] : subject?.[1]) || '', visibility: 'public', language: event.tags.find((tag) => tag[0] === 'lang')?.[1] || null, - replies_count: event.stats?.replies_count ?? 0, - reblogs_count: event.stats?.reposts_count ?? 0, - favourites_count: event.stats?.reactions_count ?? 0, + replies_count: event.event_stats?.replies_count ?? 0, + reblogs_count: event.event_stats?.reposts_count ?? 0, + favourites_count: event.event_stats?.reactions_count ?? 0, favourited: reactionEvent?.content === '+', reblogged: Boolean(repostEvent), muted: false,