diff --git a/resources/js/components/Notifications/Notification.vue b/resources/js/components/Notifications/Notification.vue index 6c0d72a9..7f7a2eb9 100644 --- a/resources/js/components/Notifications/Notification.vue +++ b/resources/js/components/Notifications/Notification.vue @@ -19,7 +19,7 @@ class="vue-feather text-theme shrink-0" /> diff --git a/routes/admin.php b/routes/admin.php index fdae8655..6b43e722 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -9,7 +9,6 @@ use Domain\Settings\Controllers\GetServerStatusController; use Domain\Settings\Controllers\GetSettingsValueController; use Domain\Admin\Controllers\Dashboard\GetNewbiesController; use Domain\Admin\Controllers\Users\ChangeUserRoleController; -use Domain\Settings\Controllers\StoreBroadcastServiceCredentialsController; use Domain\Settings\Controllers\UpdateSettingValueController; use Domain\Admin\Controllers\Users\ResetUserPasswordController; use Domain\Settings\Controllers\StoreEmailCredentialsController; @@ -23,6 +22,7 @@ use Domain\Admin\Controllers\Dashboard\GetLatestTransactionsController; use Domain\Admin\Controllers\Users\ChangeUserStorageCapacityController; use Domain\Settings\Controllers\StoreSocialServiceCredentialsController; use Domain\Settings\Controllers\StorePaymentServiceCredentialsController; +use Domain\Settings\Controllers\StoreBroadcastServiceCredentialsController; // Dashboard Route::group(['prefix' => 'dashboard'], function () { diff --git a/src/App/Console/Commands/SetupDevEnvironment.php b/src/App/Console/Commands/SetupDevEnvironment.php index 0b1a8afb..ec6c0d5d 100644 --- a/src/App/Console/Commands/SetupDevEnvironment.php +++ b/src/App/Console/Commands/SetupDevEnvironment.php @@ -122,9 +122,9 @@ class SetupDevEnvironment extends Command 'notifiable_id' => $howdy->id, 'data' => json_encode([ 'category' => 'team-invitation', - 'title' => 'New Team Invitation', - 'description' => 'Jane Doe invite you to join into Team Folder.', - 'action' => [ + 'title' => 'New Team Invitation', + 'description' => 'Jane Doe invite you to join into Team Folder.', + 'action' => [ 'type' => 'invitation', 'params' => [ 'id' => $invitation->id, @@ -161,9 +161,9 @@ class SetupDevEnvironment extends Command 'notifiable_id' => $howdy->id, 'data' => json_encode([ 'category' => 'file-request', - 'title' => 'File Request Filled', - 'description' => "Your file request for 'Shared Folder' folder was filled successfully.", - 'action' => [ + 'title' => 'File Request Filled', + 'description' => "Your file request for 'Shared Folder' folder was filled successfully.", + 'action' => [ 'type' => 'route', 'params' => [ 'route' => 'Files', diff --git a/src/App/Console/Kernel.php b/src/App/Console/Kernel.php index 90ec7515..8679a44c 100644 --- a/src/App/Console/Kernel.php +++ b/src/App/Console/Kernel.php @@ -5,7 +5,6 @@ use Illuminate\Console\Scheduling\Schedule; use App\Console\Commands\SetupDevEnvironment; use App\Console\Commands\SetupProdEnvironment; use Support\Scheduler\Actions\ReportUsageAction; -use App\Console\Commands\DemoNotificationDataCommand; use Support\Scheduler\Actions\DeleteFailedFilesAction; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Support\Scheduler\Actions\DeleteUnverifiedUsersAction; diff --git a/src/App/Users/Actions/AutoSubscribeForMeteredBillingAction.php b/src/App/Users/Actions/AutoSubscribeForMeteredBillingAction.php index cfc5b668..643cdf96 100644 --- a/src/App/Users/Actions/AutoSubscribeForMeteredBillingAction.php +++ b/src/App/Users/Actions/AutoSubscribeForMeteredBillingAction.php @@ -2,8 +2,8 @@ namespace App\Users\Actions; use App\Users\Models\User; -use App\Users\Notifications\RegistrationBonusAddedNotification; use VueFileManager\Subscription\Domain\Plans\Models\Plan; +use App\Users\Notifications\RegistrationBonusAddedNotification; class AutoSubscribeForMeteredBillingAction { diff --git a/src/Domain/Settings/Controllers/StoreBroadcastServiceCredentialsController.php b/src/Domain/Settings/Controllers/StoreBroadcastServiceCredentialsController.php index c7397448..baa80c40 100644 --- a/src/Domain/Settings/Controllers/StoreBroadcastServiceCredentialsController.php +++ b/src/Domain/Settings/Controllers/StoreBroadcastServiceCredentialsController.php @@ -1,10 +1,9 @@ runningUnitTests()) { + if (! app()->runningUnitTests()) { $credentials = [ 'pusher' => [ 'BROADCAST_DRIVER' => 'pusher', @@ -46,7 +45,7 @@ class StoreBroadcastServiceCredentialsController setEnvironmentValue($credentials[$request->input('driver')]); // Clear cache - if (!is_dev()) { + if (! is_dev()) { Artisan::call('cache:clear'); Artisan::call('config:clear'); Artisan::call('config:cache'); diff --git a/src/Domain/Settings/Requests/StoreBroadcastServiceCredentialsRequest.php b/src/Domain/Settings/Requests/StoreBroadcastServiceCredentialsRequest.php index 0f432a94..ad861564 100644 --- a/src/Domain/Settings/Requests/StoreBroadcastServiceCredentialsRequest.php +++ b/src/Domain/Settings/Requests/StoreBroadcastServiceCredentialsRequest.php @@ -1,5 +1,4 @@ runningUnitTests()) { + ): Response { + if (! app()->runningUnitTests()) { $setup = [ 'broadcasting' => [ 'pusher' => [ diff --git a/src/Domain/SetupWizard/Requests/StoreEnvironmentSetupRequest.php b/src/Domain/SetupWizard/Requests/StoreEnvironmentSetupRequest.php index 65c53756..fc09d9db 100644 --- a/src/Domain/SetupWizard/Requests/StoreEnvironmentSetupRequest.php +++ b/src/Domain/SetupWizard/Requests/StoreEnvironmentSetupRequest.php @@ -1,5 +1,4 @@ 'gift', + 'title' => "You Received {$this->bonus}", + 'description' => "You received credit bonus $this->bonus from us. Happy spending!", + ]; + } +} diff --git a/src/Domain/Subscriptions/Notifications/BillingAlertTriggeredNotification.php b/src/Domain/Subscriptions/Notifications/BillingAlertTriggeredNotification.php index f50b1377..6196036f 100644 --- a/src/Domain/Subscriptions/Notifications/BillingAlertTriggeredNotification.php +++ b/src/Domain/Subscriptions/Notifications/BillingAlertTriggeredNotification.php @@ -29,7 +29,7 @@ class BillingAlertTriggeredNotification extends Notification implements ShouldQu return [ 'category' => 'billing-alert', 'title' => 'billing Alert Reached!', - 'description' => "The billing alert you set previously has been reached. Please revise your spending.", + 'description' => 'The billing alert you set previously has been reached. Please revise your spending.', 'action' => [ 'type' => 'route', 'params' => [ diff --git a/src/Domain/Subscriptions/Notifications/InsufficientBalanceNotification.php b/src/Domain/Subscriptions/Notifications/InsufficientBalanceNotification.php new file mode 100644 index 00000000..200ebf15 --- /dev/null +++ b/src/Domain/Subscriptions/Notifications/InsufficientBalanceNotification.php @@ -0,0 +1,42 @@ +subject(__('Uh-oh! Your credit withdrawal for your pre-paid subscription failed')) + ->greeting(__('Hi there')) + ->line(__("It looks like your subscription credit withdrawal for your account didn't go through. Please make sure you have sufficient funds on your account and we'll give it another try!")) + ->action(__('Fund Your Account'), url('/user/settings/billing')); + } + + public function toArray(): array + { + return [ + 'category' => 'insufficient-balance', + 'title' => 'Withdrawal failed', + 'description' => "Your credit withdrawal for your account didn't go through. Please make sure you have sufficient funds on your account.", + 'action' => [ + 'type' => 'route', + 'params' => [ + 'route' => 'Billing', + 'button' => 'Show Billing', + ], + ], + ]; + } +} diff --git a/src/Domain/Subscriptions/Notifications/SubscriptionWasCreatedNotification.php b/src/Domain/Subscriptions/Notifications/SubscriptionWasCreatedNotification.php index 1445909f..505a3df5 100644 --- a/src/Domain/Subscriptions/Notifications/SubscriptionWasCreatedNotification.php +++ b/src/Domain/Subscriptions/Notifications/SubscriptionWasCreatedNotification.php @@ -13,7 +13,8 @@ class SubscriptionWasCreatedNotification extends Notification implements ShouldQ public function __construct( public Subscription $subscription, - ) {} + ) { + } public function via(): array { diff --git a/src/Support/Listeners/SubscriptionEventSubscriber.php b/src/Support/Listeners/SubscriptionEventSubscriber.php index 3fb61d3d..1a7c0e2e 100644 --- a/src/Support/Listeners/SubscriptionEventSubscriber.php +++ b/src/Support/Listeners/SubscriptionEventSubscriber.php @@ -1,17 +1,21 @@ subscription->user->limitations()->update([ @@ -39,11 +43,24 @@ class SubscriptionEventSubscriber ]); } + // TODO: unit test public function handleBillingAlertTriggeredEvent($event) { $event->alert->user->notify(new BillingAlertTriggeredNotification()); } + // TODO: unit test + public function handleAdminBonusAddedEvent($event) + { + $event->user->notify(new AdminBonusAddedNotification($event->bonus)); + } + + // TODO: unit test + public function handleInsufficientBalanceEvent($event) + { + $event->user->notify(new InsufficientBalanceNotification()); + } + /** * Register the listeners for the subscriber. */ @@ -54,6 +71,8 @@ class SubscriptionEventSubscriber SubscriptionWasExpired::class => 'handleSubscriptionWasExpired', SubscriptionWasUpdated::class => 'handleSubscriptionWasUpdated', BillingAlertTriggeredEvent::class => 'handleBillingAlertTriggeredEvent', + AdminBonusAddedEvent::class => 'handleAdminBonusAddedEvent', + InsufficientBalanceEvent::class => 'handleInsufficientBalanceEvent', ]; } } diff --git a/tests/App/Users/SignFlowTest.php b/tests/App/Users/SignFlowTest.php index e4510a33..365d14c1 100644 --- a/tests/App/Users/SignFlowTest.php +++ b/tests/App/Users/SignFlowTest.php @@ -1,7 +1,6 @@ 'user', 'attributes' => [ 'avatar' => null, - 'color' => $user->settings->color, + 'color' => $user->settings->color, 'email' => $user->email, 'role' => $user->role, 'socialite_account' => false, diff --git a/tests/Domain/Notifications/NotificationsTest.php b/tests/Domain/Notifications/NotificationsTest.php index b7205333..aa352471 100644 --- a/tests/Domain/Notifications/NotificationsTest.php +++ b/tests/Domain/Notifications/NotificationsTest.php @@ -25,9 +25,9 @@ class NotificationsTest extends TestCase 'notifiable_id' => $user->id, 'data' => json_encode([ 'category' => 'file-request', - 'title' => 'File Request Filled', - 'description' => "Your file request for 'Documents' folder was filled successfully.", - 'action' => [ + 'title' => 'File Request Filled', + 'description' => "Your file request for 'Documents' folder was filled successfully.", + 'action' => [ 'type' => 'route', 'params' => [ 'route' => 'Files',