mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-24 23:17:23 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user