Initial Ladill Hosting app with Gitea deploy pipeline.
Deploy Ladill Hosting / deploy (push) Failing after 17s
Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Mailbox;
|
||||
use App\Services\Mail\MailServerProvisioner;
|
||||
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;
|
||||
|
||||
class ProvisionMailboxJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
public int $backoff = 60;
|
||||
|
||||
public function __construct(
|
||||
public int $mailboxId,
|
||||
public ?string $encryptedPassword = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(MailServerProvisioner $provisioner): void
|
||||
{
|
||||
$mailbox = Mailbox::query()
|
||||
->with(['domain', 'emailDomain'])
|
||||
->find($this->mailboxId);
|
||||
|
||||
if (! $mailbox || (string) $mailbox->status === 'deleting') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $provisioner->isConfigured()) {
|
||||
Log::info('ProvisionMailboxJob: Skipped — mail server DB not configured', [
|
||||
'mailbox_id' => $mailbox->id,
|
||||
]);
|
||||
$mailbox->update(['status' => 'active']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$password = $this->encryptedPassword !== null
|
||||
? decrypt($this->encryptedPassword)
|
||||
: null;
|
||||
|
||||
try {
|
||||
if ($mailbox->email_domain_id !== null) {
|
||||
$provisioner->provisionStandaloneMailbox($mailbox, $password);
|
||||
} else {
|
||||
$provisioner->provisionMailbox($mailbox, $password);
|
||||
}
|
||||
|
||||
$mailbox->update(['status' => 'active']);
|
||||
} catch (\Throwable $exception) {
|
||||
$mailbox->update(['status' => 'failed']);
|
||||
Log::error('ProvisionMailboxJob: Failed', [
|
||||
'mailbox_id' => $mailbox->id,
|
||||
'address' => $mailbox->address,
|
||||
'error' => $exception->getMessage(),
|
||||
]);
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user