Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apps/api/plane/app/views/issue/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ def post(self, request, slug, project_id, issue_id):

@allow_permission([ROLE.ADMIN], creator=True, model=FileAsset)
def delete(self, request, slug, project_id, issue_id, pk):
issue_attachment = FileAsset.objects.get(pk=pk, workspace__slug=slug, project_id=project_id)
issue_attachment = FileAsset.objects.get(
pk=pk, workspace__slug=slug, project_id=project_id, issue_id=issue_id
)
issue_attachment.is_deleted = True
issue_attachment.deleted_at = timezone.now()
issue_attachment.save()
Expand All @@ -171,7 +173,7 @@ def delete(self, request, slug, project_id, issue_id, pk):
def get(self, request, slug, project_id, issue_id, pk=None):
if pk:
# Get the asset
asset = FileAsset.objects.get(id=pk, workspace__slug=slug, project_id=project_id)
asset = FileAsset.objects.get(id=pk, workspace__slug=slug, project_id=project_id, issue_id=issue_id)

# Check if the asset is uploaded
if not asset.is_uploaded:
Expand Down Expand Up @@ -202,7 +204,9 @@ def get(self, request, slug, project_id, issue_id, pk=None):

@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
def patch(self, request, slug, project_id, issue_id, pk):
issue_attachment = FileAsset.objects.get(pk=pk, workspace__slug=slug, project_id=project_id)
issue_attachment = FileAsset.objects.get(
pk=pk, workspace__slug=slug, project_id=project_id, issue_id=issue_id
)
serializer = IssueAttachmentSerializer(issue_attachment)

# Send this activity only if the attachment is not uploaded before
Expand All @@ -219,9 +223,9 @@ def patch(self, request, slug, project_id, issue_id, pk):
origin=base_host(request=request, is_app=True),
)

# Update the attachment
# Update the attachment — do NOT overwrite created_by; it is set at
# creation time and must not be reassigned (GHSA-5mxw-g5mw-3v3w).
issue_attachment.is_uploaded = True
issue_attachment.created_by = request.user

# Get the storage metadata
if not issue_attachment.storage_metadata:
Expand Down
Loading