From 3df94cd80f1bb040d51d68b5843b90c528cecd8a Mon Sep 17 00:00:00 2001 From: Sabrina Demagny Date: Thu, 24 Apr 2025 12:24:06 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(api)=20add=20draftBody?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/core/api/viewsets.py | 10 ++++++---- .../core/migrations/0005_message_draft_body.py | 18 ++++++++++++++++++ src/backend/core/models.py | 2 ++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 src/backend/core/migrations/0005_message_draft_body.py diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.py index 0f48b94a..106ac67b 100644 --- a/src/backend/core/api/viewsets.py +++ b/src/backend/core/api/viewsets.py @@ -690,8 +690,7 @@ class DraftMessageView(APIView): - parentId: str (optional, message id if reply, None if first message) - senderId: str (mailbox id of the sender) - subject: str - - htmlBody: str (optional) - - textBody: str (optional) + - draftBody: str (optional) - to: list[str] (optional) - cc: list[str] (optional) - bcc: list[str] (optional) @@ -699,8 +698,7 @@ class DraftMessageView(APIView): PUT /api/v1.0/draft/{message_id}/ with expected data: - subject: str (optional) - - htmlBody: str (optional) - - textBody: str (optional) + - draftBody: str (optional) - to: list[str] (optional) - cc: list[str] (optional) - bcc: list[str] (optional) @@ -995,6 +993,10 @@ class SendMessageView(APIView): POST /api/v1.0/send/ with expected data: - messageId: str (ID of the draft message to send) - senderId: str (ID of the mailbox to use as sender) + - draftBody: str (optional) + - to: list[str] (optional) + - cc: list[str] (optional) + - bcc: list[str] (optional) Return the sent message """ diff --git a/src/backend/core/migrations/0005_message_draft_body.py b/src/backend/core/migrations/0005_message_draft_body.py new file mode 100644 index 00000000..b2eb3c8b --- /dev/null +++ b/src/backend/core/migrations/0005_message_draft_body.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.8 on 2025-04-28 02:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0004_message_is_draft'), + ] + + operations = [ + migrations.AddField( + model_name='message', + name='draft_body', + field=models.TextField(blank=True, verbose_name='draft body'), + ), + ] diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 9668bcf5..24b57f25 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -368,6 +368,8 @@ class Message(BaseModel): # to object storage in the future. raw_mime = models.BinaryField(blank=True, default=b"") + draft_body = models.TextField(_("draft body"), blank=True) + # Internal cache for parsed data _parsed_email_cache: Optional[Dict[str, Any]] = None