Add durable candidate funnel
This commit is contained in:
1 parent
5abac31c28
commit
df35648920
20 files changed
+1128
-142
No files matched your search
@@ -31,7 +31,7 @@ function buildService() {
|
||||
path.join(os.tmpdir(), `chat-cache-${Date.now()}-${Math.random()}.json`),
|
||||
);
|
||||
const svc = new ChatService(matrix, logger, undefined, undefined, undefined, undefined, cache, undefined, undefined, authenticatedAccountAuth);
|
||||
return { svc, logger };
|
||||
return { svc, logger, matrix };
|
||||
}
|
||||
|
||||
describe('ChatService invitation cooldown', () => {
|
||||
@@ -82,6 +82,30 @@ describe('ChatService invitation cooldown', () => {
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('returns a retryable delivery result with the persisted cooldown deadline', async () => {
|
||||
const { svc } = buildService();
|
||||
svc.setInvitationCooldown(
|
||||
new MatrixRateLimitError('429', 60_000, 'M_LIMIT_EXCEEDED', 'rate.foo'),
|
||||
);
|
||||
const cooldown = svc.getInvitationCooldown()!;
|
||||
|
||||
await expect(svc.startConversationDetailed('someuser', 'hi')).resolves.toEqual({
|
||||
status: 'retryable',
|
||||
reason: cooldown.reason,
|
||||
retryAt: cooldown.until,
|
||||
});
|
||||
});
|
||||
|
||||
it('classifies recipients that reject chat requests as terminal', async () => {
|
||||
const { svc, matrix } = buildService();
|
||||
matrix.sendInitialDirectMessage = async () => {
|
||||
throw new Error('some of the invited users do not accept chat requests');
|
||||
};
|
||||
|
||||
await expect(svc.startConversationDetailed('someuser', 'hi', 't2_someuser'))
|
||||
.resolves.toEqual({ status: 'terminal', reason: 'Recipient does not accept chat requests' });
|
||||
});
|
||||
|
||||
it('sendChatMessage short-circuits when a cooldown is active', async () => {
|
||||
const { svc } = buildService();
|
||||
svc.setInvitationCooldown(
|
||||
|
||||
Reference in new issue
Block a user