-
Notifications
You must be signed in to change notification settings - Fork 5
Add Email Templates migration #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
premtsd-code
wants to merge
4
commits into
add-custom-domains-migration
Choose a base branch
from
add-email-templates-migration
base: add-custom-domains-migration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9813afb
Add Email Templates migration
premtsd-code edcb0aa
Rename EmailTemplate $message to $body to avoid collision with Resour…
premtsd-code 9ed01cf
Merge remote-tracking branch 'origin/add-custom-domains-migration' in…
premtsd-code ed02f85
Fold email templates into projects group (rename TYPE_EMAIL_TEMPLATE …
premtsd-code File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| <?php | ||
|
|
||
| namespace Utopia\Migration\Resources\Templates; | ||
|
|
||
| use Utopia\Migration\Resource; | ||
| use Utopia\Migration\Transfer; | ||
|
|
||
| /** | ||
| * Custom email template — one row per (templateId, locale) pair. The resource | ||
| * `id` follows the storage key format `email.{templateId}-{locale}` so | ||
| * destination read-then-merge can address the slot directly. | ||
| */ | ||
| class EmailTemplate extends Resource | ||
| { | ||
| public function __construct( | ||
| string $id, | ||
| private readonly string $templateId, | ||
| private readonly string $locale, | ||
| private readonly string $subject, | ||
| private readonly string $body, | ||
| private readonly string $senderName = '', | ||
| private readonly string $senderEmail = '', | ||
| private readonly string $replyToEmail = '', | ||
| private readonly string $replyToName = '', | ||
| string $createdAt = '', | ||
| string $updatedAt = '', | ||
| ) { | ||
| $this->id = $id; | ||
| $this->createdAt = $createdAt; | ||
| $this->updatedAt = $updatedAt; | ||
| } | ||
|
|
||
| /** | ||
| * @param array<string, mixed> $array | ||
| */ | ||
| public static function fromArray(array $array): self | ||
| { | ||
| return new self( | ||
| $array['id'], | ||
| (string) $array['templateId'], | ||
| (string) $array['locale'], | ||
| (string) ($array['subject'] ?? ''), | ||
| (string) ($array['message'] ?? ''), | ||
| (string) ($array['senderName'] ?? ''), | ||
| (string) ($array['senderEmail'] ?? ''), | ||
| (string) ($array['replyToEmail'] ?? ''), | ||
| (string) ($array['replyToName'] ?? ''), | ||
| createdAt: $array['createdAt'] ?? '', | ||
| updatedAt: $array['updatedAt'] ?? '', | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, mixed> | ||
| */ | ||
| public function jsonSerialize(): array | ||
| { | ||
| return [ | ||
| 'id' => $this->id, | ||
| 'templateId' => $this->templateId, | ||
| 'locale' => $this->locale, | ||
| 'subject' => $this->subject, | ||
| 'message' => $this->body, | ||
| 'senderName' => $this->senderName, | ||
| 'senderEmail' => $this->senderEmail, | ||
| 'replyToEmail' => $this->replyToEmail, | ||
| 'replyToName' => $this->replyToName, | ||
| 'createdAt' => $this->createdAt, | ||
| 'updatedAt' => $this->updatedAt, | ||
| ]; | ||
| } | ||
|
|
||
| public static function getName(): string | ||
| { | ||
| return Resource::TYPE_PROJECT_EMAIL_TEMPLATE; | ||
| } | ||
|
|
||
| public function getGroup(): string | ||
| { | ||
| return Transfer::GROUP_PROJECTS; | ||
| } | ||
|
|
||
| public function getTemplateId(): string | ||
| { | ||
| return $this->templateId; | ||
| } | ||
|
|
||
| public function getLocale(): string | ||
| { | ||
| return $this->locale; | ||
| } | ||
|
|
||
| public function getSubject(): string | ||
| { | ||
| return $this->subject; | ||
| } | ||
|
|
||
| public function getBody(): string | ||
| { | ||
| return $this->body; | ||
| } | ||
|
|
||
| public function getSenderName(): string | ||
| { | ||
| return $this->senderName; | ||
| } | ||
|
|
||
| public function getSenderEmail(): string | ||
| { | ||
| return $this->senderEmail; | ||
| } | ||
|
|
||
| public function getReplyToEmail(): string | ||
| { | ||
| return $this->replyToEmail; | ||
| } | ||
|
|
||
| public function getReplyToName(): string | ||
| { | ||
| return $this->replyToName; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.