mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-12-08 04:09:07 +00:00
refactor(server): cron jobs (#2067)
This commit is contained in:
@@ -3,11 +3,11 @@ import { Injectable } from '@nestjs/common';
|
||||
import { Cron, CronExpression } from '@nestjs/schedule';
|
||||
|
||||
@Injectable()
|
||||
export class ScheduleTasksService {
|
||||
export class AppCronJobs {
|
||||
constructor(private userService: UserService) {}
|
||||
|
||||
@Cron(CronExpression.EVERY_DAY_AT_11PM)
|
||||
async onUserDeleteCheck() {
|
||||
await this.userService.handleUserDeleteCheck();
|
||||
async onQueueUserDeleteCheck() {
|
||||
await this.userService.handleQueueUserDelete();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import { ConfigModule } from '@nestjs/config';
|
||||
import { AlbumModule } from './api-v1/album/album.module';
|
||||
import { AppController } from './app.controller';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
import { ScheduleTasksModule } from './modules/schedule-tasks/schedule-tasks.module';
|
||||
import { TagModule } from './api-v1/tag/tag.module';
|
||||
import { DomainModule, SearchService } from '@app/domain';
|
||||
import { InfraModule } from '@app/infra';
|
||||
@@ -23,23 +22,15 @@ import {
|
||||
} from './controllers';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { AuthGuard } from './middlewares/auth.guard';
|
||||
import { AppCronJobs } from './app.cron-jobs';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(immichAppConfig),
|
||||
|
||||
DomainModule.register({
|
||||
imports: [InfraModule],
|
||||
}),
|
||||
|
||||
DomainModule.register({ imports: [InfraModule] }),
|
||||
AssetModule,
|
||||
|
||||
AlbumModule,
|
||||
|
||||
ScheduleModule.forRoot(),
|
||||
|
||||
ScheduleTasksModule,
|
||||
|
||||
TagModule,
|
||||
],
|
||||
controllers: [
|
||||
@@ -55,7 +46,12 @@ import { AuthGuard } from './middlewares/auth.guard';
|
||||
SystemConfigController,
|
||||
UserController,
|
||||
],
|
||||
providers: [{ provide: APP_GUARD, useExisting: AuthGuard }, AuthGuard],
|
||||
providers: [
|
||||
//
|
||||
{ provide: APP_GUARD, useExisting: AuthGuard },
|
||||
AuthGuard,
|
||||
AppCronJobs,
|
||||
],
|
||||
})
|
||||
export class AppModule implements OnModuleInit {
|
||||
constructor(private searchService: SearchService) {}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { AssetEntity, ExifEntity, UserEntity } from '@app/infra';
|
||||
import { ScheduleTasksService } from './schedule-tasks.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([AssetEntity, ExifEntity, UserEntity])],
|
||||
providers: [ScheduleTasksService],
|
||||
})
|
||||
export class ScheduleTasksModule {}
|
||||
Reference in New Issue
Block a user