Skip to content

Commit

Permalink
Merge pull request #1742 from bakaphp/refact-user-reminder-emails
Browse files Browse the repository at this point in the history
refact: user welcome email
  • Loading branch information
kaioken committed Jul 29, 2024
2 parents 967e1c5 + 21549fe commit 7039f8b
Show file tree
Hide file tree
Showing 2 changed files with 6 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
5 changes: 4 additions & 1 deletion src/Kanvas/Users/Services/UserNotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ 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 7039f8b

Please sign in to comment.