feat(integration): add requires_tenant_configuration field and update related logic and tests
This commit is contained in:
@@ -94,7 +94,7 @@ abstract class BaseIntegrationService
|
||||
->where('integration_code', $this->integrationCode)
|
||||
->first();
|
||||
|
||||
if (!$this->tenantIntegration) {
|
||||
if (!$this->tenantIntegration && $this->integration->requires_tenant_configuration) {
|
||||
throw new Exception("Tenant '{$this->tenantCode}' does not have integration '{$this->integrationCode}' configured.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ class MailService extends BaseIntegrationService
|
||||
|
||||
private ?Tenant $tenant = null;
|
||||
|
||||
private bool $usesTenantMailer = false;
|
||||
|
||||
public function __construct(?MailFactory $mailFactory = null)
|
||||
{
|
||||
$this->mailFactory = $mailFactory ?? app(MailFactory::class);
|
||||
@@ -41,7 +43,14 @@ class MailService extends BaseIntegrationService
|
||||
$this->tenant = Tenant::query()
|
||||
->where('codigo', $tenantCode)
|
||||
->firstOrFail();
|
||||
$this->mailer = $this->resolveMailer();
|
||||
|
||||
if ($this->tenantIntegration) {
|
||||
$this->mailer = $this->resolveMailer();
|
||||
$this->usesTenantMailer = true;
|
||||
} else {
|
||||
$this->mailer = $this->mailFactory->mailer();
|
||||
$this->usesTenantMailer = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -82,7 +91,9 @@ class MailService extends BaseIntegrationService
|
||||
|
||||
public function mailerName(): string
|
||||
{
|
||||
return 'tenant-smtp';
|
||||
return $this->usesTenantMailer
|
||||
? 'tenant-smtp'
|
||||
: (string) config('mail.default');
|
||||
}
|
||||
|
||||
public function onSetup(): void
|
||||
|
||||
Reference in New Issue
Block a user