api: download the FTC complaint list

SD3 (14 §2.2): spamFtcSync reads the FTC's Do Not Call complaints a day
at a time, 15 pages a minute, saving its place; failures are kept for
Settings → Spam check and retried the next minute. Download now starts
one. Old complaints are dropped after windowDays.

Follow-up: one real download with the owner's api.data.gov key.
This commit is contained in:
iamdoubz committed 2026-10-27 16:40:14 -05:00
1 parent 70f14288ca
commit 49d529e185
11 files changed
+406 -19

No files matched your search

+14
View File
@@ -315,6 +315,20 @@ describe.skipIf(!hasTestDb)('spam check', () => {
},
});
it('Download now: due at the next minute; refused without the FTC list', async () => {
await settings(keys.withIpqs);
const r = await admin('POST', '/api/settings/spam/ftc/sync');
expect(r.statusCode).toBe(400);
expect(r.body).toMatch('Set up the FTC list first');
await settings(keys.withFtc);
await setSetting(t.db, 'spam.state', {
...(await getSetting(t.db, 'spam.state')),
ftcLastSyncAt: new Date().toISOString(),
});
expect((await admin('POST', '/api/settings/spam/ftc/sync')).statusCode).toBe(200);
expect((await getSetting(t.db, 'spam.state')).ftcLastSyncAt).toBeNull();
});
it('keys are write-only, and empty keeps the saved one', async () => {
await setSetting(t.db, 'spam', SPAM_DEFAULTS);
const r = await admin('PATCH', '/api/settings', body());