Deploy Ladill Queue / deploy (push) Successful in 28s
Poll displays every 1.2s with client-side TTS ack; expose service API for sibling apps; redesign tickets, counters, and staff console. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1010 B
PHP
32 lines
1010 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\Organization;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class EnsureQueueIntegration
|
|
{
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
$caller = (string) $request->attributes->get('service_caller', '');
|
|
if (! in_array($caller, ['care', 'frontdesk'], true)) {
|
|
return $next($request);
|
|
}
|
|
|
|
$owner = trim((string) ($request->input('owner') ?? $request->query('owner', '')));
|
|
if ($owner === '') {
|
|
return response()->json(['error' => 'The owner parameter is required.'], 422);
|
|
}
|
|
|
|
$organization = Organization::owned($owner)->first();
|
|
if (! $organization || ! data_get($organization->settings, 'integrations.'.$caller.'_enabled', false)) {
|
|
return response()->json(['error' => 'Queue integration is not enabled for this account.'], 403);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|