feat(server,web): make user deletion delay configurable (#7663)
* feat(server,web): make user deletion delay configurable * alphabetical order * add min for user.deleteDelay in SettingInputField * make config.user.deleteDelay SettingInputField min consistent format * fix e2e test * update description on user delete delay
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsInt, Min } from 'class-validator';
|
||||
|
||||
export class SystemConfigUserDto {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Type(() => Number)
|
||||
@ApiProperty({ type: 'integer' })
|
||||
deleteDelay!: number;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import { SystemConfigStorageTemplateDto } from './system-config-storage-template
|
||||
import { SystemConfigThemeDto } from './system-config-theme.dto';
|
||||
import { SystemConfigThumbnailDto } from './system-config-thumbnail.dto';
|
||||
import { SystemConfigTrashDto } from './system-config-trash.dto';
|
||||
import { SystemConfigUserDto } from './system-config-user.dto';
|
||||
|
||||
export class SystemConfigDto implements SystemConfig {
|
||||
@Type(() => SystemConfigFFmpegDto)
|
||||
@@ -92,6 +93,11 @@ export class SystemConfigDto implements SystemConfig {
|
||||
@ValidateNested()
|
||||
@IsObject()
|
||||
server!: SystemConfigServerDto;
|
||||
|
||||
@Type(() => SystemConfigUserDto)
|
||||
@ValidateNested()
|
||||
@IsObject()
|
||||
user!: SystemConfigUserDto;
|
||||
}
|
||||
|
||||
export function mapConfig(config: SystemConfig): SystemConfigDto {
|
||||
|
||||
@@ -140,6 +140,9 @@ export const defaults = Object.freeze<SystemConfig>({
|
||||
externalDomain: '',
|
||||
loginPageMessage: '',
|
||||
},
|
||||
user: {
|
||||
deleteDelay: 7,
|
||||
},
|
||||
});
|
||||
|
||||
export enum FeatureFlag {
|
||||
|
||||
@@ -23,6 +23,7 @@ const updates: SystemConfigEntity[] = [
|
||||
{ key: SystemConfigKey.FFMPEG_CRF, value: 30 },
|
||||
{ key: SystemConfigKey.OAUTH_AUTO_LAUNCH, value: true },
|
||||
{ key: SystemConfigKey.TRASH_DAYS, value: 10 },
|
||||
{ key: SystemConfigKey.USER_DELETE_DELAY, value: 15 },
|
||||
];
|
||||
|
||||
const updatedConfig = Object.freeze<SystemConfig>({
|
||||
@@ -140,6 +141,9 @@ const updatedConfig = Object.freeze<SystemConfig>({
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
user: {
|
||||
deleteDelay: 15,
|
||||
},
|
||||
});
|
||||
|
||||
describe(SystemConfigService.name, () => {
|
||||
@@ -199,6 +203,7 @@ describe(SystemConfigService.name, () => {
|
||||
{ key: SystemConfigKey.FFMPEG_CRF, value: 30 },
|
||||
{ key: SystemConfigKey.OAUTH_AUTO_LAUNCH, value: true },
|
||||
{ key: SystemConfigKey.TRASH_DAYS, value: 10 },
|
||||
{ key: SystemConfigKey.USER_DELETE_DELAY, value: 15 },
|
||||
]);
|
||||
|
||||
await expect(sut.getConfig()).resolves.toEqual(updatedConfig);
|
||||
@@ -206,7 +211,12 @@ describe(SystemConfigService.name, () => {
|
||||
|
||||
it('should load the config from a file', async () => {
|
||||
process.env.IMMICH_CONFIG_FILE = 'immich-config.json';
|
||||
const partialConfig = { ffmpeg: { crf: 30 }, oauth: { autoLaunch: true }, trash: { days: 10 } };
|
||||
const partialConfig = {
|
||||
ffmpeg: { crf: 30 },
|
||||
oauth: { autoLaunch: true },
|
||||
trash: { days: 10 },
|
||||
user: { deleteDelay: 15 },
|
||||
};
|
||||
configMock.readFile.mockResolvedValue(JSON.stringify(partialConfig));
|
||||
|
||||
await expect(sut.getConfig()).resolves.toEqual(updatedConfig);
|
||||
|
||||
Reference in New Issue
Block a user