Fix account cooldown stats contract
This commit is contained in:
1 parent
e9083281a8
commit
742c06d0c4
2 files changed
+10
-2
No files matched your search
@@ -80,7 +80,13 @@ export function createStatsRouter(ctx: WebContext): Router {
|
|||||||
hourlyResetAt: timers.hourlyResetAt,
|
hourlyResetAt: timers.hourlyResetAt,
|
||||||
messagesRemaining: timers.messagesRemaining,
|
messagesRemaining: timers.messagesRemaining,
|
||||||
actionableReplies: priority?.actionableBacklog ?? 0,
|
actionableReplies: priority?.actionableBacklog ?? 0,
|
||||||
invitationCooldown: accountCooldown,
|
invitationCooldown: accountCooldown
|
||||||
|
? {
|
||||||
|
until: accountCooldown.until,
|
||||||
|
reason: accountCooldown.reason,
|
||||||
|
redditCode: accountCooldown.redditCode,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
failure: snapshot?.failure ?? null,
|
failure: snapshot?.failure ?? null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe('stats route account status', () => {
|
|||||||
const account = (
|
const account = (
|
||||||
accountId: string,
|
accountId: string,
|
||||||
redditUsername: 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 },
|
session: { accountId, redditUsername },
|
||||||
resources: {
|
resources: {
|
||||||
@@ -50,6 +50,7 @@ describe('stats route account status', () => {
|
|||||||
until: now + 600_000,
|
until: now + 600_000,
|
||||||
reason: 'Matrix rate-limited: M_LIMIT_EXCEEDED',
|
reason: 'Matrix rate-limited: M_LIMIT_EXCEEDED',
|
||||||
redditCode: 'rate.invitation_limit_mature_account',
|
redditCode: 'rate.invitation_limit_mature_account',
|
||||||
|
setAt: now,
|
||||||
});
|
});
|
||||||
const runtimes = new Map([[ready.session.accountId, ready], [limited.session.accountId, limited]]);
|
const runtimes = new Map([[ready.session.accountId, ready], [limited.session.accountId, limited]]);
|
||||||
const context = {
|
const context = {
|
||||||
@@ -90,5 +91,6 @@ describe('stats route account status', () => {
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
expect(stats.invitationCooldown).toMatchObject({ redditUsername: 'limited-account' });
|
expect(stats.invitationCooldown).toMatchObject({ redditUsername: 'limited-account' });
|
||||||
|
expect(stats.accounts[1]?.invitationCooldown).not.toHaveProperty('setAt');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user