mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-18 02:14:32 +00:00
refactor(api): validate and throttle feedback endpoint (#9653)
This commit is contained in:
5 files changed
+110
-5
No files matched your search
@@ -147,11 +147,15 @@ class OtherController extends Controller
|
||||
|
||||
public function feedback(Request $request)
|
||||
{
|
||||
$content = $request->input('content');
|
||||
$data = $request->validate([
|
||||
'content' => ['required', 'string', 'min:10', 'max:2000'],
|
||||
]);
|
||||
|
||||
$webhook_url = config('constants.webhooks.feedback_discord_webhook');
|
||||
if ($webhook_url) {
|
||||
Http::post($webhook_url, [
|
||||
'content' => $content,
|
||||
Http::timeout(5)->post($webhook_url, [
|
||||
'content' => $data['content'],
|
||||
'allowed_mentions' => ['parse' => []],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class Help extends Component
|
||||
#[Validate(['required', 'min:10', 'max:1000'])]
|
||||
public string $description;
|
||||
|
||||
#[Validate(['required', 'min:3'])]
|
||||
#[Validate(['required', 'min:3', 'max:600'])]
|
||||
public string $subject;
|
||||
|
||||
public function submit()
|
||||
|
||||
@@ -54,5 +54,9 @@ class RouteServiceProvider extends ServiceProvider
|
||||
RateLimiter::for('5', function (Request $request) {
|
||||
return Limit::perMinute(5)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
RateLimiter::for('feedback', function (Request $request) {
|
||||
return Limit::perMinute(3)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user