Prioritize conversation replies

This commit is contained in:
jjbrunton committed 2026-08-09 16:04:39 +01:00
1 parent f55ae7ddf8
commit 9b86cee9be
13 files changed
+535 -39

No files matched your search

+30
View File
@@ -220,6 +220,36 @@ describe('RedditAccountRuntimeManager', () => {
});
describe('account runtime isolation', () => {
it('does not accept new outreach while the account has actionable replies', async () => {
const stored = account('reply_first');
const hasActionableReplies = vi.fn().mockResolvedValue(true);
const runtime = new RedditAccountRuntime(
{
accountId: stored.accountId,
redditUsername: stored.redditUsername,
matrixUserId: stored.matrixUserId!,
cookies: [],
matrixCredentials: JSON.parse(stored.matrixCredentialsJson),
updatedAt: stored.updatedAt,
},
{
accountAuth: {
isFullyAuthenticated: () => true,
ensureFullyAuthenticated: async () => true,
},
conversationAutomation: { hasActionableReplies },
chatService: { getInvitationCooldown: () => null },
rateLimiter: { getTimers: () => ({ nextMessageAvailableAt: null }) },
} as unknown as RedditAccountRuntimeResources,
{ start: vi.fn(), stop: vi.fn() },
);
await runtime.start();
expect(await runtime.canAcceptPost()).toBe(false);
hasActionableReplies.mockResolvedValue(false);
expect(await runtime.canAcceptPost()).toBe(true);
});
it('uses the Reddit fullname for auth while retaining the Matrix runtime owner', () => {
expect(runtimeAuthenticatedAccount(
{ matrixUserId: '@t2_1u57iqxxbv:reddit.com' },