From f96bb62351cb90216c5fae921127087cc75b88f0 Mon Sep 17 00:00:00 2001 From: Artem Otliaguzov Date: Mon, 26 Aug 2024 11:14:39 +0200 Subject: [PATCH] fix reject entity --- app/Http/Controllers/MembershipController.php | 10 ---------- app/Jobs/FolderDeleteMembership.php | 4 +--- app/Observers/MembershipObserver.php | 11 ++++++++--- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/MembershipController.php b/app/Http/Controllers/MembershipController.php index ad27db5..620b536 100644 --- a/app/Http/Controllers/MembershipController.php +++ b/app/Http/Controllers/MembershipController.php @@ -45,18 +45,8 @@ public function update(Membership $membership) public function destroy(Membership $membership) { $this->authorize('delete', $membership); - - $entity = $membership->entity->entityid; - $locale = app()->getLocale(); - - $federation = $membership->federation->name; $entity = $membership->entity->{"name_$locale"} ?? $membership->entity->entityid; - $operators = $membership->entity->operators; - - if (! $membership->entity->approved) { - $membership->entity->forceDelete(); - } $membership->delete(); diff --git a/app/Jobs/FolderDeleteMembership.php b/app/Jobs/FolderDeleteMembership.php index 829af28..2cb2082 100644 --- a/app/Jobs/FolderDeleteMembership.php +++ b/app/Jobs/FolderDeleteMembership.php @@ -15,7 +15,6 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; use Mockery\Exception; @@ -42,7 +41,6 @@ public function __construct(Entity $entity, Federation $federation) */ public function handle(): void { - Log::info('MEMBERSHIP DELETE START'); $federation = $this->federation; $entity = $this->entity; $diskName = config('storageCfg.name'); @@ -56,7 +54,7 @@ public function handle(): void return; } $pathToFile = $federation->xml_id.'/'.$entity->file; - Log::info($pathToFile); + if (! Storage::disk($diskName)->exists($pathToFile)) { NotificationService::sendModelNotification($entity, new MembershipRejected($entity->entityid, $federation->name)); diff --git a/app/Observers/MembershipObserver.php b/app/Observers/MembershipObserver.php index ec20ce2..5c043dc 100644 --- a/app/Observers/MembershipObserver.php +++ b/app/Observers/MembershipObserver.php @@ -33,9 +33,14 @@ public function updated(Membership $membership): void */ public function deleted(Membership $membership): void { - $entity = $membership->entity; - $federation = $membership->federation; - FolderDeleteMembership::dispatch($entity, $federation); + if (! $membership->entity->approved) { + $membership->entity->forceDelete(); + } else { + $entity = $membership->entity; + $federation = $membership->federation; + FolderDeleteMembership::dispatch($entity, $federation); + } + } /**