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:
Jason Rasmussen
2023-08-09 22:01:16 -04:00
committed by GitHub
parent 343087e2b4
commit a6eb227330
33 changed files with 519 additions and 25 deletions

View File

@@ -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 {

View File

@@ -45,4 +45,8 @@ export class UpdateUserDto {
@IsOptional()
@IsBoolean()
shouldChangePassword?: boolean;
@IsOptional()
@IsBoolean()
memoriesEnabled?: boolean;
}

View File

@@ -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,
};
}

View File

@@ -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');

View File

@@ -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,
},
]);
});