From 9c50c7eb2ae385a9444dde1147f78cf71f2a62b2 Mon Sep 17 00:00:00 2001 From: kaioken Date: Sun, 28 Jul 2024 20:38:52 -0400 Subject: [PATCH] refact: user welcome email --- src/Kanvas/Enums/AppSettingsEnums.php | 2 ++ src/Kanvas/Users/Services/UserNotificationService.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Kanvas/Enums/AppSettingsEnums.php b/src/Kanvas/Enums/AppSettingsEnums.php index a1d72f493..10a948cb2 100644 --- a/src/Kanvas/Enums/AppSettingsEnums.php +++ b/src/Kanvas/Enums/AppSettingsEnums.php @@ -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; @@ -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', diff --git a/src/Kanvas/Users/Services/UserNotificationService.php b/src/Kanvas/Users/Services/UserNotificationService.php index be733a870..cce8a9ef9 100644 --- a/src/Kanvas/Users/Services/UserNotificationService.php +++ b/src/Kanvas/Users/Services/UserNotificationService.php @@ -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) {