Trigger twofaccounts withdrawal after group deletion, not during

This commit is contained in:
Bubka 2025-02-19 11:23:42 +01:00
parent ceb9d69478
commit b82a7eb604
4 changed files with 6 additions and 9 deletions

View File

@ -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));
}
}

View File

@ -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(

View File

@ -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));
});
}
/**

View File

@ -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 => [