mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: asset key validation (#1938)
* fix: asset key validation * chore: asset key validation in user assets --------- Co-authored-by: Bavisetti Narayan <narayan@Bavisettis-MacBook-Pro.local>
This commit is contained in:
parent
761a1eb41a
commit
17aff1f369
@ -18,10 +18,21 @@ class FileAssetEndpoint(BaseAPIView):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def get(self, request, workspace_id, asset_key):
|
def get(self, request, workspace_id, asset_key):
|
||||||
asset_key = str(workspace_id) + "/" + asset_key
|
try:
|
||||||
files = FileAsset.objects.filter(asset=asset_key)
|
asset_key = str(workspace_id) + "/" + asset_key
|
||||||
serializer = FileAssetSerializer(files, context={"request": request}, many=True)
|
files = FileAsset.objects.filter(asset=asset_key)
|
||||||
return Response(serializer.data)
|
if files.exists():
|
||||||
|
serializer = FileAssetSerializer(files, context={"request": request}, many=True)
|
||||||
|
return Response({"data": serializer.data, "status": True}, status=status.HTTP_200_OK)
|
||||||
|
else:
|
||||||
|
return Response({"error": "Asset key does not exist", "status": False}, status=status.HTTP_200_OK)
|
||||||
|
except Exception as e:
|
||||||
|
capture_exception(e)
|
||||||
|
return Response(
|
||||||
|
{"error": "Something went wrong please try again later"},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def post(self, request, slug):
|
def post(self, request, slug):
|
||||||
try:
|
try:
|
||||||
@ -68,11 +79,16 @@ class UserAssetsEndpoint(BaseAPIView):
|
|||||||
def get(self, request, asset_key):
|
def get(self, request, asset_key):
|
||||||
try:
|
try:
|
||||||
files = FileAsset.objects.filter(asset=asset_key, created_by=request.user)
|
files = FileAsset.objects.filter(asset=asset_key, created_by=request.user)
|
||||||
serializer = FileAssetSerializer(files, context={"request": request})
|
if files.exists():
|
||||||
return Response(serializer.data)
|
serializer = FileAssetSerializer(files, context={"request": request})
|
||||||
except FileAsset.DoesNotExist:
|
return Response({"data": serializer.data, "status": True}, status=status.HTTP_200_OK)
|
||||||
|
else:
|
||||||
|
return Response({"error": "Asset key does not exist", "status": False}, status=status.HTTP_200_OK)
|
||||||
|
except Exception as e:
|
||||||
|
capture_exception(e)
|
||||||
return Response(
|
return Response(
|
||||||
{"error": "File Asset does not exist"}, status=status.HTTP_404_NOT_FOUND
|
{"error": "Something went wrong please try again later"},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
)
|
)
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
|
Loading…
Reference in New Issue
Block a user