mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-13 16:55:01 +00:00
added AdminBonusAddedNotification.php and InsufficientBalanceNotification.php
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
class="vue-feather text-theme shrink-0"
|
||||
/>
|
||||
<alert-triangle-icon
|
||||
v-if="notification.data.attributes.category === 'billing-alert'"
|
||||
v-if="['billing-alert', 'insufficient-balance'].includes(notification.data.attributes.category)"
|
||||
size="22"
|
||||
class="vue-feather text-theme shrink-0"
|
||||
/>
|
||||
|
||||
+1
-1
@@ -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 () {
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Settings\Controllers;
|
||||
|
||||
use Artisan;
|
||||
use Domain\Settings\Requests\StoreBroadcastServiceCredentialsRequest;
|
||||
use Illuminate\Http\Response;
|
||||
use Domain\Settings\Requests\StoreBroadcastServiceCredentialsRequest;
|
||||
|
||||
class StoreBroadcastServiceCredentialsController
|
||||
{
|
||||
@@ -17,7 +16,7 @@ class StoreBroadcastServiceCredentialsController
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// Get and store credentials
|
||||
if (!app()->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');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Settings\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\SetupWizard\Controllers;
|
||||
|
||||
use Artisan;
|
||||
@@ -14,9 +13,8 @@ class StoreEnvironmentSettingsController extends Controller
|
||||
*/
|
||||
public function __invoke(
|
||||
StoreEnvironmentSetupRequest $request,
|
||||
): Response
|
||||
{
|
||||
if (!app()->runningUnitTests()) {
|
||||
): Response {
|
||||
if (! app()->runningUnitTests()) {
|
||||
$setup = [
|
||||
'broadcasting' => [
|
||||
'pusher' => [
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\SetupWizard\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace Domain\Subscriptions\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class AdminBonusAddedNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
public string $bonus
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*/
|
||||
public function via(mixed $notifiable): array
|
||||
{
|
||||
return ['database', 'broadcast'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*/
|
||||
public function toArray(mixed $notifiable): array
|
||||
{
|
||||
return [
|
||||
'category' => 'gift',
|
||||
'title' => "You Received {$this->bonus}",
|
||||
'description' => "You received credit bonus $this->bonus from us. Happy spending!",
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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' => [
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace Domain\Subscriptions\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class InsufficientBalanceNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
return ['mail', 'database', 'broadcast'];
|
||||
}
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->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',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ class SubscriptionWasCreatedNotification extends Notification implements ShouldQ
|
||||
|
||||
public function __construct(
|
||||
public Subscription $subscription,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function via(): array
|
||||
{
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Support\Listeners;
|
||||
|
||||
use Domain\Subscriptions\Notifications\BillingAlertTriggeredNotification;
|
||||
use Domain\Subscriptions\Notifications\SubscriptionWasCreatedNotification;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use VueFileManager\Subscription\Support\Events\BillingAlertTriggeredEvent;
|
||||
use Domain\Subscriptions\Notifications\AdminBonusAddedNotification;
|
||||
use VueFileManager\Subscription\Support\Events\AdminBonusAddedEvent;
|
||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasCreated;
|
||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasExpired;
|
||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasUpdated;
|
||||
use Domain\Subscriptions\Notifications\InsufficientBalanceNotification;
|
||||
use VueFileManager\Subscription\Support\Events\InsufficientBalanceEvent;
|
||||
use Domain\Subscriptions\Notifications\BillingAlertTriggeredNotification;
|
||||
use Domain\Subscriptions\Notifications\SubscriptionWasCreatedNotification;
|
||||
use VueFileManager\Subscription\Support\Events\BillingAlertTriggeredEvent;
|
||||
|
||||
class SubscriptionEventSubscriber
|
||||
{
|
||||
// TODO: unit test for notification
|
||||
public function handleSubscriptionWasCreated($event)
|
||||
{
|
||||
$event->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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace Tests\App\Users;
|
||||
|
||||
use App\Users\Notifications\RegistrationBonusAddedNotification;
|
||||
use Storage;
|
||||
use Notification;
|
||||
use Tests\TestCase;
|
||||
@@ -12,6 +11,7 @@ use Illuminate\Support\Facades\Password;
|
||||
use App\Users\Notifications\ResetPassword;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
||||
use App\Users\Notifications\RegistrationBonusAddedNotification;
|
||||
|
||||
class SignFlowTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ class UserAccountTest extends TestCase
|
||||
'type' => 'user',
|
||||
'attributes' => [
|
||||
'avatar' => null,
|
||||
'color' => $user->settings->color,
|
||||
'color' => $user->settings->color,
|
||||
'email' => $user->email,
|
||||
'role' => $user->role,
|
||||
'socialite_account' => false,
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user