Skip to content

Commit

Permalink
fix reject entity
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Aug 26, 2024
1 parent 31024e4 commit f96bb62
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
10 changes: 0 additions & 10 deletions app/Http/Controllers/MembershipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 1 addition & 3 deletions app/Jobs/FolderDeleteMembership.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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');
Expand All @@ -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));

Expand Down
11 changes: 8 additions & 3 deletions app/Observers/MembershipObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

/**
Expand Down

0 comments on commit f96bb62

Please sign in to comment.