mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
Without SMTP or Resend configured, the Help form posts to the Cloud feedback API but ignored the response, so it always reported success. Check the response and show an error on failure. The Cloud endpoint now returns 502 when the Discord webhook fails.
69 lines
2.2 KiB
PHP
69 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
|
|
use Illuminate\Http\Client\ConnectionException;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
|
|
class Help extends Component
|
|
{
|
|
use WithRateLimiting;
|
|
|
|
#[Validate(['required', 'min:10', 'max:1000'])]
|
|
public string $description;
|
|
|
|
#[Validate(['required', 'min:3', 'max:600'])]
|
|
public string $subject;
|
|
|
|
public function submit()
|
|
{
|
|
try {
|
|
$this->validate();
|
|
$this->rateLimit(3, 30);
|
|
|
|
$settings = instanceSettings();
|
|
$mail = new MailMessage;
|
|
$mail->view(
|
|
'emails.help',
|
|
[
|
|
'description' => $this->description,
|
|
]
|
|
);
|
|
$mail->subject("[HELP]: {$this->subject}");
|
|
$type = set_transanctional_email_settings($settings);
|
|
|
|
// Sending feedback through Cloud API
|
|
if (blank($type)) {
|
|
$url = 'https://app.coolify.io/api/feedback';
|
|
try {
|
|
$response = Http::timeout(10)->post($url, [
|
|
'content' => 'User: `'.auth()->user()?->email.'` with subject: `'.$this->subject.'` has the following problem: `'.$this->description.'`',
|
|
]);
|
|
} catch (ConnectionException) {
|
|
$response = null;
|
|
}
|
|
if (! $response?->successful()) {
|
|
$this->dispatch('error', 'Feedback could not be sent.', 'Please try again later or contact us on Discord.');
|
|
|
|
return;
|
|
}
|
|
} else {
|
|
send_user_an_email($mail, auth()->user()?->email, 'feedback@coollabs.io');
|
|
}
|
|
$this->dispatch('success', 'Feedback sent.', 'We will get in touch with you as soon as possible.');
|
|
$this->reset('description', 'subject');
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.help')->layout('layouts.app');
|
|
}
|
|
}
|