From dcbd01e5e3c30cf38c021e89b9413b2caee128d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Tue, 10 Aug 2021 14:33:48 +0200 Subject: [PATCH] Add a --and-confirmed parameter to the accounts:clear-unconfirmed command Update the documentation Bump the package number --- flexiapi/README.md | 2 +- .../app/Console/Commands/RemoveUnconfirmedAccounts.php | 8 ++++++-- flexisip-account-manager.spec | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/flexiapi/README.md b/flexiapi/README.md index 862e515..eaa91ba 100644 --- a/flexiapi/README.md +++ b/flexiapi/README.md @@ -139,7 +139,7 @@ This will remove the nonces stored that were not updated after `x minutes`. This request will remove the accounts that were not confirmed after `x days`. In the database an unconfirmed account is having the `activated` attribute set to `false`. - php artisan accounts:clear-unconfirmed {days} {--apply} + php artisan accounts:clear-unconfirmed {days} {--apply} {--and-confirmed} The base request will not delete the related accounts by default. You need to add `--apply` to remove them. diff --git a/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php b/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php index 2f79195..47960bd 100644 --- a/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php +++ b/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php @@ -26,7 +26,7 @@ use App\Account; class RemoveUnconfirmedAccounts extends Command { - protected $signature = 'accounts:clear-unconfirmed {days} {--apply}'; + protected $signature = 'accounts:clear-unconfirmed {days} {--apply} {--and-confirmed}'; protected $description = 'Clear unconfirmed accounts after n days'; public function __construct() @@ -36,10 +36,14 @@ class RemoveUnconfirmedAccounts extends Command public function handle() { - $accounts = Account::where('activated', false)->where('creation_time', '<', + $accounts = Account::where('creation_time', '<', Carbon::now()->subDays($this->argument('days'))->toDateTimeString() ); + if (!$this->option('and-confirmed')) { + $accounts = $accounts->where('activated', false); + } + if ($this->option('apply')) { $this->info($accounts->count() . ' accounts deleted'); $accounts->delete(); diff --git a/flexisip-account-manager.spec b/flexisip-account-manager.spec index f1da2cb..1828494 100644 --- a/flexisip-account-manager.spec +++ b/flexisip-account-manager.spec @@ -8,7 +8,7 @@ #%define _datadir %{_datarootdir} #%define _docdir %{_datadir}/doc -%define build_number 95 +%define build_number 96 %define var_dir /var/opt/belledonne-communications %define opt_dir /opt/belledonne-communications/share/flexisip-account-manager