feat: translation codes
This commit is contained in:
@@ -43,7 +43,7 @@ class ContentModerationService
|
||||
$apiKey = trim((string) config('moderation.content.openai_key'));
|
||||
|
||||
if ($apiKey === '') {
|
||||
throw new HttpException(503, __('api.moderation.unavailable'));
|
||||
throw new HttpException(503, 'CONTENT_MODERATION_UNAVAILABLE');
|
||||
}
|
||||
|
||||
$input = [];
|
||||
@@ -80,7 +80,7 @@ class ContentModerationService
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
throw new HttpException(503, __('api.moderation.unavailable'), $exception);
|
||||
throw new HttpException(503, 'CONTENT_MODERATION_UNAVAILABLE', $exception);
|
||||
}
|
||||
|
||||
if (collect($response->json('results', []))->contains(
|
||||
@@ -107,7 +107,7 @@ class ContentModerationService
|
||||
$contents = file_get_contents($image->getRealPath());
|
||||
|
||||
if ($contents === false) {
|
||||
throw new HttpException(503, __('api.moderation.unavailable'));
|
||||
throw new HttpException(503, 'CONTENT_MODERATION_UNAVAILABLE');
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
@@ -126,7 +126,7 @@ class ContentModerationService
|
||||
private function rejectContent(): never
|
||||
{
|
||||
throw ValidationException::withMessages([
|
||||
'content' => [__('api.moderation.rejected')],
|
||||
'content' => ['CONTENT_MODERATION_REJECTED'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class ModerationReportService
|
||||
->where('reportable_id', $reportable->getKey())
|
||||
->exists(),
|
||||
409,
|
||||
__('api.reports.already_exists'),
|
||||
'REPORT_ALREADY_EXISTS',
|
||||
);
|
||||
|
||||
$report = Report::create([
|
||||
@@ -62,7 +62,7 @@ class ModerationReportService
|
||||
});
|
||||
} catch (QueryException $exception) {
|
||||
if ($this->isDuplicateReportException($exception)) {
|
||||
abort(409, __('api.reports.already_exists'));
|
||||
abort(409, 'REPORT_ALREADY_EXISTS');
|
||||
}
|
||||
|
||||
throw $exception;
|
||||
@@ -128,19 +128,19 @@ class ModerationReportService
|
||||
abort_if(
|
||||
$reportable instanceof User && $reportable->is($reporter),
|
||||
422,
|
||||
__('api.reports.cannot_report_self'),
|
||||
'CANNOT_REPORT_SELF',
|
||||
);
|
||||
|
||||
abort_if(
|
||||
$reportable instanceof MealPosts && $reportable->user_id === $reporter->getKey(),
|
||||
422,
|
||||
__('api.reports.cannot_report_own_meal'),
|
||||
'CANNOT_REPORT_OWN_MEAL',
|
||||
);
|
||||
|
||||
abort_if(
|
||||
$reportable instanceof PostReviews && $reportable->user_id === $reporter->getKey(),
|
||||
422,
|
||||
__('api.reports.cannot_report_own_review'),
|
||||
'CANNOT_REPORT_OWN_REVIEW',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user