From b82a7eb604ddfe994fadce7db3a9e4a201c54a83 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Wed, 19 Feb 2025 11:23:42 +0100 Subject: [PATCH] Trigger twofaccounts withdrawal after group deletion, not during --- app/Events/GroupDeleted.php | 3 +++ app/Listeners/DissociateTwofaccountFromGroup.php | 4 ++-- app/Models/Group.php | 3 --- app/Providers/EventServiceProvider.php | 5 +---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/Events/GroupDeleted.php b/app/Events/GroupDeleted.php index 6f5acc13..d7b50c58 100644 --- a/app/Events/GroupDeleted.php +++ b/app/Events/GroupDeleted.php @@ -6,6 +6,7 @@ use App\Models\Group; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\Log; class GroupDeleted { @@ -24,5 +25,7 @@ class GroupDeleted public function __construct(Group $group) { $this->group = $group; + + Log::info(sprintf('Group %s (id #%d) deleted ', var_export($group->name, true), $group->id)); } } diff --git a/app/Listeners/DissociateTwofaccountFromGroup.php b/app/Listeners/DissociateTwofaccountFromGroup.php index d3c9dd74..9fe461c7 100644 --- a/app/Listeners/DissociateTwofaccountFromGroup.php +++ b/app/Listeners/DissociateTwofaccountFromGroup.php @@ -2,7 +2,7 @@ namespace App\Listeners; -use App\Events\GroupDeleting; +use App\Events\GroupDeleted; use App\Models\TwoFAccount; use Illuminate\Support\Facades\Log; @@ -23,7 +23,7 @@ class DissociateTwofaccountFromGroup * * @return void */ - public function handle(GroupDeleting $event) + public function handle(GroupDeleted $event) { TwoFAccount::where('group_id', $event->group->id) ->update( diff --git a/app/Models/Group.php b/app/Models/Group.php index 3b997b3c..1dc0a212 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -98,9 +98,6 @@ class Group extends Model static::updated(function (object $model) { Log::info(sprintf('Group %s (id #%d) updated by user ID #%s', var_export($model->name, true), $model->id, $model->user_id)); }); - static::deleted(function (object $model) { - Log::info(sprintf('Group %s (id #%d) deleted ', var_export($model->name, true), $model->id)); - }); } /** diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index c198d743..5f5114e3 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -3,7 +3,6 @@ namespace App\Providers; use App\Events\GroupDeleted; -use App\Events\GroupDeleting; use App\Events\ScanForNewReleaseCalled; use App\Events\StoreIconsInDatabaseSettingChanged; use App\Events\TwoFAccountDeleted; @@ -44,10 +43,8 @@ class EventServiceProvider extends ServiceProvider TwoFAccountDeleted::class => [ CleanIconStorage::class, ], - GroupDeleting::class => [ - DissociateTwofaccountFromGroup::class, - ], GroupDeleted::class => [ + DissociateTwofaccountFromGroup::class, ResetUsersPreference::class, ], ScanForNewReleaseCalled::class => [