1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-01 21:24:45 +02:00

Server: Fixed user deletion schedule

This commit is contained in:
Laurent Cozic 2022-02-23 09:16:30 +00:00
parent 00e0f6b97c
commit bfe5ee8ba3
2 changed files with 5 additions and 4 deletions

View File

@ -159,21 +159,22 @@ describe('UserDeletionModel', function() {
disabled_time: t0, disabled_time: t0,
}); });
await models().userDeletion().autoAdd(10, 90 * Day, 3 * Day); await models().userDeletion().autoAdd(10, 90 * Day, t0 + 3 * Day);
expect(await models().userDeletion().count()).toBe(0); expect(await models().userDeletion().count()).toBe(0);
const t1 = new Date('2022-05-30').getTime(); const t1 = new Date('2022-05-30').getTime();
jest.setSystemTime(t1); jest.setSystemTime(t1);
await models().userDeletion().autoAdd(10, 90 * Day, 3 * Day); await models().userDeletion().autoAdd(10, 90 * Day, t1 + 3 * Day);
expect(await models().userDeletion().count()).toBe(1); expect(await models().userDeletion().count()).toBe(1);
const d = (await models().userDeletion().all())[0]; const d = (await models().userDeletion().all())[0];
expect(d.user_id).toBe(user2.id); expect(d.user_id).toBe(user2.id);
expect(d.scheduled_time).toBe(t1 + 3 * Day);
// Shouldn't add it again if running autoAdd() again // Shouldn't add it again if running autoAdd() again
await models().userDeletion().autoAdd(10, 90 * Day, 3 * Day); await models().userDeletion().autoAdd(10, 90 * Day, t1 + 3 * Day);
expect(await models().userDeletion().count()).toBe(1); expect(await models().userDeletion().count()).toBe(1);
jest.useRealTimers(); jest.useRealTimers();

View File

@ -112,7 +112,7 @@ export default class UserDeletionService extends BaseService {
const addedUserIds = await this.models.userDeletion().autoAdd( const addedUserIds = await this.models.userDeletion().autoAdd(
10, 10,
this.config.USER_DATA_AUTO_DELETE_AFTER_DAYS * Day, this.config.USER_DATA_AUTO_DELETE_AFTER_DAYS * Day,
3 * Day, Date.now() + 3 * Day,
{ {
processAccount: true, processAccount: true,
processData: true, processData: true,