mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-12-08 20:29:05 +00:00
feat(web,server): user memory settings (#3628)
* feat(web,server): user preference for time-based memories * chore: open api * dev: mobile * fix: update * mobile work --------- Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Alex Tran <Alex.Tran@conductix.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { toEmail, toSanitized } from '../../domain.util';
|
||||
|
||||
export class CreateUserDto {
|
||||
@@ -27,6 +27,10 @@ export class CreateUserDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
externalPath?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
memoriesEnabled?: boolean;
|
||||
}
|
||||
|
||||
export class CreateAdminDto {
|
||||
|
||||
@@ -45,4 +45,8 @@ export class UpdateUserDto {
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
shouldChangePassword?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
memoriesEnabled?: boolean;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ export class UserResponseDto {
|
||||
deletedAt!: Date | null;
|
||||
updatedAt!: Date;
|
||||
oauthId!: string;
|
||||
memoriesEnabled!: boolean;
|
||||
}
|
||||
|
||||
export function mapUser(entity: UserEntity): UserResponseDto {
|
||||
@@ -31,5 +32,6 @@ export function mapUser(entity: UserEntity): UserResponseDto {
|
||||
deletedAt: entity.deletedAt,
|
||||
updatedAt: entity.updatedAt,
|
||||
oauthId: entity.oauthId,
|
||||
memoriesEnabled: entity.memoriesEnabled,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ export class UserCore {
|
||||
dto.externalPath = null;
|
||||
}
|
||||
|
||||
console.log(dto.memoriesEnabled);
|
||||
return this.userRepository.update(id, dto);
|
||||
} catch (e) {
|
||||
Logger.error(e, 'Failed to update user info');
|
||||
|
||||
@@ -16,6 +16,7 @@ import { ICryptoRepository } from '../crypto';
|
||||
import { IJobRepository, JobName } from '../job';
|
||||
import { IStorageRepository } from '../storage';
|
||||
import { UpdateUserDto } from './dto/update-user.dto';
|
||||
import { UserResponseDto } from './response-dto';
|
||||
import { IUserRepository } from './user.repository';
|
||||
import { UserService } from './user.service';
|
||||
|
||||
@@ -54,6 +55,7 @@ const adminUser: UserEntity = Object.freeze({
|
||||
assets: [],
|
||||
storageLabel: 'admin',
|
||||
externalPath: null,
|
||||
memoriesEnabled: true,
|
||||
});
|
||||
|
||||
const immichUser: UserEntity = Object.freeze({
|
||||
@@ -73,9 +75,10 @@ const immichUser: UserEntity = Object.freeze({
|
||||
assets: [],
|
||||
storageLabel: null,
|
||||
externalPath: null,
|
||||
memoriesEnabled: true,
|
||||
});
|
||||
|
||||
const updatedImmichUser: UserEntity = Object.freeze({
|
||||
const updatedImmichUser = Object.freeze<UserEntity>({
|
||||
id: immichUserAuth.id,
|
||||
email: 'immich@test.com',
|
||||
password: 'immich_password',
|
||||
@@ -92,9 +95,10 @@ const updatedImmichUser: UserEntity = Object.freeze({
|
||||
assets: [],
|
||||
storageLabel: null,
|
||||
externalPath: null,
|
||||
memoriesEnabled: true,
|
||||
});
|
||||
|
||||
const adminUserResponse = Object.freeze({
|
||||
const adminUserResponse = Object.freeze<UserResponseDto>({
|
||||
id: adminUserAuth.id,
|
||||
email: 'admin@test.com',
|
||||
firstName: 'admin_first_name',
|
||||
@@ -108,6 +112,7 @@ const adminUserResponse = Object.freeze({
|
||||
updatedAt: new Date('2021-01-01'),
|
||||
storageLabel: 'admin',
|
||||
externalPath: null,
|
||||
memoriesEnabled: true,
|
||||
});
|
||||
|
||||
describe(UserService.name, () => {
|
||||
@@ -158,6 +163,7 @@ describe(UserService.name, () => {
|
||||
updatedAt: new Date('2021-01-01'),
|
||||
storageLabel: 'admin',
|
||||
externalPath: null,
|
||||
memoriesEnabled: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user