Implement package limit notification system
This commit is contained in:
@@ -2,16 +2,39 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Events\Packages\EventPackageGalleryExpired;
|
||||
use App\Events\Packages\EventPackageGalleryExpiring;
|
||||
use App\Events\Packages\EventPackageGuestLimitReached;
|
||||
use App\Events\Packages\EventPackageGuestThresholdReached;
|
||||
use App\Events\Packages\EventPackagePhotoLimitReached;
|
||||
use App\Events\Packages\EventPackagePhotoThresholdReached;
|
||||
use App\Events\Packages\TenantCreditsLow;
|
||||
use App\Events\Packages\TenantPackageEventLimitReached;
|
||||
use App\Events\Packages\TenantPackageEventThresholdReached;
|
||||
use App\Events\Packages\TenantPackageExpired;
|
||||
use App\Events\Packages\TenantPackageExpiring;
|
||||
use App\Listeners\Packages\QueueGalleryExpiredNotification;
|
||||
use App\Listeners\Packages\QueueGalleryWarningNotification;
|
||||
use App\Listeners\Packages\QueueGuestLimitNotification;
|
||||
use App\Listeners\Packages\QueueGuestThresholdNotification;
|
||||
use App\Listeners\Packages\QueuePhotoLimitNotification;
|
||||
use App\Listeners\Packages\QueuePhotoThresholdNotification;
|
||||
use App\Listeners\Packages\QueueTenantCreditsLowNotification;
|
||||
use App\Listeners\Packages\QueueTenantEventLimitNotification;
|
||||
use App\Listeners\Packages\QueueTenantEventThresholdNotification;
|
||||
use App\Listeners\Packages\QueueTenantPackageExpiredNotification;
|
||||
use App\Listeners\Packages\QueueTenantPackageExpiringNotification;
|
||||
use App\Notifications\UploadPipelineFailed;
|
||||
use App\Services\Checkout\CheckoutAssignmentService;
|
||||
use App\Services\Checkout\CheckoutPaymentService;
|
||||
use App\Services\Checkout\CheckoutSessionService;
|
||||
use App\Notifications\UploadPipelineFailed;
|
||||
use App\Services\Security\PhotoSecurityScanner;
|
||||
use App\Services\Storage\EventStorageManager;
|
||||
use App\Services\Storage\StorageHealthService;
|
||||
use App\Services\Security\PhotoSecurityScanner;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Queue\Events\JobFailed;
|
||||
use Illuminate\Support\Facades\Event as EventFacade;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
@@ -40,25 +63,80 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
$this->app->make(EventStorageManager::class)->registerDynamicDisks();
|
||||
|
||||
EventFacade::listen(
|
||||
EventPackagePhotoThresholdReached::class,
|
||||
[QueuePhotoThresholdNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
EventPackagePhotoLimitReached::class,
|
||||
[QueuePhotoLimitNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
EventPackageGuestThresholdReached::class,
|
||||
[QueueGuestThresholdNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
EventPackageGuestLimitReached::class,
|
||||
[QueueGuestLimitNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
EventPackageGalleryExpiring::class,
|
||||
[QueueGalleryWarningNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
EventPackageGalleryExpired::class,
|
||||
[QueueGalleryExpiredNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
TenantPackageEventThresholdReached::class,
|
||||
[QueueTenantEventThresholdNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
TenantPackageEventLimitReached::class,
|
||||
[QueueTenantEventLimitNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
TenantPackageExpiring::class,
|
||||
[QueueTenantPackageExpiringNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
TenantPackageExpired::class,
|
||||
[QueueTenantPackageExpiredNotification::class, 'handle']
|
||||
);
|
||||
|
||||
EventFacade::listen(
|
||||
TenantCreditsLow::class,
|
||||
[QueueTenantCreditsLowNotification::class, 'handle']
|
||||
);
|
||||
|
||||
RateLimiter::for('tenant-api', function (Request $request) {
|
||||
$tenantId = $request->attributes->get('tenant_id')
|
||||
?? $request->user()?->tenant_id
|
||||
?? $request->user()?->tenant?->id;
|
||||
|
||||
$key = $tenantId ? 'tenant:' . $tenantId : ('ip:' . ($request->ip() ?? 'unknown'));
|
||||
$key = $tenantId ? 'tenant:'.$tenantId : ('ip:'.($request->ip() ?? 'unknown'));
|
||||
|
||||
return Limit::perMinute(100)->by($key);
|
||||
});
|
||||
|
||||
RateLimiter::for('oauth', function (Request $request) {
|
||||
return Limit::perMinute(10)->by('oauth:' . ($request->ip() ?? 'unknown'));
|
||||
return Limit::perMinute(10)->by('oauth:'.($request->ip() ?? 'unknown'));
|
||||
});
|
||||
|
||||
Inertia::share('locale', fn () => app()->getLocale());
|
||||
Inertia::share('analytics', static function () {
|
||||
$config = config('services.matomo');
|
||||
|
||||
if (!($config['enabled'] ?? false)) {
|
||||
if (! ($config['enabled'] ?? false)) {
|
||||
return [
|
||||
'matomo' => [
|
||||
'enabled' => false,
|
||||
|
||||
Reference in New Issue
Block a user