mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-30 15:44:41 +00:00
added AdminBonusAddedNotification.php and InsufficientBalanceNotification.php
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
class="vue-feather text-theme shrink-0"
|
class="vue-feather text-theme shrink-0"
|
||||||
/>
|
/>
|
||||||
<alert-triangle-icon
|
<alert-triangle-icon
|
||||||
v-if="notification.data.attributes.category === 'billing-alert'"
|
v-if="['billing-alert', 'insufficient-balance'].includes(notification.data.attributes.category)"
|
||||||
size="22"
|
size="22"
|
||||||
class="vue-feather text-theme shrink-0"
|
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\Settings\Controllers\GetSettingsValueController;
|
||||||
use Domain\Admin\Controllers\Dashboard\GetNewbiesController;
|
use Domain\Admin\Controllers\Dashboard\GetNewbiesController;
|
||||||
use Domain\Admin\Controllers\Users\ChangeUserRoleController;
|
use Domain\Admin\Controllers\Users\ChangeUserRoleController;
|
||||||
use Domain\Settings\Controllers\StoreBroadcastServiceCredentialsController;
|
|
||||||
use Domain\Settings\Controllers\UpdateSettingValueController;
|
use Domain\Settings\Controllers\UpdateSettingValueController;
|
||||||
use Domain\Admin\Controllers\Users\ResetUserPasswordController;
|
use Domain\Admin\Controllers\Users\ResetUserPasswordController;
|
||||||
use Domain\Settings\Controllers\StoreEmailCredentialsController;
|
use Domain\Settings\Controllers\StoreEmailCredentialsController;
|
||||||
@@ -23,6 +22,7 @@ use Domain\Admin\Controllers\Dashboard\GetLatestTransactionsController;
|
|||||||
use Domain\Admin\Controllers\Users\ChangeUserStorageCapacityController;
|
use Domain\Admin\Controllers\Users\ChangeUserStorageCapacityController;
|
||||||
use Domain\Settings\Controllers\StoreSocialServiceCredentialsController;
|
use Domain\Settings\Controllers\StoreSocialServiceCredentialsController;
|
||||||
use Domain\Settings\Controllers\StorePaymentServiceCredentialsController;
|
use Domain\Settings\Controllers\StorePaymentServiceCredentialsController;
|
||||||
|
use Domain\Settings\Controllers\StoreBroadcastServiceCredentialsController;
|
||||||
|
|
||||||
// Dashboard
|
// Dashboard
|
||||||
Route::group(['prefix' => 'dashboard'], function () {
|
Route::group(['prefix' => 'dashboard'], function () {
|
||||||
|
|||||||
@@ -122,9 +122,9 @@ class SetupDevEnvironment extends Command
|
|||||||
'notifiable_id' => $howdy->id,
|
'notifiable_id' => $howdy->id,
|
||||||
'data' => json_encode([
|
'data' => json_encode([
|
||||||
'category' => 'team-invitation',
|
'category' => 'team-invitation',
|
||||||
'title' => 'New Team Invitation',
|
'title' => 'New Team Invitation',
|
||||||
'description' => 'Jane Doe invite you to join into Team Folder.',
|
'description' => 'Jane Doe invite you to join into Team Folder.',
|
||||||
'action' => [
|
'action' => [
|
||||||
'type' => 'invitation',
|
'type' => 'invitation',
|
||||||
'params' => [
|
'params' => [
|
||||||
'id' => $invitation->id,
|
'id' => $invitation->id,
|
||||||
@@ -161,9 +161,9 @@ class SetupDevEnvironment extends Command
|
|||||||
'notifiable_id' => $howdy->id,
|
'notifiable_id' => $howdy->id,
|
||||||
'data' => json_encode([
|
'data' => json_encode([
|
||||||
'category' => 'file-request',
|
'category' => 'file-request',
|
||||||
'title' => 'File Request Filled',
|
'title' => 'File Request Filled',
|
||||||
'description' => "Your file request for 'Shared Folder' folder was filled successfully.",
|
'description' => "Your file request for 'Shared Folder' folder was filled successfully.",
|
||||||
'action' => [
|
'action' => [
|
||||||
'type' => 'route',
|
'type' => 'route',
|
||||||
'params' => [
|
'params' => [
|
||||||
'route' => 'Files',
|
'route' => 'Files',
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use Illuminate\Console\Scheduling\Schedule;
|
|||||||
use App\Console\Commands\SetupDevEnvironment;
|
use App\Console\Commands\SetupDevEnvironment;
|
||||||
use App\Console\Commands\SetupProdEnvironment;
|
use App\Console\Commands\SetupProdEnvironment;
|
||||||
use Support\Scheduler\Actions\ReportUsageAction;
|
use Support\Scheduler\Actions\ReportUsageAction;
|
||||||
use App\Console\Commands\DemoNotificationDataCommand;
|
|
||||||
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
|
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
namespace App\Users\Actions;
|
namespace App\Users\Actions;
|
||||||
|
|
||||||
use App\Users\Models\User;
|
use App\Users\Models\User;
|
||||||
use App\Users\Notifications\RegistrationBonusAddedNotification;
|
|
||||||
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
||||||
|
use App\Users\Notifications\RegistrationBonusAddedNotification;
|
||||||
|
|
||||||
class AutoSubscribeForMeteredBillingAction
|
class AutoSubscribeForMeteredBillingAction
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\Settings\Controllers;
|
namespace Domain\Settings\Controllers;
|
||||||
|
|
||||||
use Artisan;
|
use Artisan;
|
||||||
use Domain\Settings\Requests\StoreBroadcastServiceCredentialsRequest;
|
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
use Domain\Settings\Requests\StoreBroadcastServiceCredentialsRequest;
|
||||||
|
|
||||||
class StoreBroadcastServiceCredentialsController
|
class StoreBroadcastServiceCredentialsController
|
||||||
{
|
{
|
||||||
@@ -17,7 +16,7 @@ class StoreBroadcastServiceCredentialsController
|
|||||||
abort_if(is_demo(), 204, 'Done.');
|
abort_if(is_demo(), 204, 'Done.');
|
||||||
|
|
||||||
// Get and store credentials
|
// Get and store credentials
|
||||||
if (!app()->runningUnitTests()) {
|
if (! app()->runningUnitTests()) {
|
||||||
$credentials = [
|
$credentials = [
|
||||||
'pusher' => [
|
'pusher' => [
|
||||||
'BROADCAST_DRIVER' => 'pusher',
|
'BROADCAST_DRIVER' => 'pusher',
|
||||||
@@ -46,7 +45,7 @@ class StoreBroadcastServiceCredentialsController
|
|||||||
setEnvironmentValue($credentials[$request->input('driver')]);
|
setEnvironmentValue($credentials[$request->input('driver')]);
|
||||||
|
|
||||||
// Clear cache
|
// Clear cache
|
||||||
if (!is_dev()) {
|
if (! is_dev()) {
|
||||||
Artisan::call('cache:clear');
|
Artisan::call('cache:clear');
|
||||||
Artisan::call('config:clear');
|
Artisan::call('config:clear');
|
||||||
Artisan::call('config:cache');
|
Artisan::call('config:cache');
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\Settings\Requests;
|
namespace Domain\Settings\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\SetupWizard\Controllers;
|
namespace Domain\SetupWizard\Controllers;
|
||||||
|
|
||||||
use Artisan;
|
use Artisan;
|
||||||
@@ -14,9 +13,8 @@ class StoreEnvironmentSettingsController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function __invoke(
|
public function __invoke(
|
||||||
StoreEnvironmentSetupRequest $request,
|
StoreEnvironmentSetupRequest $request,
|
||||||
): Response
|
): Response {
|
||||||
{
|
if (! app()->runningUnitTests()) {
|
||||||
if (!app()->runningUnitTests()) {
|
|
||||||
$setup = [
|
$setup = [
|
||||||
'broadcasting' => [
|
'broadcasting' => [
|
||||||
'pusher' => [
|
'pusher' => [
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Domain\SetupWizard\Requests;
|
namespace Domain\SetupWizard\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
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 [
|
return [
|
||||||
'category' => 'billing-alert',
|
'category' => 'billing-alert',
|
||||||
'title' => 'billing Alert Reached!',
|
'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' => [
|
'action' => [
|
||||||
'type' => 'route',
|
'type' => 'route',
|
||||||
'params' => [
|
'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 function __construct(
|
||||||
public Subscription $subscription,
|
public Subscription $subscription,
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
public function via(): array
|
public function via(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Support\Listeners;
|
namespace Support\Listeners;
|
||||||
|
|
||||||
use Domain\Subscriptions\Notifications\BillingAlertTriggeredNotification;
|
|
||||||
use Domain\Subscriptions\Notifications\SubscriptionWasCreatedNotification;
|
|
||||||
use Illuminate\Events\Dispatcher;
|
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\SubscriptionWasCreated;
|
||||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasExpired;
|
use VueFileManager\Subscription\Support\Events\SubscriptionWasExpired;
|
||||||
use VueFileManager\Subscription\Support\Events\SubscriptionWasUpdated;
|
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
|
class SubscriptionEventSubscriber
|
||||||
{
|
{
|
||||||
|
// TODO: unit test for notification
|
||||||
public function handleSubscriptionWasCreated($event)
|
public function handleSubscriptionWasCreated($event)
|
||||||
{
|
{
|
||||||
$event->subscription->user->limitations()->update([
|
$event->subscription->user->limitations()->update([
|
||||||
@@ -39,11 +43,24 @@ class SubscriptionEventSubscriber
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: unit test
|
||||||
public function handleBillingAlertTriggeredEvent($event)
|
public function handleBillingAlertTriggeredEvent($event)
|
||||||
{
|
{
|
||||||
$event->alert->user->notify(new BillingAlertTriggeredNotification());
|
$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.
|
* Register the listeners for the subscriber.
|
||||||
*/
|
*/
|
||||||
@@ -54,6 +71,8 @@ class SubscriptionEventSubscriber
|
|||||||
SubscriptionWasExpired::class => 'handleSubscriptionWasExpired',
|
SubscriptionWasExpired::class => 'handleSubscriptionWasExpired',
|
||||||
SubscriptionWasUpdated::class => 'handleSubscriptionWasUpdated',
|
SubscriptionWasUpdated::class => 'handleSubscriptionWasUpdated',
|
||||||
BillingAlertTriggeredEvent::class => 'handleBillingAlertTriggeredEvent',
|
BillingAlertTriggeredEvent::class => 'handleBillingAlertTriggeredEvent',
|
||||||
|
AdminBonusAddedEvent::class => 'handleAdminBonusAddedEvent',
|
||||||
|
InsufficientBalanceEvent::class => 'handleInsufficientBalanceEvent',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Tests\App\Users;
|
namespace Tests\App\Users;
|
||||||
|
|
||||||
use App\Users\Notifications\RegistrationBonusAddedNotification;
|
|
||||||
use Storage;
|
use Storage;
|
||||||
use Notification;
|
use Notification;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -12,6 +11,7 @@ use Illuminate\Support\Facades\Password;
|
|||||||
use App\Users\Notifications\ResetPassword;
|
use App\Users\Notifications\ResetPassword;
|
||||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||||
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
||||||
|
use App\Users\Notifications\RegistrationBonusAddedNotification;
|
||||||
|
|
||||||
class SignFlowTest extends TestCase
|
class SignFlowTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class UserAccountTest extends TestCase
|
|||||||
'type' => 'user',
|
'type' => 'user',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'avatar' => null,
|
'avatar' => null,
|
||||||
'color' => $user->settings->color,
|
'color' => $user->settings->color,
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'role' => $user->role,
|
'role' => $user->role,
|
||||||
'socialite_account' => false,
|
'socialite_account' => false,
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ class NotificationsTest extends TestCase
|
|||||||
'notifiable_id' => $user->id,
|
'notifiable_id' => $user->id,
|
||||||
'data' => json_encode([
|
'data' => json_encode([
|
||||||
'category' => 'file-request',
|
'category' => 'file-request',
|
||||||
'title' => 'File Request Filled',
|
'title' => 'File Request Filled',
|
||||||
'description' => "Your file request for 'Documents' folder was filled successfully.",
|
'description' => "Your file request for 'Documents' folder was filled successfully.",
|
||||||
'action' => [
|
'action' => [
|
||||||
'type' => 'route',
|
'type' => 'route',
|
||||||
'params' => [
|
'params' => [
|
||||||
'route' => 'Files',
|
'route' => 'Files',
|
||||||
|
|||||||
Reference in New Issue
Block a user