Feature/312 363 364 publish redis external account

This commit is contained in:
Timothée Jaussoin 2025-07-24 14:53:30 +00:00
parent 507e913241
commit 4d0c713174
5 changed files with 53 additions and 12 deletions

View file

@ -67,6 +67,9 @@ v2.0
- Fix FLEXIAPI-354 Fix contact deletion
- Fix FLEXIAPI-360 Add rules on some jobs to only run them in the Gitlab pipeline when needed
- Fix FLEXIAPI-362 Return an empty object and not an empty array in the vcards-storage index endpoint to prevent some parsing issues in the clients
- Fix FLEXIAPI-312 Add Redis publish event when updating the externalAccount to ping the Flexisip B2BUA
- Fix FLEXIAPI-363 Send the Redis publish event when the externalAccount is deleted to ping the Flexisip B2BUA
- Fix FLEXIAPI-364 Fix a faulty redirection in the ExternalAccount controller
v1.6
----

View file

@ -43,25 +43,22 @@ class ExternalAccountController extends Controller
public function store(CreateUpdate $request, int $accountId)
{
$externalAccount = (new AccountService)->storeExternalAccount($request, $accountId);
(new AccountService)->storeExternalAccount($request, $accountId);
return redirect()->route('admin.account.show', $externalAccount->account->id);
return redirect()->route('admin.account.show', $accountId);
}
public function delete(int $accountId)
{
$account = Account::findOrFail($accountId);
return view('admin.account.external.delete', [
'account' => $account
'account' => Account::findOrFail($accountId)
]);
}
public function destroy(int $accountId)
{
$account = Account::findOrFail($accountId);
$account->external->delete();
(new AccountService)->deleteExternalAccount($accountId);
return redirect()->route('admin.account.show', $account->id);
return redirect()->route('admin.account.show', $accountId);
}
}

View file

@ -42,7 +42,6 @@ class ExternalAccountController extends Controller
public function destroy(int $accountId)
{
$account = Account::findOrFail($accountId);
return $account->external->delete();
return (new AccountService)->deleteExternalAccount($accountId);
}
}

View file

@ -20,6 +20,8 @@
namespace App\Libraries;
use App\Device;
use App\ExternalAccount;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Log;
use stdClass;
@ -54,4 +56,21 @@ class FlexisipRedisConnector
Log::error('Redis server issue: ' . $th->getMessage());
}
}
public function pingB2BUA(ExternalAccount $externalAccount): bool
{
try {
Redis::publish('flexisip/B2BUA/account', json_encode([
'username' => $externalAccount->username,
'domain' => $externalAccount->domain,
'identifier' => "$externalAccount->id"
]));
return true;
} catch (\Throwable $th) {
Log::error('Redis server issue: ' . $th->getMessage());
}
return false;
}
}

View file

@ -26,17 +26,20 @@ use App\EmailChangeCode;
use App\ExternalAccount;
use App\Http\Requests\Account\Create\Request as CreateRequest;
use App\Http\Requests\Account\Update\Request as UpdateRequest;
use App\Libraries\FlexisipRedisConnector;
use App\Libraries\OvhSMS;
use App\Mail\NewsletterRegistration;
use App\Mail\RecoverByCode;
use App\Mail\RegisterValidation;
use App\PhoneChangeCode;
use App\Rules\FilteredPhone;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
use Illuminate\Support\Facades\Mail;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Validation\Rule;
class AccountService
@ -194,8 +197,15 @@ class AccountService
public function destroy(Request $request, int $accountId)
{
$account = Account::findOrFail($accountId);
$externalAccount = $account->external;
$account->delete();
if ($externalAccount) {
(new FlexisipRedisConnector)->pingB2BUA($externalAccount);
}
Log::channel('events')->info(
'Account Service: Account destroyed',
['id' => $account->identifier]
@ -443,6 +453,19 @@ class AccountService
$externalAccount->save();
(new FlexisipRedisConnector)->pingB2BUA($externalAccount);
return $externalAccount;
}
public function deleteExternalAccount(int $accountId)
{
$account = Account::findOrFail($accountId);
$externalAccount = $account->external;
if ($externalAccount) {
(new FlexisipRedisConnector)->pingB2BUA($externalAccount);
return $externalAccount->delete();
}
}
}