mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
17 lines
608 B
TypeScript
17 lines
608 B
TypeScript
|
|
import { UserEntity } from '@app/database/entities/user.entity';
|
||
|
|
|
||
|
|
function createUserUtils() {
|
||
|
|
const isReadyForDeletion = (user: UserEntity): boolean => {
|
||
|
|
if (user.deletedAt == null) return false;
|
||
|
|
const millisecondsInDay = 86400000;
|
||
|
|
// get this number (7 days) from some configuration perhaps ?
|
||
|
|
const millisecondsDeleteWait = millisecondsInDay * 7;
|
||
|
|
|
||
|
|
const millisecondsSinceDelete = new Date().getTime() - (user.deletedAt?.getTime() ?? 0);
|
||
|
|
return millisecondsSinceDelete >= millisecondsDeleteWait;
|
||
|
|
};
|
||
|
|
return { isReadyForDeletion };
|
||
|
|
}
|
||
|
|
|
||
|
|
export const userUtils = createUserUtils();
|