1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 08:14:10 +00:00

Update ApiV1Controller, add validation messages to update_credentials endpoint

This commit is contained in:
Daniel Supernault 2022-02-05 18:39:17 -07:00
parent 74905ba1d0
commit cd78560184
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -74,6 +74,7 @@ use App\Services\{
UserFilterService
};
use App\Util\Lexer\Autolink;
use App\Util\Lexer\PrettyNumber;
use App\Util\Localization\Localization;
use App\Util\Media\License;
use App\Jobs\MediaPipeline\MediaSyncLicensePipeline;
@ -182,13 +183,17 @@ class ApiV1Controller extends Controller
abort_if(!$request->user(), 403);
$this->validate($request, [
'avatar' => 'sometimes|mimetypes:image/jpeg,image/png',
'avatar' => 'sometimes|mimetypes:image/jpeg,image/png|min:10|max:' . config('pixelfed.max_avatar_size'),
'display_name' => 'nullable|string',
'note' => 'nullable|string',
'locked' => 'nullable',
'website' => 'nullable',
// 'source.privacy' => 'nullable|in:unlisted,public,private',
// 'source.sensitive' => 'nullable|boolean'
], [
'required' => 'The :attribute field is required.',
'avatar.mimetypes' => 'The file must be in jpeg or png format',
'avatar.max' => 'The :attribute exceeds the file size limit of ' . PrettyNumber::size(config('pixelfed.max_avatar_size'), true, false),
]);
$user = $request->user();
@ -201,8 +206,6 @@ class ApiV1Controller extends Controller
$licenseChanged = false;
$composeSettings = array_merge(AccountService::defaultSettings()['compose_settings'], $settings->compose_settings ?? []);
// return $request->input('locked');
if($request->has('avatar')) {
$av = Avatar::whereProfileId($profile->id)->first();
if($av) {