diff --git a/app/Events/DeleteEntity.php b/app/Events/DeleteEntity.php index f24fd20..f296424 100644 --- a/app/Events/DeleteEntity.php +++ b/app/Events/DeleteEntity.php @@ -3,25 +3,21 @@ namespace App\Events; use App\Models\Entity; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; -use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; class DeleteEntity { use Dispatchable, InteractsWithSockets, SerializesModels; + public Entity $entity; /** * Create a new event instance. */ - public function __construct(Entity $entity ) + public function __construct(Entity $entity) { $this->entity = $entity; } - } diff --git a/app/Http/Controllers/EntityController.php b/app/Http/Controllers/EntityController.php index 42589f8..657f293 100644 --- a/app/Http/Controllers/EntityController.php +++ b/app/Http/Controllers/EntityController.php @@ -3,20 +3,16 @@ namespace App\Http\Controllers; use App\Http\Requests\StoreEntity; -use App\Jobs\GitAddEntity; -use App\Jobs\GitAddMember; use App\Jobs\GitAddToCategory; use App\Jobs\GitAddToEdugain; use App\Jobs\GitAddToHfd; use App\Jobs\GitAddToRs; -use App\Jobs\GitDeleteEntity; use App\Jobs\GitDeleteFromCategory; use App\Jobs\GitDeleteFromEdugain; use App\Jobs\GitDeleteFromHfd; use App\Jobs\GitDeleteFromRs; use App\Jobs\GitRestoreToCategory; use App\Jobs\GitRestoreToEdugain; -use App\Jobs\GitUpdateEntity; use App\Ldap\CesnetOrganization; use App\Ldap\EduidczOrganization; use App\Mail\NewIdentityProvider; diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index 67aa975..870eb51 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -4,7 +4,6 @@ use App\Http\Requests\StoreFederation; use App\Http\Requests\UpdateFederation; -use App\Jobs\GitAddMembers; use App\Jobs\GitDeleteMembers; use App\Models\Entity; use App\Models\Federation; @@ -284,7 +283,9 @@ public function update(UpdateFederation $request, Federation $federation) ]); $new_entities = Entity::whereIn('id', request('entities'))->get(); - GitAddMembers::dispatch($federation, $new_entities, Auth::user()); + + //TODO add members to federation + // GitAddMembers::dispatch($federation, $new_entities, Auth::user()); Notification::send($federation->operators, new FederationMembersChanged($federation, $new_entities, 'added')); Notification::send(User::activeAdmins()->select('id', 'emails')->get(), new FederationMembersChanged($federation, $new_entities, 'added')); diff --git a/app/Http/Controllers/MembershipController.php b/app/Http/Controllers/MembershipController.php index 5a9ad23..17e64cd 100644 --- a/app/Http/Controllers/MembershipController.php +++ b/app/Http/Controllers/MembershipController.php @@ -2,8 +2,6 @@ namespace App\Http\Controllers; -use App\Jobs\GitAddEntity; -use App\Jobs\GitAddMembership; use App\Jobs\GitAddToHfd; use App\Models\Membership; use App\Models\User; @@ -41,20 +39,21 @@ public function update(Membership $membership) $membership->update(); }); - Bus::chain([ - new GitAddEntity($membership->entity, Auth::user()), - new GitAddToHfd($membership->entity, Auth::user()), - new GitAddMembership($membership, Auth::user()), - function () use ($membership) { - $admins = User::activeAdmins()->select('id', 'email')->get(); - Notification::send($membership->entity->operators, new MembershipAccepted($membership)); - Notification::send($admins, new MembershipAccepted($membership)); - if ($membership->entity->hfd) { - Notification::send($membership->entity->operators, new EntityAddedToHfd($membership->entity)); - Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityAddedToHfd($membership->entity)); - } - }, - ])->dispatch(); + // TODO chain of update membership chain + /* Bus::chain([ + new Old_GitAddEntity($membership->entity, Auth::user()), + new GitAddToHfd($membership->entity, Auth::user()), + new GitAddMembership($membership, Auth::user()), + function () use ($membership) { + $admins = User::activeAdmins()->select('id', 'email')->get(); + Notification::send($membership->entity->operators, new MembershipAccepted($membership)); + Notification::send($admins, new MembershipAccepted($membership)); + if ($membership->entity->hfd) { + Notification::send($membership->entity->operators, new EntityAddedToHfd($membership->entity)); + Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityAddedToHfd($membership->entity)); + } + }, + ])->dispatch();*/ return redirect() ->back() diff --git a/app/Jobs/FolderAddEntity.php b/app/Jobs/FolderAddEntity.php index 0cfad1c..b9c4c35 100644 --- a/app/Jobs/FolderAddEntity.php +++ b/app/Jobs/FolderAddEntity.php @@ -31,7 +31,6 @@ public function __construct(Entity $entity) $this->entity = $entity; } - /** * Execute the job. */ diff --git a/app/Jobs/FolderDeleteEntity.php b/app/Jobs/FolderDeleteEntity.php index defdaf5..058de5c 100644 --- a/app/Jobs/FolderDeleteEntity.php +++ b/app/Jobs/FolderDeleteEntity.php @@ -4,7 +4,6 @@ use App\Facades\EntityFacade; use App\Models\Entity; -use App\Models\Federation; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -56,11 +55,7 @@ public function handle(): void } } - - - } - } } diff --git a/app/Jobs/GitAddEntity.php b/app/Jobs/Old_GitAddEntity.php similarity index 97% rename from app/Jobs/GitAddEntity.php rename to app/Jobs/Old_GitAddEntity.php index d8f6aab..2925379 100644 --- a/app/Jobs/GitAddEntity.php +++ b/app/Jobs/Old_GitAddEntity.php @@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Storage; use Throwable; -class GitAddEntity implements ShouldQueue +class Old_GitAddEntity implements ShouldQueue { use Dispatchable, GitTrait, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Jobs/GitAddMember.php b/app/Jobs/Old_GitAddMember.php similarity index 97% rename from app/Jobs/GitAddMember.php rename to app/Jobs/Old_GitAddMember.php index 9809447..8535026 100644 --- a/app/Jobs/GitAddMember.php +++ b/app/Jobs/Old_GitAddMember.php @@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Storage; use Throwable; -class GitAddMember implements ShouldQueue +class Old_GitAddMember implements ShouldQueue { use Dispatchable, GitTrait, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Jobs/GitAddMembers.php b/app/Jobs/Old_GitAddMembers.php similarity index 97% rename from app/Jobs/GitAddMembers.php rename to app/Jobs/Old_GitAddMembers.php index 7fcd22b..c2dcd9e 100644 --- a/app/Jobs/GitAddMembers.php +++ b/app/Jobs/Old_GitAddMembers.php @@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Storage; use Throwable; -class GitAddMembers implements ShouldQueue +class Old_GitAddMembers implements ShouldQueue { use Dispatchable, GitTrait, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Jobs/GitAddMembership.php b/app/Jobs/Old_GitAddMembership.php similarity index 97% rename from app/Jobs/GitAddMembership.php rename to app/Jobs/Old_GitAddMembership.php index 20de888..60dfe1c 100644 --- a/app/Jobs/GitAddMembership.php +++ b/app/Jobs/Old_GitAddMembership.php @@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Storage; use Throwable; -class GitAddMembership implements ShouldQueue +class Old_GitAddMembership implements ShouldQueue { use Dispatchable, GitTrait, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Jobs/GitDeleteEntity.php b/app/Jobs/Old_GitDeleteEntity.php similarity index 97% rename from app/Jobs/GitDeleteEntity.php rename to app/Jobs/Old_GitDeleteEntity.php index f136fdb..894af03 100644 --- a/app/Jobs/GitDeleteEntity.php +++ b/app/Jobs/Old_GitDeleteEntity.php @@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Storage; use Throwable; -class GitDeleteEntity implements ShouldQueue +class Old_GitDeleteEntity implements ShouldQueue { use Dispatchable, GitTrait, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Jobs/GitUpdateEntity.php b/app/Jobs/Old_GitUpdateEntity.php similarity index 97% rename from app/Jobs/GitUpdateEntity.php rename to app/Jobs/Old_GitUpdateEntity.php index 92d8754..8e34422 100644 --- a/app/Jobs/GitUpdateEntity.php +++ b/app/Jobs/Old_GitUpdateEntity.php @@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Storage; use Throwable; -class GitUpdateEntity implements ShouldQueue +class Old_GitUpdateEntity implements ShouldQueue { use Dispatchable, GitTrait, InteractsWithQueue, Queueable, SerializesModels; diff --git a/app/Listeners/SendDeletedEntityToDeleteJob.php b/app/Listeners/SendDeletedEntityToDeleteJob.php index 8733e55..cebd908 100644 --- a/app/Listeners/SendDeletedEntityToDeleteJob.php +++ b/app/Listeners/SendDeletedEntityToDeleteJob.php @@ -5,8 +5,6 @@ use App\Events\DeleteEntity; use App\Facades\EntityFacade; use App\Jobs\FolderDeleteEntity; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Log; class SendDeletedEntityToDeleteJob @@ -33,9 +31,6 @@ public function handle(DeleteEntity $event): void EntityFacade::deleteEntityMetadataFromFolder($entity->file, $federation->xml_id); } - - - - // FolderDeleteEntity::dispatch($event->entity); + // FolderDeleteEntity::dispatch($event->entity); } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 7a91ba2..b07c157 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -37,7 +37,7 @@ class EventServiceProvider extends ServiceProvider ], DeleteEntity::class => [ SendDeletedEntityToDeleteJob::class, - ] + ], ]; diff --git a/app/Services/EntityService.php b/app/Services/EntityService.php index 5c55a5f..f07263e 100644 --- a/app/Services/EntityService.php +++ b/app/Services/EntityService.php @@ -51,21 +51,17 @@ public function saveEntityMetadataToFolder($entity_id, $folderName): void public function deleteEntityMetadataFromFolder($fileName, $folderName): void { $diskName = config('storageCfg.name'); - $pathToFile = $folderName . '/' . $fileName; + $pathToFile = $folderName.'/'.$fileName; if (Storage::disk($diskName)->exists($pathToFile)) { try { Storage::disk($diskName)->delete($pathToFile); } catch (Exception $e) { - Log::error("Failed to delete file: {$pathToFile}. Error: " . $e->getMessage()); + Log::error("Failed to delete file: {$pathToFile}. Error: ".$e->getMessage()); } } else { Log::warning("File does not exist: {$pathToFile}"); } - - } - - } diff --git a/tests/Feature/Http/Controllers/EntityControllerTest.php b/tests/Feature/Http/Controllers/EntityControllerTest.php index eb675c3..facd132 100644 --- a/tests/Feature/Http/Controllers/EntityControllerTest.php +++ b/tests/Feature/Http/Controllers/EntityControllerTest.php @@ -2,9 +2,6 @@ namespace Tests\Feature\Http\Controllers; -use App\Jobs\GitAddEntity; -use App\Jobs\GitDeleteEntity; -use App\Jobs\GitUpdateEntity; use App\Models\Entity; use App\Models\Federation; use App\Models\Membership; diff --git a/tests/Feature/Http/Controllers/FederationControllerTest.php b/tests/Feature/Http/Controllers/FederationControllerTest.php index 168eabd..4865cca 100644 --- a/tests/Feature/Http/Controllers/FederationControllerTest.php +++ b/tests/Feature/Http/Controllers/FederationControllerTest.php @@ -2,7 +2,6 @@ namespace Tests\Feature\Http\Controllers; -use App\Jobs\GitAddMembers; use App\Jobs\GitDeleteMembers; use App\Jobs\GitUpdateFederation; use App\Jobs\Old_GitAddFederation; @@ -514,10 +513,10 @@ public function a_user_with_operator_permission_can_change_an_existing_federatio $this->assertEquals(2, $federation->entities()->count()); $this->assertEquals(route('federations.entities', $federation), url()->current()); - Bus::assertDispatched(GitAddMembers::class, function ($job) use ($federation, $new_entity) { - return $job->federation->is($federation) && - $job->entities->contains($new_entity); - }); + /* Bus::assertDispatched(GitAddMembers::class, function ($job) use ($federation, $new_entity) { + return $job->federation->is($federation) && + $job->entities->contains($new_entity); + });*/ $this ->followingRedirects() @@ -1086,10 +1085,10 @@ public function an_admin_can_change_an_existing_federations_entities() $this->assertEquals(2, $federation->entities()->count()); $this->assertEquals(route('federations.entities', $federation), url()->current()); - Bus::assertDispatched(GitAddMembers::class, function ($job) use ($federation, $new_entity) { - return $job->federation->is($federation) && - $job->entities->contains($new_entity); - }); + /* Bus::assertDispatched(GitAddMembers::class, function ($job) use ($federation, $new_entity) { + return $job->federation->is($federation) && + $job->entities->contains($new_entity); + });*/ $this ->followingRedirects()