diff --git a/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Create.php b/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Create.php index 06342a0e79..98108e40dd 100644 --- a/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Create.php +++ b/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Create.php @@ -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 :.', 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, ]); diff --git a/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Update.php b/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Update.php index 540bb2703e..ab84c7324b 100644 --- a/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Update.php +++ b/src/Appwrite/Platform/Modules/Messaging/Http/Messages/Email/Update.php @@ -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 :.', 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)) {