1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-28 09:33:27 +02:00

fix(server): use luxon for deleted date calculation (#6958)

* luxon implementation

* chore: simplify

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Manas Adepu 2024-02-08 16:56:19 -05:00 committed by GitHub
parent bd1fa9377b
commit 198e8517e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
import { UserEntity } from '@app/infra/entities';
import { ImmichLogger } from '@app/infra/logger';
import { BadRequestException, ForbiddenException, Inject, Injectable, NotFoundException } from '@nestjs/common';
import { DateTime } from 'luxon';
import { randomBytes } from 'node:crypto';
import { AuthDto } from '../auth';
import { CacheControl, ImmichFileResponse } from '../domain.util';
@ -188,12 +189,7 @@ export class UserService {
return false;
}
// TODO use luxon for date calculation
const msInDay = 86_400_000;
const msDeleteWait = msInDay * 7;
const msSinceDelete = Date.now() - (Date.parse(user.deletedAt.toString()) || 0);
return msSinceDelete >= msDeleteWait;
return DateTime.now().minus({ days: 7 }) > DateTime.fromJSDate(user.deletedAt);
}
private async findOrFail(id: string, options: UserFindOptions) {