From 90cffbfcdefb5c9a0129356d138d919246204253 Mon Sep 17 00:00:00 2001 From: jelveh Date: Tue, 11 Aug 2026 22:11:24 -0700 Subject: [PATCH] refactor: prep the feedback cap error once instead of via a factory Both throw sites are in one call and only one can ever run, so a plain const reads the same and drops a function that existed only to defer a constructor. --- .../services/feedback/AppFeedbackService.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/backend/services/feedback/AppFeedbackService.ts b/src/backend/services/feedback/AppFeedbackService.ts index df3249c69..72aa3dd0f 100644 --- a/src/backend/services/feedback/AppFeedbackService.ts +++ b/src/backend/services/feedback/AppFeedbackService.ts @@ -219,14 +219,13 @@ export class AppFeedbackService extends PuterService { userCount >= AppFeedbackService.PER_USER_DAILY_LIMIT + slack ); }; - const tooManyError = () => - new HttpError( - 429, - 'You have sent a lot of feedback recently — please try again later', - { legacyCode: 'too_many_requests' }, - ); + const tooManyError = new HttpError( + 429, + 'You have sent a lot of feedback recently — please try again later', + { legacyCode: 'too_many_requests' }, + ); if (await capsBreached(false)) { - throw tooManyError(); + throw tooManyError; } const row = await this.stores.appFeedback.create({ @@ -245,7 +244,7 @@ export class AppFeedbackService extends PuterService { // hold. if (await capsBreached(true)) { await this.stores.appFeedback.deleteById(row.id); - throw tooManyError(); + throw tooManyError; } // Email delivery is best-effort: any failure past this point must