diff --git a/src/web/routes/stats.ts b/src/web/routes/stats.ts index 821b10e..9d73cd1 100644 --- a/src/web/routes/stats.ts +++ b/src/web/routes/stats.ts @@ -80,7 +80,13 @@ export function createStatsRouter(ctx: WebContext): Router { hourlyResetAt: timers.hourlyResetAt, messagesRemaining: timers.messagesRemaining, actionableReplies: priority?.actionableBacklog ?? 0, - invitationCooldown: accountCooldown, + invitationCooldown: accountCooldown + ? { + until: accountCooldown.until, + reason: accountCooldown.reason, + redditCode: accountCooldown.redditCode, + } + : null, failure: snapshot?.failure ?? null, }; }); diff --git a/tests/web/stats-route.test.ts b/tests/web/stats-route.test.ts index b3cffd0..aef6816 100644 --- a/tests/web/stats-route.test.ts +++ b/tests/web/stats-route.test.ts @@ -25,7 +25,7 @@ describe('stats route account status', () => { const account = ( accountId: string, redditUsername: string, - cooldown: { until: number; reason: string; redditCode: string | null } | null, + cooldown: { until: number; reason: string; redditCode: string | null; setAt: number } | null, ) => ({ session: { accountId, redditUsername }, resources: { @@ -50,6 +50,7 @@ describe('stats route account status', () => { until: now + 600_000, reason: 'Matrix rate-limited: M_LIMIT_EXCEEDED', redditCode: 'rate.invitation_limit_mature_account', + setAt: now, }); const runtimes = new Map([[ready.session.accountId, ready], [limited.session.accountId, limited]]); const context = { @@ -90,5 +91,6 @@ describe('stats route account status', () => { }), ]); expect(stats.invitationCooldown).toMatchObject({ redditUsername: 'limited-account' }); + expect(stats.accounts[1]?.invitationCooldown).not.toHaveProperty('setAt'); }); });