Files
api/services/nginx/app/routes/birdVoiceFlashCallsRoute.php
T
Jeppe B ab6c3ba5b6 Fix route permission instance calls (#344)
## Root cause

`route_t::hasPermission()` and `requirePermission()` are instance
methods. Route code was invoking them with `self::`; the new XL Vask
hall-scope helper made that call from a genuinely static context,
causing PHP to throw:

`Non-static method routes\\xlvaskUsageLogsRoute::hasPermission() cannot
be called statically`

## Changes

- Invoke route permission methods through `$this` across all 273
executable legacy calls in 45 route classes.
- Make `xlvaskUsageLogsRoute::allowedHallIdsForUser()` an instance
helper and update all 13 callers.
- Preserve the existing all-scope and own-scope hall selection rules.
- Add a token-aware regression test that rejects executable
`self::hasPermission()` and `self::requirePermission()` calls, while
ignoring comments.
- Add focused XL Vask tests for global scanner hall scope and
group-limited own scope.
- Update affected route contract assertions to the instance-call form.

## Verification

- PHP lint: all 53 changed PHP files
- Focused PHPStan: changed XL Vask route and both new regression tests —
clean
- Focused regression slice: 58 passed, 748 assertions
- Full local unit suite: 1,300 passed, 9,442 assertions (1 unrelated
existing warning, 1 environment skip)
- Full local API suite: 285 passed, 11,704 assertions
- Exact-SHA GitHub Tests workflow: all 7 jobs passed (unit, API,
integration, legacy, edge gateway, and supporting checks)
- Independent exact-SHA QA gate: PASS, no findings
- Independent exact-SHA security gate: PASS, no findings
- Independent exact-SHA reviewer gate: PASS, no findings
- Remote comparison: exactly one commit ahead of
`40b104abed7723a7d1b7028190ecda0e7aeef829`; all 53 remote blob hashes
matched the reviewed worktree

## Delivery state

Draft only for human review. No merge or deployment is included. Qodana
is skipped while the PR remains draft and is therefore not represented
as a passed gate.
2026-08-04 16:04:41 +02:00

135 lines
5.7 KiB
PHP

<?php
namespace routes;
require_once WD . '/classes/bird.php';
require_once WD . '/traits/route_t.php';
require_once WD . '/traits/bird_route_helpers_t.php';
require_once WD . '/traits/bird_route_validation_t.php';
require_once WD . '/modules/bird/helpers/bird_request_schemas.php';
require_once WD . '/modules/bird/helpers/bird_payloads.php';
use bird\helpers\bird_flash_create_payload;
use bird\helpers\bird_flash_end_payload;
use bird\helpers\bird_flash_hangup_payload;
use bird\helpers\bird_flash_list_query_payload;
use bird\helpers\bird_request_schemas;
use classes\bird;
use traits\bird_route_helpers_t;
use traits\bird_route_validation_t;
use traits\route_t;
class birdVoiceFlashCallsRoute
{
use route_t, bird_route_helpers_t, bird_route_validation_t;
public function run(): void
{
// Create a flash call
$this->post('/bird/voice/flash-calls', function () {
global $response;
$this->requirePermission('modules_bird_voice_flash_calls_create');
$client = new bird();
[$workspaceId, $channelId] = $this->birdResolveWorkspaceAndChannelIds($client);
$payload = $this->birdPayloadWithout(['workspaceId', 'channelId']);
$payload = $this->birdValidateSchema($payload, bird_request_schemas::flashCreateBody());
$payload = bird_flash_create_payload::fromArray($payload)->toArray();
$res = $client->createFlashCall($workspaceId, $channelId, $payload);
$response->success($res ?? ['status' => 'ok']);
}, [
'modules_bird_voice_flash_calls_create' => 'Create/place a flash call via Bird',
]);
// List flash calls
$this->get('/bird/voice/flash-calls', function () {
global $response;
$this->requirePermission('modules_bird_voice_flash_calls_list');
$client = new bird();
[$workspaceId, $channelId] = $this->birdResolveWorkspaceAndChannelIds($client);
$query = $this->birdPayloadWithout(['workspaceId', 'channelId']);
$query = $this->birdValidateSchema($query, bird_request_schemas::flashListQuery());
$query = bird_flash_list_query_payload::fromArray($query)->toArray();
$res = $client->listFlashCalls($workspaceId, $channelId, $query);
$response->success($res ?? []);
}, [
'modules_bird_voice_flash_calls_list' => 'List flash calls via Bird',
]);
// Get a specific flash call by ID
$this->get('/bird/voice/flash-calls/{id}', function () {
global $response;
$this->requirePermission('modules_bird_voice_flash_calls_get');
$client = new bird();
[$workspaceId, $channelId] = $this->birdResolveWorkspaceAndChannelIds($client);
$callId = $this->birdResolveRouteCallId();
$res = $client->getFlashCall($workspaceId, $channelId, $callId);
$response->success($res ?? []);
}, [
'modules_bird_voice_flash_calls_get' => 'Get a flash call by ID via Bird',
]);
// Complete/end a flash call by ID
$this->post('/bird/voice/flash-calls/{id}', function () {
global $response;
$this->requirePermission('modules_bird_voice_flash_calls_end');
$client = new bird();
[$workspaceId, $channelId] = $this->birdResolveWorkspaceAndChannelIds($client);
$callId = $this->birdResolveRouteCallId();
$payload = $this->birdPayloadWithout(['workspaceId', 'channelId']);
$payload = $this->birdValidateSchema($payload, bird_request_schemas::flashEndBody());
$payload = bird_flash_end_payload::fromArray($payload)->toArray();
$res = $client->endFlashCall($workspaceId, $channelId, $callId, $payload);
$response->success($res ?? ['status' => 'ok']);
}, [
'modules_bird_voice_flash_calls_end' => 'Complete/end a flash call by ID via Bird',
]);
// Hang up flash calls by payload
$this->post('/bird/voice/flash-calls/hangup', function () {
global $response;
$this->requirePermission('modules_bird_voice_flash_calls_hangup');
$client = new bird();
[$workspaceId, $channelId] = $this->birdResolveWorkspaceAndChannelIds($client);
$payload = $this->birdPayloadWithout(['workspaceId', 'channelId']);
$payload = $this->birdValidateSchema($payload, bird_request_schemas::flashHangupBody());
$payload = bird_flash_hangup_payload::fromArray($payload)->toArray();
$res = $client->hangupFlashCall($workspaceId, $channelId, $payload);
$response->success($res ?? ['status' => 'ok']);
}, [
'modules_bird_voice_flash_calls_hangup' => 'Hang up flash calls via Bird',
]);
// Compatibility alias for flash hangup endpoint
$this->post('/bird/voice/flash-calls/end', function () {
global $response;
$this->requirePermission('modules_bird_voice_flash_calls_end_by_numbers');
$client = new bird();
[$workspaceId, $channelId] = $this->birdResolveWorkspaceAndChannelIds($client);
$payload = $this->birdPayloadWithout(['workspaceId', 'channelId']);
$payload = $this->birdValidateSchema($payload, bird_request_schemas::flashHangupBody());
$payload = bird_flash_hangup_payload::fromArray($payload)->toArray();
$res = $client->hangupFlashCall($workspaceId, $channelId, $payload);
$response->success($res ?? ['status' => 'ok']);
}, [
'modules_bird_voice_flash_calls_end_by_numbers' => 'Compatibility alias for hanging up flash calls via Bird',
]);
}
}