mirror of
https://github.com/suitenumerique/messages.git
synced 2026-08-17 21:25:41 +02:00
🐛(drafts) fix concurrent updates of drafts with blob delete
This commit is contained in:
@@ -47,6 +47,7 @@ env.d/terraform
|
||||
# npm
|
||||
node_modules
|
||||
src/frontend/out/
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
# Mails
|
||||
src/backend/core/templates/mail/
|
||||
|
||||
@@ -156,10 +156,18 @@ lint: ## run all linters
|
||||
lint: \
|
||||
back-lint \
|
||||
front-lint \
|
||||
front-ts-check \
|
||||
mta-in-lint \
|
||||
mta-out-lint
|
||||
.PHONY: lint
|
||||
|
||||
lint-check: ## run all linters in check mode
|
||||
lint-check: \
|
||||
back-ruff-check \
|
||||
back-pylint \
|
||||
front-ts-check
|
||||
.PHONY: lint-check
|
||||
|
||||
back-lint: ## run back-end linters
|
||||
back-lint: \
|
||||
back-ruff-format \
|
||||
|
||||
@@ -253,8 +253,12 @@ class DraftMessageView(APIView):
|
||||
|
||||
# Update draft body if provided
|
||||
if "draftBody" in request_data:
|
||||
if message.draft_blob:
|
||||
message.draft_blob.delete()
|
||||
|
||||
try:
|
||||
if message.draft_blob:
|
||||
message.draft_blob.delete()
|
||||
except models.Blob.DoesNotExist:
|
||||
pass
|
||||
message.draft_blob = self.mailbox.create_blob(
|
||||
content=(request_data.get("draftBody") or "").encode("utf-8"),
|
||||
content_type="application/json",
|
||||
@@ -468,7 +472,7 @@ class DraftMessageView(APIView):
|
||||
try:
|
||||
# Fetch the draft message, ensuring it belongs to the user indirectly via ThreadAccess
|
||||
# and matches the sender mailbox context if that's a requirement for *updating*.
|
||||
message = models.Message.objects.select_related("thread").get(
|
||||
message = models.Message.objects.select_related("thread", "draft_blob").get(
|
||||
id=message_id,
|
||||
is_draft=True,
|
||||
# Ensure the user has access to this thread
|
||||
|
||||
Reference in New Issue
Block a user