Skip to content

Commit

Permalink
rin pint
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Jul 23, 2024
1 parent 42f5791 commit a002d72
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 29 deletions.
3 changes: 1 addition & 2 deletions app/Http/Controllers/EntityFederationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Http\Requests\JoinFederation;
use App\Jobs\FolderDeleteMembership;
use App\Jobs\Old_GitDeleteFromFederation;
use App\Models\Entity;
use App\Models\Federation;
use App\Models\User;
Expand Down Expand Up @@ -82,7 +81,7 @@ public function destroy(Request $request, Entity $entity)
foreach (request('federations') as $f) {
$federation = Federation::find($f);

FolderDeleteMembership::dispatch($entity,$federation);
FolderDeleteMembership::dispatch($entity, $federation);
//GitDeleteFromFederation::dispatch($entity, $federation, Auth::user());
Notification::send($entity->operators, new EntityDeletedFromFederation($entity, $federation));
Notification::send(User::activeAdmins()->select('id', 'email')->get(), new EntityDeletedFromFederation($entity, $federation));
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/MembershipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public function destroy(Membership $membership)

$membership->delete();

/* $admins = User::activeAdmins()->select('id', 'email')->get();
Notification::send($operators, new MembershipRejected($entity, $federation));
Notification::send($admins, new MembershipRejected($entity, $federation));*/
/* $admins = User::activeAdmins()->select('id', 'email')->get();
Notification::send($operators, new MembershipRejected($entity, $federation));
Notification::send($admins, new MembershipRejected($entity, $federation));*/

return redirect()
->back()
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/EduGainRunMdaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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 Down
8 changes: 3 additions & 5 deletions app/Jobs/FolderAddMembership.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use App\Models\Federation;
use App\Models\Membership;
use App\Notifications\EntityAddedToHfd;
use App\Notifications\EntityStateChanged;
use App\Notifications\MembershipAccepted;
use App\Services\NotificationService;
use App\Traits\HandlesJobsFailuresTrait;
Expand Down Expand Up @@ -58,10 +57,9 @@ public function handle(): void

NotificationService::sendEntityNotification($entity, new MembershipAccepted($this->membership));

/* if($this->membership->entity->hfd) {
NotificationService::sendEntityNotification($entity, new EntityAddedToHfd($this->membership->entity));
}*/

/* if($this->membership->entity->hfd) {
NotificationService::sendEntityNotification($entity, new EntityAddedToHfd($this->membership->entity));
}*/

RunMdaScript::dispatch($federation, $lock->owner());
} catch (Exception $e) {
Expand Down
4 changes: 1 addition & 3 deletions app/Jobs/FolderDeleteEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Facades\EntityFacade;
use App\Models\Entity;
use App\Notifications\EntityDeletedFromHfd;
use App\Notifications\EntityStateChanged;
use App\Services\NotificationService;
use App\Traits\HandlesJobsFailuresTrait;
Expand All @@ -14,7 +13,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 Down Expand Up @@ -65,7 +63,7 @@ public function handle(): void

RunMdaScript::dispatch($federation, $lock->owner());
} catch (Exception $e) {
$this->fail($e);
$this->fail($e);
} finally {
if ($lock->isOwnedByCurrentProcess()) {
$lock->release();
Expand Down
10 changes: 3 additions & 7 deletions app/Jobs/FolderDeleteMembership.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use App\Facades\EntityFacade;
use App\Models\Entity;
use App\Models\Federation;
use App\Models\Membership;
use App\Notifications\EntityDeletedFromHfd;
use App\Notifications\EntityStateChanged;
use App\Notifications\MembershipRejected;
use App\Services\NotificationService;
use App\Traits\HandlesJobsFailuresTrait;
Expand All @@ -26,9 +23,9 @@ class FolderDeleteMembership implements ShouldQueue
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use HandlesJobsFailuresTrait;

public Federation $federation;
public Entity $entity;
public Federation $federation;

public Entity $entity;

/**
* Create a new job instance.
Expand Down Expand Up @@ -59,8 +56,7 @@ public function handle(): void
$lock->block(61);
EntityFacade::deleteEntityMetadataFromFolder($entity->file, $federation->xml_id);


NotificationService::sendEntityNotification($entity,new MembershipRejected($entity->entityid,$federation->name));
NotificationService::sendEntityNotification($entity, new MembershipRejected($entity->entityid, $federation->name));

RunMdaScript::dispatch($federation, $lock->owner());
} catch (Exception $e) {
Expand Down
4 changes: 0 additions & 4 deletions app/Models/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
namespace App\Models;

use App\Enums\EntityType;
use App\Events\CreateEntity;
use App\Events\DeleteEntity;
use App\Events\UpdateEntity;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
Expand Down Expand Up @@ -93,5 +90,4 @@ public function scopeSearch($query, ?string $search = null)
->orWhere('description_en', 'like', "%$search%")
->orWhere('description_cs', 'like', "%$search%");
}

}
4 changes: 2 additions & 2 deletions app/Observers/EntityObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function updated(Entity $entity): void
if ($entity->wasChanged('xml_file')
) {
FolderAddEntity::dispatch($entity);
} elseif ($entity->approved == 1 && !$entity->wasChanged('approved') ){
} elseif ($entity->approved == 1 && ! $entity->wasChanged('approved')) {

if(!$entity->wasChanged('edugain') && !$entity->wasChanged('deleted_at')){
if (! $entity->wasChanged('edugain') && ! $entity->wasChanged('deleted_at')) {
NotificationService::sendUpdateNotification($entity);
}

Expand Down
3 changes: 1 addition & 2 deletions app/Services/EntityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Models\Federation;
use Exception;
use http\Exception\InvalidArgumentException;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;

class EntityService
Expand Down Expand Up @@ -58,7 +57,7 @@ public function deleteEntityMetadataFromFolder($fileName, $folderName): void
try {
Storage::disk($diskName)->delete($pathToFile);
} catch (Exception $e) {
throw new InvalidArgumentException("Unable to delete file $pathToFile");
throw new InvalidArgumentException("Unable to delete file $pathToFile");
}
} else {
throw new InvalidArgumentException("Unable to delete file $pathToFile");
Expand Down

0 comments on commit a002d72

Please sign in to comment.