refactor(previews): move preview domain generation logic to ApplicationPreview model for better encapsulation and consistency across webhook handlers

This commit is contained in:
Andras Bacsai
2025-07-14 19:12:57 +02:00
parent 8a107b3c4b
commit 5bdf2e8481
8 changed files with 42 additions and 36 deletions

View File

@@ -236,8 +236,11 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
$this->preview->generate_preview_fqdn_compose();
}
} else {
// For non-Docker Compose apps, use the application model's method
$this->preview = $this->application->generate_preview_fqdn($this->pull_request_id);
// For non-Docker Compose apps, use the preview model's method
$this->preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id);
if ($this->preview) {
$this->preview->generate_preview_fqdn();
}
}
if ($this->application->is_github_based()) {
ApplicationPullRequestUpdateJob::dispatch(application: $this->application, preview: $this->preview, deployment_uuid: $this->deployment_uuid, status: ProcessStatus::IN_PROGRESS);