ашчуы

This commit is contained in:
xds
2026-02-20 10:28:56 +03:00
parent e1d941a2cd
commit 9e0c522b5f
3 changed files with 17 additions and 2 deletions

View File

@@ -102,7 +102,7 @@ class AssetsRepo:
return assets
async def get_asset(self, asset_id: str, with_data: bool = True) -> Asset:
async def get_asset(self, asset_id: str, with_data: bool = True) -> Optional[Asset]:
projection = None
if not with_data:
projection = {"data": 0, "thumbnail": 0}
@@ -182,7 +182,9 @@ class AssetsRepo:
return await self.collection.count_documents(filter)
async def get_assets_by_ids(self, asset_ids: List[str]) -> List[Asset]:
object_ids = [ObjectId(asset_id) for asset_id in asset_ids]
object_ids = [ObjectId(asset_id) for asset_id in asset_ids if ObjectId.is_valid(asset_id)]
if not object_ids:
return []
res = self.collection.find({"_id": {"$in": object_ids}}, {"data": 0}) # Exclude data but maybe allow thumbnail if small?
# Original excluded thumbnail too.
assets = []