diff --git a/changelog.md b/changelog.md index 330ee323..1b371448 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +## Version 2.0.16 +#### Release date: 8. April 2022 +- Test mailgun connection before storing your credentials into the app +- UI enhancements & fixes + ## Version 2.0.15 #### Release date: 6. April 2022 - Wasabi region list updated diff --git a/config/language-translations.php b/config/language-translations.php index ceff4b21..1e5c8d67 100644 --- a/config/language-translations.php +++ b/config/language-translations.php @@ -337,7 +337,7 @@ return [ 'clear_cache' => 'Clear Cache', 'admin_settings.others.contact_email' => 'Contact Email', 'admin_settings.others.contact_email_plac' => 'Type your contact email', - 'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in MB)', + 'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in GB)', 'admin_settings.others.default_storage_plac' => 'Set default storage space in GB', 'admin_settings.others.google_analytics' => 'Google Analytics Code (optional)', 'admin_settings.others.google_analytics_plac' => 'Paste your Google Analytics Code', @@ -551,8 +551,8 @@ return [ 'routes_title.users_user' => 'User', 'can_download_file' => 'Can download file', 'shared.editor' => 'Can edit and upload files', - 'shared.empty_shared' => "Nothing Shared Yet", - 'shared.empty_shared_desc' => "All items you share will be visible here.", + 'shared.empty_shared' => 'Nothing Shared Yet', + 'shared.empty_shared_desc' => 'All items you share will be visible here.', 'shared.visitor' => 'Can only view and download', 'awesome_iam_done' => 'Awesome, I’m done!', 'generate_link' => 'Generate Link', diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 81614b76..19dc7b86 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -6,7 +6,7 @@ "/chunks/status-check.js": "/chunks/status-check.js?id=f82f9939c1326fe2", "/chunks/purchase-code.js": "/chunks/purchase-code.js?id=df5bd89528649783", "/chunks/database.js": "/chunks/database.js?id=15cc488117dccf7b", - "/chunks/environment.js": "/chunks/environment.js?id=166cd302ba7338ae", + "/chunks/environment.js": "/chunks/environment.js?id=dfc24aa910b0c667", "/chunks/app-setup.js": "/chunks/app-setup.js?id=15938ff1ad2d6ed2", "/chunks/admin-account.js": "/chunks/admin-account.js?id=916450217130f3b8", "/chunks/shared.js": "/chunks/shared.js?id=ec06bf0d3ada0f65", @@ -42,7 +42,7 @@ "/chunks/app-settings.js": "/chunks/app-settings.js?id=55da23af2b076069", "/chunks/app-appearance.js": "/chunks/app-appearance.js?id=a694a01f3641712c", "/chunks/app-index.js": "/chunks/app-index.js?id=efdbfa062749ca00", - "/chunks/app-environment.js": "/chunks/app-environment.js?id=6e5e264c7417af60", + "/chunks/app-environment.js": "/chunks/app-environment.js?id=85670492c4e9fe78", "/chunks/app-others.js": "/chunks/app-others.js?id=abb8d96cd7c3a576", "/chunks/app-sign-in-out.js": "/chunks/app-sign-in-out.js?id=1cfffc99465b9a7a", "/chunks/app-adsense.js": "/chunks/app-adsense.js?id=a5dc9e715f8561bd", diff --git a/resources/js/store/modules/lists.js b/resources/js/store/modules/lists.js index 024b8e90..9724b297 100644 --- a/resources/js/store/modules/lists.js +++ b/resources/js/store/modules/lists.js @@ -31,7 +31,7 @@ const defaultState = { value: 'postmark', }, { - label: 'Log', + label: 'None (Log)', value: 'log', }, ], diff --git a/resources/js/views/Admin/AppSettings/AppSettingsTabs/Environment.vue b/resources/js/views/Admin/AppSettings/AppSettingsTabs/Environment.vue index 47c1c07a..9cd42a42 100644 --- a/resources/js/views/Admin/AppSettings/AppSettingsTabs/Environment.vue +++ b/resources/js/views/Admin/AppSettings/AppSettingsTabs/Environment.vue @@ -374,13 +374,12 @@ - + @@ -563,6 +562,16 @@ export default { value: 'none', }, ], + mailgunRegions: [ + { + label: 'US Endpoint (api.mailgun.net)', + value: 'api.mailgun.net', + }, + { + label: 'EU Endpoint (api.eu.mailgun.net)', + value: 'api.eu.mailgun.net', + }, + ], pusherClusters: [ { label: 'US East (N. Virginia)', diff --git a/resources/js/views/SetupWizard/EnvironmentSetup.vue b/resources/js/views/SetupWizard/EnvironmentSetup.vue index 89aabd33..e7ec1758 100644 --- a/resources/js/views/SetupWizard/EnvironmentSetup.vue +++ b/resources/js/views/SetupWizard/EnvironmentSetup.vue @@ -306,13 +306,12 @@ v-slot="{ errors }" > - + @@ -939,6 +938,16 @@ export default { value: 'none', }, ], + mailgunRegions: [ + { + label: 'US Endpoint (api.mailgun.net)', + value: 'api.mailgun.net', + }, + { + label: 'EU Endpoint (api.eu.mailgun.net)', + value: 'api.eu.mailgun.net', + }, + ], pusherClusters: [ { label: 'US East (N. Virginia)', diff --git a/src/App/Console/Kernel.php b/src/App/Console/Kernel.php index 167af946..048e47f9 100644 --- a/src/App/Console/Kernel.php +++ b/src/App/Console/Kernel.php @@ -5,6 +5,7 @@ use Illuminate\Console\Scheduling\Schedule; use App\Console\Commands\SetupDevEnvironment; use App\Console\Commands\SetupProdEnvironment; use Support\Scheduler\Actions\ReportUsageAction; +use Support\Upgrading\Actions\UpdateSystemAction; use Support\Demo\Actions\ClearHowdyDemoDataAction; use Support\Scheduler\Actions\DeleteFailedFilesAction; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -12,7 +13,6 @@ use Support\Scheduler\Actions\DeleteUnverifiedUsersAction; use Support\Scheduler\Actions\DeleteExpiredShareLinksAction; use App\Console\Commands\GenerateDemoSubscriptionContentCommand; use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction; -use Support\Upgrading\Actions\UpdateSystemAction; class Kernel extends ConsoleKernel { diff --git a/src/Domain/Settings/Actions/TestMailgunConnectionAction.php b/src/Domain/Settings/Actions/TestMailgunConnectionAction.php new file mode 100644 index 00000000..a7dfaa76 --- /dev/null +++ b/src/Domain/Settings/Actions/TestMailgunConnectionAction.php @@ -0,0 +1,45 @@ + [ + 'driver' => 'mailgun', + ], + 'services' => [ + 'mailgun' => [ + 'domain' => $credentials['domain'], + 'secret' => $credentials['secret'], + 'endpoint' => $credentials['endpoint'], + ], + ], + ]); + + // Send test email + Mail::to('test@hi5ve.digital')->send(new TestMail('example@domain.com')); + } catch (TransportException | LogicException $error) { + abort( + response()->json([ + 'type' => 'mailer-connection-error', + 'title' => 'Mail Connection Error', + 'message' => $error->getMessage(), + ], 401) + ); + } + } +} diff --git a/src/Domain/Settings/Actions/TestS3ConnectionAction.php b/src/Domain/Settings/Actions/TestS3ConnectionAction.php index c6953edc..16108804 100644 --- a/src/Domain/Settings/Actions/TestS3ConnectionAction.php +++ b/src/Domain/Settings/Actions/TestS3ConnectionAction.php @@ -2,31 +2,43 @@ namespace Domain\Settings\Actions; use Storage; +use Aws\S3\Exception\S3Exception; +use League\Flysystem\UnableToWriteFile; use Domain\Settings\DTO\S3CredentialsData; class TestS3ConnectionAction { public function __invoke(S3CredentialsData $credentials): void { - // Set temporary s3 connection - config([ - 'filesystems.disks.s3' => [ - 'driver' => 's3', - 'key' => $credentials->key, - 'secret' => $credentials->secret, - 'region' => $credentials->region, - 'bucket' => $credentials->bucket, - 'endpoint' => $credentials->endpoint, - ], - ]); + try { + // Set temporary s3 connection + config([ + 'filesystems.disks.s3' => [ + 'driver' => 's3', + 'key' => $credentials->key, + 'secret' => $credentials->secret, + 'region' => $credentials->region, + 'bucket' => $credentials->bucket, + 'endpoint' => $credentials->endpoint, + ], + ]); - // Try to get files - Storage::disk('s3')->allFiles(); + // Try to get files + Storage::disk('s3')->allFiles(); - // Try to create folder - Storage::disk('s3')->makeDirectory('s3-test'); + // Try to create folder + Storage::disk('s3')->makeDirectory('s3-test'); - // Delete test folder - Storage::disk('s3')->deleteDirectory('s3-test'); + // Delete test folder + Storage::disk('s3')->deleteDirectory('s3-test'); + } catch (S3Exception | UnableToWriteFile $error) { + abort( + response()->json([ + 'type' => 's3-connection-error', + 'title' => 'S3 Connection Error', + 'message' => $error->getMessage(), + ], 401) + ); + } } } diff --git a/src/Domain/Settings/Actions/TestSMTPConnectionAction.php b/src/Domain/Settings/Actions/TestSMTPConnectionAction.php new file mode 100644 index 00000000..1015e3eb --- /dev/null +++ b/src/Domain/Settings/Actions/TestSMTPConnectionAction.php @@ -0,0 +1,47 @@ + [ + 'driver' => 'smtp', + 'host' => $credentials['host'], + 'port' => $credentials['port'], + 'username' => $credentials['username'], + 'password' => $credentials['password'], + 'encryption' => $credentials['encryption'] ?? '', + 'from' => [ + 'address' => $credentials['email'] ?? $credentials['username'], + 'name' => $credentials['email'] ?? $credentials['username'], + ], + ]]); + + $sender = $credentials['email'] ?? $credentials['username']; + + // Send test email + Mail::to('test@hi5ve.digital')->send(new TestMail($sender)); + } catch (TransportException | LogicException $error) { + abort( + response()->json([ + 'type' => 'mailer-connection-error', + 'title' => 'Mail Connection Error', + 'message' => $error->getMessage(), + ], 401) + ); + } + } +} diff --git a/src/Domain/Settings/Controllers/StoreEmailCredentialsController.php b/src/Domain/Settings/Controllers/StoreEmailCredentialsController.php index f2d0d7a9..5c7cd5bd 100644 --- a/src/Domain/Settings/Controllers/StoreEmailCredentialsController.php +++ b/src/Domain/Settings/Controllers/StoreEmailCredentialsController.php @@ -1,57 +1,45 @@ runningUnitTests()) { - // Test smtp server - if ($request->input('mailDriver') === 'smtp') { - try { - // Get credentials - $credentials = [ - 'smtp' => [ - 'driver' => 'smtp', - 'host' => $request->input('smtp.host'), - 'port' => $request->input('smtp.port'), - 'username' => $request->input('smtp.username'), - 'password' => $request->input('smtp.password'), - 'encryption' => $request->input('smtp.encryption') ?? '', - 'from.address' => $request->input('smtp.email') ?? $request->input('smtp.username'), - 'from.name' => $request->input('smtp.email') ?? $request->input('smtp.username'), - ], - ]; - - // Set temporary mail connection - config(['mail' => $credentials['smtp']]); - - $sender = $request->input('smtp.email') ?? $request->input('smtp.username'); - - // Send test email - Mail::to('test@hi5ve.digital')->send(new TestMail($sender)); - } catch (TransportException|LogicException $error) { - return response([ - 'type' => 'mailer-connection-error', - 'title' => 'Mail Connection Error', - 'message' => $error->getMessage(), - ], 401); - } - } + // Test email connection + match ($request->input('mailDriver')) { + 'smtp' => ($this->testSMTPConnection)([ + 'host' => $request->input('smtp.host'), + 'port' => $request->input('smtp.port'), + 'username' => $request->input('smtp.username'), + 'password' => $request->input('smtp.password'), + 'encryption' => $request->input('smtp.encryption') ?? '', + 'email' => $request->input('smtp.email'), + ]), + 'mailgun' => ($this->testMailgunConnection)([ + 'domain' => $request->input('mailgun.domain'), + 'secret' => $request->input('mailgun.secret'), + 'endpoint' => $request->input('mailgun.endpoint'), + ]), + }; $mail = [ 'log' => [ @@ -61,7 +49,7 @@ class StoreEmailCredentialsController 'MAIL_DRIVER' => 'postmark', 'POSTMARK_TOKEN' => $request->input('postmark.token'), ], - 'smtp' => [ + 'smtp' => [ 'MAIL_DRIVER' => 'smtp', 'MAIL_HOST' => $request->input('smtp.host'), 'MAIL_PORT' => $request->input('smtp.port'), @@ -96,6 +84,6 @@ class StoreEmailCredentialsController Artisan::call('config:cache'); } - return response('Done', 204); + return response()->json('Done', 204); } } diff --git a/src/Domain/SetupWizard/Controllers/StoreEnvironmentSettingsController.php b/src/Domain/SetupWizard/Controllers/StoreEnvironmentSettingsController.php index fdb6fd31..f40710b5 100644 --- a/src/Domain/SetupWizard/Controllers/StoreEnvironmentSettingsController.php +++ b/src/Domain/SetupWizard/Controllers/StoreEnvironmentSettingsController.php @@ -1,23 +1,21 @@ runningUnitTests()) { // Test s3 credentials if ($request->input('storage.driver') !== 'local') { - try { - // connect to the s3 - ($this->testS3Connection)(S3CredentialsData::fromRequest($request)); - } catch (S3Exception | UnableToWriteFile $error) { - return response([ - 'type' => 's3-connection-error', - 'title' => 'S3 Connection Error', - 'message' => $error->getMessage(), - ], 401); - } + ($this->testS3Connection)(S3CredentialsData::fromRequest($request)); } - // Test smtp server - if ($request->input('mailDriver') === 'smtp') { - try { - // Get credentials - $credentials = [ - 'smtp' => [ - 'driver' => 'smtp', - 'host' => $request->input('smtp.host'), - 'port' => $request->input('smtp.port'), - 'username' => $request->input('smtp.username'), - 'password' => $request->input('smtp.password'), - 'encryption' => $request->input('smtp.encryption') ?? '', - 'from.address' => $request->input('smtp.email') ?? $request->input('smtp.username'), - 'from.name' => $request->input('smtp.email') ?? $request->input('smtp.username'), - ], - ]; - - // Set temporary mail connection - config(['mail' => $credentials['smtp']]); - - $sender = $request->input('smtp.email') ?? $request->input('smtp.username'); - - // Send test email - Mail::to('test@hi5ve.digital')->send(new TestMail($sender)); - } catch (TransportException|LogicException $error) { - return response([ - 'type' => 'mailer-connection-error', - 'title' => 'Mail Connection Error', - 'message' => $error->getMessage(), - ], 401); - } - } + // Test email connection + match ($request->input('mailDriver')) { + 'smtp' => ($this->testSMTPConnection)([ + 'host' => $request->input('smtp.host'), + 'port' => $request->input('smtp.port'), + 'username' => $request->input('smtp.username'), + 'password' => $request->input('smtp.password'), + 'encryption' => $request->input('smtp.encryption') ?? '', + 'email' => $request->input('smtp.email'), + ]), + 'mailgun' => ($this->testMailgunConnection)([ + 'domain' => $request->input('mailgun.domain'), + 'secret' => $request->input('mailgun.secret'), + 'endpoint' => $request->input('mailgun.endpoint'), + ]), + }; $setup = [ 'broadcasting' => [ @@ -118,7 +91,7 @@ class StoreEnvironmentSettingsController extends Controller 'MAIL_DRIVER' => 'postmark', 'POSTMARK_TOKEN' => $request->input('postmark.token'), ], - 'smtp' => [ + 'smtp' => [ 'MAIL_DRIVER' => 'smtp', 'MAIL_HOST' => $request->input('smtp.host'), 'MAIL_PORT' => $request->input('smtp.port'), @@ -174,6 +147,6 @@ class StoreEnvironmentSettingsController extends Controller Artisan::call('config:cache'); } - return response('Done', 204); + return response()->json('Done', 204); } } diff --git a/src/Support/Demo/Actions/FakeUploadFileAction.php b/src/Support/Demo/Actions/FakeUploadFileAction.php index 20db55f2..48f33cb4 100644 --- a/src/Support/Demo/Actions/FakeUploadFileAction.php +++ b/src/Support/Demo/Actions/FakeUploadFileAction.php @@ -2,7 +2,6 @@ namespace Support\Demo\Actions; use ByteUnits\Metric; -use Domain\Sharing\Resources\ShareResource; use Illuminate\Support\Str; use Domain\Files\Requests\UploadRequest; diff --git a/src/Support/Upgrading/Controllers/UpgradingVersionsController.php b/src/Support/Upgrading/Controllers/UpgradingVersionsController.php index 5ab34bb3..86d60024 100644 --- a/src/Support/Upgrading/Controllers/UpgradingVersionsController.php +++ b/src/Support/Upgrading/Controllers/UpgradingVersionsController.php @@ -121,9 +121,10 @@ class UpgradingVersionsController public function upgrade_to_2_0_16(): void { ($this->updateLanguageStrings)([ - 'write_feedback' => 'Help Us Improve', - 'change_password' => 'Security & API', - 'shared.empty_shared' => "Nothing Shared Yet", + 'write_feedback' => 'Help Us Improve', + 'change_password' => 'Security & API', + 'shared.empty_shared' => 'Nothing Shared Yet', + 'admin_settings.others.default_storage' => 'Default Storage Space for User Accounts (in GB)', ]); Artisan::call('cache:clear');