feat(messaging): accept replyToEmail and replyToName on email messages

Add optional reply-to address and name params to the create and update
email endpoints, persisted alongside the rest of the message data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ArnabChatterjee20kandClaude Opus 4.8 committed 2026-09-21 11:16:19 +05:30
1 parent addb770419
commit 776493f53d
2 files changed
+18 -2

No files matched your search

@@ -21,6 +21,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Query;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\Database\Validator\UID;
use Utopia\Emails\Validator\Email;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList;
@@ -71,6 +72,8 @@ class Create extends Action
->param('cc', [], fn (Database $dbForProject) => new ArrayList(new UID($dbForProject->getAdapter()->getMaxUIDLength())), 'Array of target IDs to be added as CC.', true, ['dbForProject'])
->param('bcc', [], fn (Database $dbForProject) => new ArrayList(new UID($dbForProject->getAdapter()->getMaxUIDLength())), 'Array of target IDs to be added as BCC.', true, ['dbForProject'])
->param('attachments', [], new ArrayList(new CompoundUID()), 'Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.', true)
->param('replyToEmail', '', new Email(), 'Email address to reply to. If not set, defaults to the sender email address.', true)
->param('replyToName', '', new Text(128), 'Name of the reply to recipient. If not set, defaults to the sender name.', true)
->param('draft', false, new Boolean(), 'Is message a draft', true)
->param('html', false, new Boolean(), 'Is content of type HTML', true)
->param('scheduledAt', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
@@ -83,7 +86,7 @@ class Create extends Action
->callback($this->action(...));
}
public function action(string $messageId, string $subject, string $content, ?array $topics, ?array $users, ?array $targets, ?array $cc, ?array $bcc, ?array $attachments, bool $draft, bool $html, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForPlatform, Document $project, MessagingPublisher $publisherForMessaging, Response $response)
public function action(string $messageId, string $subject, string $content, ?array $topics, ?array $users, ?array $targets, ?array $cc, ?array $bcc, ?array $attachments, string $replyToEmail, string $replyToName, bool $draft, bool $html, ?string $scheduledAt, Event $queueForEvents, Database $dbForProject, Database $dbForPlatform, Document $project, MessagingPublisher $publisherForMessaging, Response $response)
{
$messageId = $messageId == 'unique()'
? ID::unique()
@@ -158,6 +161,8 @@ class Create extends Action
'cc' => $cc,
'bcc' => $bcc,
'attachments' => $attachments,
'replyToEmail' => $replyToEmail,
'replyToName' => $replyToName,
],
'status' => $status,
]);
@@ -17,6 +17,7 @@ use Utopia\Database\DateTime;
use Utopia\Database\Document;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\Database\Validator\UID;
use Utopia\Emails\Validator\Email;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList;
@@ -68,6 +69,8 @@ class Update extends Action
->param('html', null, new Nullable(new Boolean()), 'Is content of type HTML', true)
->param('cc', null, fn (Database $dbForProject) => new Nullable(new ArrayList(new UID($dbForProject->getAdapter()->getMaxUIDLength()))), 'Array of target IDs to be added as CC.', true, ['dbForProject'])
->param('bcc', null, fn (Database $dbForProject) => new Nullable(new ArrayList(new UID($dbForProject->getAdapter()->getMaxUIDLength()))), 'Array of target IDs to be added as BCC.', true, ['dbForProject'])
->param('replyToEmail', null, new Nullable(new Email()), 'Email address to reply to. If not set, defaults to the sender email address.', true)
->param('replyToName', null, new Nullable(new Text(128)), 'Name of the reply to recipient. If not set, defaults to the sender name.', true)
->param('scheduledAt', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->param('attachments', null, new Nullable(new ArrayList(new CompoundUID())), 'Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.', true)
->inject('queueForEvents')
@@ -79,7 +82,7 @@ class Update extends Action
->callback($this->action(...));
}
public function action(string $messageId, ?array $topics, ?array $users, ?array $targets, ?string $subject, ?string $content, ?bool $draft, ?bool $html, ?array $cc, ?array $bcc, ?string $scheduledAt, ?array $attachments, Event $queueForEvents, Database $dbForProject, Database $dbForPlatform, Document $project, MessagingPublisher $publisherForMessaging, Response $response)
public function action(string $messageId, ?array $topics, ?array $users, ?array $targets, ?string $subject, ?string $content, ?bool $draft, ?bool $html, ?array $cc, ?array $bcc, ?string $replyToEmail, ?string $replyToName, ?string $scheduledAt, ?array $attachments, Event $queueForEvents, Database $dbForProject, Database $dbForPlatform, Document $project, MessagingPublisher $publisherForMessaging, Response $response)
{
$message = $dbForProject->getDocument('messages', $messageId);
@@ -229,6 +232,14 @@ class Update extends Action
$data['bcc'] = $bcc;
}
if (!\is_null($replyToEmail)) {
$data['replyToEmail'] = $replyToEmail;
}
if (!\is_null($replyToName)) {
$data['replyToName'] = $replyToName;
}
$message->setAttribute('data', $data);
if (!\is_null($status)) {