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,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Composers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\Identity\IdentityClient;
|
||||
use App\Services\Mailbox\MailboxClient;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class MailboxLinkComposer
|
||||
{
|
||||
public function __construct(
|
||||
private IdentityClient $identity,
|
||||
private MailboxClient $mailboxes,
|
||||
) {}
|
||||
|
||||
public function compose(View $view): void
|
||||
{
|
||||
$account = ladill_account();
|
||||
$status = ['show_reminder' => false];
|
||||
$dismissed = (bool) session('mailbox_link_banner_dismissed', false);
|
||||
|
||||
if ($account?->public_id) {
|
||||
$mailboxOptions = [];
|
||||
|
||||
try {
|
||||
$mailboxOptions = $this->mailboxes->forUser((string) $account->public_id);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
|
||||
try {
|
||||
$status = $this->identity->mailboxLinkStatus((string) $account->public_id);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
$status = $this->localMailboxLinkStatus($account, $mailboxOptions);
|
||||
}
|
||||
|
||||
if (! ($status['show_reminder'] ?? false) && $this->localNeedsMailboxLink($account, $mailboxOptions, $status)) {
|
||||
$status['show_reminder'] = true;
|
||||
$status['stage'] = $status['stage'] ?? 'needs_link';
|
||||
$status['account_email'] = $status['account_email'] ?? $account->email;
|
||||
}
|
||||
}
|
||||
|
||||
$view->with('mailboxLinkReminder', [
|
||||
...$status,
|
||||
'visible' => ($status['show_reminder'] ?? false) && ! $dismissed,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @param array<int, array<string, mixed>> $mailboxOptions */
|
||||
private function localNeedsMailboxLink(User $account, array $mailboxOptions, array $status): bool
|
||||
{
|
||||
if ($status['linked_mailbox'] ?? null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$email = strtolower(trim($account->email ?? ''));
|
||||
if ($email === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($mailboxOptions as $mailbox) {
|
||||
if (strtolower((string) ($mailbox['address'] ?? '')) === $email) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return count($mailboxOptions) > 0;
|
||||
}
|
||||
|
||||
/** @param array<int, array<string, mixed>> $mailboxOptions */
|
||||
/** @return array<string, mixed> */
|
||||
private function localMailboxLinkStatus(User $account, array $mailboxOptions): array
|
||||
{
|
||||
$needsLink = $this->localNeedsMailboxLink($account, $mailboxOptions, []);
|
||||
|
||||
return [
|
||||
'show_reminder' => $needsLink,
|
||||
'stage' => count($mailboxOptions) > 0 ? 'needs_link' : 'needs_mailbox',
|
||||
'linked_mailbox' => null,
|
||||
'account_email' => $account->email,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user