server: expire notifications after 3 months

closes FoundKeyGang/FoundKey#292

Changelog: Added
This commit is contained in:
Johann150 2022-12-21 21:46:45 +01:00
parent fc36bb8880
commit 9317d25078
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -1,6 +1,6 @@
import Bull from 'bull'; import Bull from 'bull';
import { In, LessThan } from 'typeorm'; import { In, LessThan } from 'typeorm';
import { AttestationChallenges, AuthSessions, Mutings, PasswordResetRequests, Signins } from '@/models/index.js'; import { AttestationChallenges, AuthSessions, Mutings, Notifications, PasswordResetRequests, Signins } from '@/models/index.js';
import { publishUserEvent } from '@/services/stream.js'; import { publishUserEvent } from '@/services/stream.js';
import { MINUTE, DAY, MONTH } from '@/const.js'; import { MINUTE, DAY, MONTH } from '@/const.js';
import { queueLogger } from '@/queue/logger.js'; import { queueLogger } from '@/queue/logger.js';
@ -47,6 +47,11 @@ export async function checkExpired(job: Bull.Job<Record<string, unknown>>, done:
createdAt: OlderThan(15 * MINUTE), createdAt: OlderThan(15 * MINUTE),
}); });
await Notifications.delete({
isRead: true,
createdAt: OlderThan(3 * MONTH),
});
logger.succ('Deleted expired data.'); logger.succ('Deleted expired data.');
done(); done();