fix: update
This commit is contained in:
@@ -15,8 +15,12 @@ class DeleteAvatarCommand:
|
|||||||
self._cache = cache
|
self._cache = cache
|
||||||
self._s3 = s3
|
self._s3 = s3
|
||||||
|
|
||||||
|
@transactional
|
||||||
|
async def _load_user(self, user_id: str) -> UserEntity:
|
||||||
|
return await self._unit_of_work.user_repository.get_user_by_id(user_id)
|
||||||
|
|
||||||
async def __call__(self, user_id: str) -> UserEntity:
|
async def __call__(self, user_id: str) -> UserEntity:
|
||||||
prior = await self._unit_of_work.user_repository.get_user_by_id(user_id)
|
prior = await self._load_user(user_id)
|
||||||
link = prior.avatar_link
|
link = prior.avatar_link
|
||||||
if link:
|
if link:
|
||||||
key = self._s3.object_key_from_public_url(link)
|
key = self._s3.object_key_from_public_url(link)
|
||||||
|
|||||||
@@ -23,8 +23,12 @@ class SetAvatarCommand:
|
|||||||
self._cache = cache
|
self._cache = cache
|
||||||
self._s3 = s3
|
self._s3 = s3
|
||||||
|
|
||||||
|
@transactional
|
||||||
|
async def _load_user(self, user_id: str) -> UserEntity:
|
||||||
|
return await self._unit_of_work.user_repository.get_user_by_id(user_id)
|
||||||
|
|
||||||
async def __call__(self, user_id: str, image_bytes: bytes) -> tuple[UserEntity, int]:
|
async def __call__(self, user_id: str, image_bytes: bytes) -> tuple[UserEntity, int]:
|
||||||
prior = await self._unit_of_work.user_repository.get_user_by_id(user_id)
|
prior = await self._load_user(user_id)
|
||||||
old_link = prior.avatar_link
|
old_link = prior.avatar_link
|
||||||
try:
|
try:
|
||||||
webp_bytes = image_bytes_to_webp(image_bytes)
|
webp_bytes = image_bytes_to_webp(image_bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user