2023-08-15 12:11:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Models\InstanceSettings;
|
|
|
|
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\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Mail\Message;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
|
2023-09-14 08:12:44 +00:00
|
|
|
class SendConfirmationForWaitlistJob implements ShouldQueue, ShouldBeEncrypted
|
2023-08-15 12:11:38 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
public function __construct(public string $email, public string $uuid)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$mail = new MailMessage();
|
|
|
|
$confirmation_url = base_url() . '/webhooks/waitlist/confirm?email=' . $this->email . '&confirmation_code=' . $this->uuid;
|
|
|
|
$cancel_url = base_url() . '/webhooks/waitlist/cancel?email=' . $this->email . '&confirmation_code=' . $this->uuid;
|
|
|
|
$mail->view('emails.waitlist-confirmation',
|
|
|
|
[
|
|
|
|
'confirmation_url' => $confirmation_url,
|
|
|
|
'cancel_url' => $cancel_url,
|
|
|
|
]);
|
|
|
|
$mail->subject('You are on the waitlist!');
|
2023-08-17 13:19:37 +00:00
|
|
|
send_user_an_email($mail, $this->email);
|
2023-09-11 15:36:30 +00:00
|
|
|
} catch (\Throwable $e) {
|
|
|
|
send_internal_notification("SendConfirmationForWaitlistJob failed for {$this->email} with error: " . $e->getMessage());
|
|
|
|
ray($e->getMessage());
|
|
|
|
throw $e;
|
2023-08-15 12:11:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|