refactor: channels design to allow attachment ownership

This commit is contained in:
Mohamed Marrouchi
2025-01-15 15:46:50 +01:00
parent e859cf1930
commit 39213e8b0b
11 changed files with 184 additions and 53 deletions

View File

@@ -110,10 +110,7 @@ export class ReadOnlyUserController extends BaseController<
throw new Error('User has no avatar');
}
return await this.attachmentService.download(
user.avatar,
config.parameters.avatarDir,
);
return await this.attachmentService.download(user.avatar);
} catch (err) {
this.logger.verbose(
'User has no avatar, generating initials avatar ...',
@@ -293,18 +290,14 @@ export class ReadWriteUserController extends ReadOnlyUserController {
// Upload Avatar if provided
const avatar = avatarFile
? await this.attachmentService.store(
avatarFile,
{
name: avatarFile.originalname,
size: avatarFile.size,
type: avatarFile.mimetype,
context: 'user_avatar',
ownerType: 'User',
owner: req.user.id,
},
config.parameters.avatarDir,
)
? await this.attachmentService.store(avatarFile, {
name: avatarFile.originalname,
size: avatarFile.size,
type: avatarFile.mimetype,
context: 'user_avatar',
ownerType: 'User',
owner: req.user.id,
})
: undefined;
const result = await this.userService.updateOne(