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,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\HostingAccount;
|
||||
use App\Models\Mailbox;
|
||||
use App\Services\Hosting\HostingMailboxService;
|
||||
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 DeactivateMailboxJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
public int $backoff = 60;
|
||||
|
||||
public function __construct(public int $mailboxId)
|
||||
{
|
||||
}
|
||||
|
||||
public function handle(MailServerProvisioner $provisioner, HostingMailboxService $hostingMailboxes): void
|
||||
{
|
||||
$mailbox = Mailbox::query()->find($this->mailboxId);
|
||||
if (! $mailbox) {
|
||||
return;
|
||||
}
|
||||
|
||||
$hostingAccountId = $mailbox->hosting_account_id;
|
||||
|
||||
try {
|
||||
if ($provisioner->isConfigured()) {
|
||||
$provisioner->deactivateMailbox($mailbox);
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$mailbox->update(['status' => 'failed']);
|
||||
Log::error('DeactivateMailboxJob: Remote deactivation failed', [
|
||||
'mailbox_id' => $mailbox->id,
|
||||
'address' => $mailbox->address,
|
||||
'error' => $exception->getMessage(),
|
||||
]);
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$mailbox->delete();
|
||||
|
||||
if ($hostingAccountId) {
|
||||
$account = HostingAccount::query()->with(['product', 'mailboxes'])->find($hostingAccountId);
|
||||
if ($account) {
|
||||
$hostingMailboxes->syncAddonInvoice($account);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user