lasthourcloud/app/Jobs/CleanupInstanceStuffsJob.php

61 lines
1.6 KiB
PHP
Raw Normal View History

2023-08-15 12:11:38 +00:00
<?php
namespace App\Jobs;
2023-09-15 09:19:36 +00:00
use App\Models\TeamInvitation;
2023-08-15 12:11:38 +00:00
use App\Models\Waitlist;
use Illuminate\Bus\Queueable;
2023-09-14 08:12:44 +00:00
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
2023-08-15 12:11:38 +00:00
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
2024-06-10 20:43:34 +00:00
class CleanupInstanceStuffsJob implements ShouldBeEncrypted, ShouldBeUnique, ShouldQueue
2023-08-15 12:11:38 +00:00
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct()
{
}
// public function uniqueId(): string
// {
// return $this->container_name;
// }
public function handle(): void
{
try {
// $this->cleanup_waitlist();
2023-09-11 15:36:30 +00:00
} catch (\Throwable $e) {
2024-06-10 20:43:34 +00:00
send_internal_notification('CleanupInstanceStuffsJob failed with error: '.$e->getMessage());
2023-08-15 12:11:38 +00:00
ray($e->getMessage());
2023-09-15 09:19:36 +00:00
}
try {
$this->cleanup_invitation_link();
} catch (\Throwable $e) {
2024-06-10 20:43:34 +00:00
send_internal_notification('CleanupInstanceStuffsJob failed with error: '.$e->getMessage());
2023-09-15 09:19:36 +00:00
ray($e->getMessage());
2023-08-15 12:11:38 +00:00
}
}
private function cleanup_waitlist()
{
2023-08-30 16:23:55 +00:00
$waitlist = Waitlist::whereVerified(false)->where('created_at', '<', now()->subMinutes(config('constants.waitlist.expiration')))->get();
2023-08-15 12:11:38 +00:00
foreach ($waitlist as $item) {
$item->delete();
}
}
2024-06-10 20:43:34 +00:00
2023-09-15 09:19:36 +00:00
private function cleanup_invitation_link()
{
$invitation = TeamInvitation::all();
foreach ($invitation as $item) {
$item->isValid();
}
}
2023-08-15 12:11:38 +00:00
}