Skip to content

Commit

Permalink
refact: user welcome email
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Jul 29, 2024
1 parent 967e1c5 commit 9c50c7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Kanvas/Enums/AppSettingsEnums.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum AppSettingsEnums implements EnumsInterface
case DEFAULT_COUNTRY;
case DEFAULT_LANGUAGE;
case SEND_WELCOME_EMAIL;
case WELCOME_EMAIL_CONFIG;
case SEND_CREATE_USER_EMAIL;
case ONBOARDING_GUILD_SETUP;
case ONBOARDING_INVENTORY_SETUP;
Expand All @@ -38,6 +39,7 @@ public function getValue(): mixed
self::DEFAULT_COUNTRY => 'default_user_country',
self::DEFAULT_LANGUAGE => 'language',
self::SEND_WELCOME_EMAIL => 'send_welcome_email',
self::WELCOME_EMAIL_CONFIG => 'welcome_email_template_config',
self::SEND_CREATE_USER_EMAIL => 'send_create_user_email',
self::ONBOARDING_GUILD_SETUP => 'onboarding_guild_setup',
self::ONBOARDING_INVENTORY_SETUP => 'onboarding_inventory_setup',
Expand Down
6 changes: 5 additions & 1 deletion src/Kanvas/Users/Services/UserNotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ public static function sendWelcomeEmail(
): void {
try {
if ($app->get((string) AppSettingsEnums::SEND_WELCOME_EMAIL->getValue())) {

$welcomeEmailConfig = $app->get((string) AppSettingsEnums::WELCOME_EMAIL_CONFIG->getValue()) ?? [];

$title = $welcomeEmailConfig['title'] ?? 'Welcome to ' . $app->name;
$user->notify(new Welcome(
$user,
$company ? ['company' => $company, 'subject' => 'Welcome to ' . $company->name, 'app' => $app] : ['app' => $app]
$company ? ['company' => $company, 'subject' => $title, 'app' => $app] : ['app' => $app]
));
}
} catch (Throwable $e) {
Expand Down

0 comments on commit 9c50c7e

Please sign in to comment.