- ProvisionDnsDomainJob/SuspendDnsDomainJob: tạo domain admin lên Plesk, huỷ = suspend (is_created=3) - Khách xem zone DNS được gán ở /dich-vu/domain, quản lý bản ghi A/AAAA/CNAME/TXT/MX/SRV - send-mail hoá đơn đẩy SendInvoiceMailJob, preview + sửa nội dung, ghi mail.order_id - invoice_attachments.type (payment_proof/deployment) - CacheService xoá theo SCAN pattern, Redis không persistent mặc định - Backfill transactions.public_code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Models\Setting;
|
|
use Illuminate\Support\Facades\Context;
|
|
|
|
final class AutoEmailGate
|
|
{
|
|
public const SCENARIO_DATA_KEY = '__mail_scenario';
|
|
|
|
private const MANUAL_CONTEXT_KEY = 'mail.manual_send';
|
|
|
|
public static function markManual(): void
|
|
{
|
|
Context::addHidden(self::MANUAL_CONTEXT_KEY, true);
|
|
}
|
|
|
|
public static function blocks(?string $scenario): bool
|
|
{
|
|
if ($scenario === null || Context::hasHidden(self::MANUAL_CONTEXT_KEY)) {
|
|
return false;
|
|
}
|
|
|
|
return in_array($scenario, self::disabledScenarios(), true);
|
|
}
|
|
|
|
public static function allows(?string $scenario): bool
|
|
{
|
|
return self::mailEnabled() && !self::blocks($scenario);
|
|
}
|
|
|
|
public static function mailEnabled(): bool
|
|
{
|
|
return (bool) (self::emailSettings()['mail_enabled'] ?? true);
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function disabledScenarios(): array
|
|
{
|
|
return (array) (self::emailSettings()['auto_disabled'] ?? []);
|
|
}
|
|
|
|
private static function emailSettings(): array
|
|
{
|
|
$value = Setting::where('key', 'email_settings')->value('value');
|
|
|
|
return (array) (json_decode($value ?? '', true) ?? []);
|
|
}
|
|
}
|