Fix FLEXIAPI-271 Handle properly reversed attributes in objects

This commit is contained in:
Timothée Jaussoin 2025-02-18 12:01:09 +01:00
parent ac74ad31f4
commit cc9fb24db1
5 changed files with 24 additions and 21 deletions

View file

@ -21,6 +21,7 @@ v1.7
- Fix FLEXIAPI-269 Update the IsNotPhoneNumber rule to use a better phone number validator - Fix FLEXIAPI-269 Update the IsNotPhoneNumber rule to use a better phone number validator
- Fix FLEXIAPI-258 Move DotEnv instance configurations in the Spaces table - Fix FLEXIAPI-258 Move DotEnv instance configurations in the Spaces table
- Fix FLEXIAPI-270 Call the static $apnsTypes attribute in FlexisipPusherConnector - Fix FLEXIAPI-270 Call the static $apnsTypes attribute in FlexisipPusherConnector
- Fix FLEXIAPI-271 Handle properly reversed attributes in objects
v1.6 v1.6
---- ----

View file

@ -55,9 +55,11 @@ function generateNonce(): string
return Str::random(32); return Str::random(32);
} }
function getRequestBoolean(Request $request, string $key): bool function getRequestBoolean(Request $request, string $key, bool $reversed = false): bool
{ {
return $request->has($key) ? $request->get($key) == "on" : false; $bool = $request->has($key) ? $request->get($key) == "on" : false;
return $reversed ? !$bool : $bool;
} }
function generateValidNonce(Account $account): string function generateValidNonce(Account $account): string

View file

@ -169,17 +169,17 @@ class SpaceController extends Controller
'max_account' => 'required|integer', 'max_account' => 'required|integer',
]); ]);
$space->disable_chat_feature = getRequestBoolean($request, 'disable_chat_feature'); $space->disable_chat_feature = getRequestBoolean($request, 'disable_chat_feature', reversed: true);
$space->disable_meetings_feature = getRequestBoolean($request, 'disable_meetings_feature'); $space->disable_meetings_feature = getRequestBoolean($request, 'disable_meetings_feature', reversed: true);
$space->disable_broadcast_feature = getRequestBoolean($request, 'disable_broadcast_feature'); $space->disable_broadcast_feature = getRequestBoolean($request, 'disable_broadcast_feature', reversed: true);
$space->hide_settings = getRequestBoolean($request, 'hide_settings'); $space->hide_settings = getRequestBoolean($request, 'hide_settings', reversed: true);
$space->max_account = $request->get('max_account', 0); $space->max_account = $request->get('max_account', 0);
$space->hide_account_settings = getRequestBoolean($request, 'hide_account_settings'); $space->hide_account_settings = getRequestBoolean($request, 'hide_account_settings', reversed: true);
$space->disable_call_recordings_feature = getRequestBoolean($request, 'disable_call_recordings_feature'); $space->disable_call_recordings_feature = getRequestBoolean($request, 'disable_call_recordings_feature', reversed: true);
$space->only_display_sip_uri_username = getRequestBoolean($request, 'only_display_sip_uri_username'); $space->only_display_sip_uri_username = getRequestBoolean($request, 'only_display_sip_uri_username');
$space->assistant_hide_create_account = getRequestBoolean($request, 'assistant_hide_create_account'); $space->assistant_hide_create_account = getRequestBoolean($request, 'assistant_hide_create_account', reversed: true);
$space->assistant_disable_qr_code = getRequestBoolean($request, 'assistant_disable_qr_code'); $space->assistant_disable_qr_code = getRequestBoolean($request, 'assistant_disable_qr_code', reversed: true);
$space->assistant_hide_third_party_account = getRequestBoolean($request, 'assistant_hide_third_party_account'); $space->assistant_hide_third_party_account = getRequestBoolean($request, 'assistant_hide_third_party_account', reversed: true);
return $space; return $space;
} }

View file

@ -27,12 +27,12 @@
<h3 class="large">Features</h3> <h3 class="large">Features</h3>
@include('parts.form.toggle', ['object' => $space, 'key' => 'disable_chat_feature', 'label' => 'Chat feature', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'disable_chat_feature', 'label' => 'Chat feature', 'reversed' => true])
@include('parts.form.toggle', ['object' => $space, 'key' => 'disable_meetings_feature', 'label' => 'Meeting feature', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'disable_meetings_feature', 'label' => 'Meeting feature', 'reversed' => true])
@include('parts.form.toggle', ['object' => $space, 'key' => 'disable_broadcast_feature', 'label' => 'Conference feature', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'disable_broadcast_feature', 'label' => 'Conference feature', 'reversed' => true])
@include('parts.form.toggle', ['object' => $space, 'key' => 'hide_settings', 'label' => 'General settings', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'hide_settings', 'label' => 'General settings', 'reversed' => true])
@include('parts.form.toggle', ['object' => $space, 'key' => 'hide_account_settings', 'label' => 'Account settings', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'hide_account_settings', 'label' => 'Account settings', 'reversed' => true])
@include('parts.form.toggle', ['object' => $space, 'key' => 'disable_call_recordings_feature', 'label' => 'Record audio/video calls', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'disable_call_recordings_feature', 'label' => 'Record audio/video calls', 'reversed' => true])
<h3 class="large">General toggles</h3> <h3 class="large">General toggles</h3>
@ -50,9 +50,9 @@
<h3 class="large">Assistant</h3> <h3 class="large">Assistant</h3>
@include('parts.form.toggle', ['object' => $space, 'key' => 'assistant_hide_create_account', 'label' => 'Account creation panel', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'assistant_hide_create_account', 'label' => 'Account creation panel', 'reversed' => true])
@include('parts.form.toggle', ['object' => $space, 'key' => 'assistant_disable_qr_code', 'label' => 'QR Code scanning panel', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'assistant_disable_qr_code', 'label' => 'QR Code scanning panel', 'reversed' => true])
@include('parts.form.toggle', ['object' => $space, 'key' => 'assistant_hide_third_party_account', 'label' => 'Third party SIP panel', 'reverse' => true]) @include('parts.form.toggle', ['object' => $space, 'key' => 'assistant_hide_third_party_account', 'label' => 'Third party SIP panel', 'reversed' => true])
<div class="large"> <div class="large">
<input class="btn" type="submit" value="Update"> <input class="btn" type="submit" value="Update">

View file

@ -1,5 +1,5 @@
<div class="checkbox"> <div class="checkbox">
<input id="{{ $key }}" type="checkbox" @if ($object->$key || (isset($reversed) && $reversed && !$object->$key)) checked @endif name="{{ $key }}"> <input id="{{ $key }}" type="checkbox" @if ((!isset($reversed) && $object->$key) || (isset($reversed) && $reversed && !$object->$key)) checked @endif name="{{ $key }}">
<label for="{{ $key }}"></label> <label for="{{ $key }}"></label>
<div> <div>
<p>{{ $label }}</p> <p>{{ $label }}</p>