mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\ContactPipeline;
|
|
|
|
use App\Mail\ContactAdmin;
|
|
use App\Models\Contact;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class ContactPipeline implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $contact;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(Contact $contact)
|
|
{
|
|
$this->contact = $contact;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
$contact = $this->contact;
|
|
|
|
// Verify contact exists
|
|
if (! $contact) {
|
|
Log::info('ContactPipeline: Contact no longer exists, skipping job');
|
|
|
|
return;
|
|
}
|
|
|
|
$email = config('instance.email');
|
|
if (config('instance.contact.enabled') == false || $contact->read_at !== null || filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
Mail::to($email)->send(new ContactAdmin($contact));
|
|
} catch (\Exception $e) {
|
|
Log::warning("ContactPipeline: Failed to send contact email for contact {$contact->id}: ".$e->getMessage());
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|