mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-09-20 00:08:01 +00:00
Update config() to config_cache()
This commit is contained in:
parent
e7b33c4cc6
commit
1d54204635
4 changed files with 16 additions and 16 deletions
|
@ -960,7 +960,7 @@ class ApiV1Controller extends Controller
|
||||||
$res = [
|
$res = [
|
||||||
'approval_required' => false,
|
'approval_required' => false,
|
||||||
'contact_account' => null,
|
'contact_account' => null,
|
||||||
'description' => config('instance.description'),
|
'description' => config_cache('app.description'),
|
||||||
'email' => config('instance.email'),
|
'email' => config('instance.email'),
|
||||||
'invites_enabled' => false,
|
'invites_enabled' => false,
|
||||||
'rules' => [],
|
'rules' => [],
|
||||||
|
@ -979,7 +979,7 @@ class ApiV1Controller extends Controller
|
||||||
'urls' => [],
|
'urls' => [],
|
||||||
'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') . ')',
|
'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') . ')',
|
||||||
'environment' => [
|
'environment' => [
|
||||||
'max_photo_size' => (int) config('pixelfed.max_photo_size'),
|
'max_photo_size' => (int) config_cache('pixelfed.max_photo_size'),
|
||||||
'max_avatar_size' => (int) config('pixelfed.max_avatar_size'),
|
'max_avatar_size' => (int) config('pixelfed.max_avatar_size'),
|
||||||
'max_caption_length' => (int) config('pixelfed.max_caption_length'),
|
'max_caption_length' => (int) config('pixelfed.max_caption_length'),
|
||||||
'max_bio_length' => (int) config('pixelfed.max_bio_length'),
|
'max_bio_length' => (int) config('pixelfed.max_bio_length'),
|
||||||
|
@ -1034,7 +1034,7 @@ class ApiV1Controller extends Controller
|
||||||
return [
|
return [
|
||||||
'required',
|
'required',
|
||||||
'mimes:' . config('pixelfed.media_types'),
|
'mimes:' . config('pixelfed.media_types'),
|
||||||
'max:' . config('pixelfed.max_photo_size'),
|
'max:' . config_cache('pixelfed.max_photo_size'),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
'filter_name' => 'nullable|string|max:24',
|
'filter_name' => 'nullable|string|max:24',
|
||||||
|
|
|
@ -160,7 +160,7 @@ class DirectMessageController extends Controller
|
||||||
'messages' => []
|
'messages' => []
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} elseif(config('database.default') == 'mysql') {
|
} elseif(config('database.default') == 'mysql') {
|
||||||
if($action == 'inbox') {
|
if($action == 'inbox') {
|
||||||
$dms = DirectMessage::selectRaw('*, max(created_at) as createdAt')
|
$dms = DirectMessage::selectRaw('*, max(created_at) as createdAt')
|
||||||
|
@ -334,7 +334,7 @@ class DirectMessageController extends Controller
|
||||||
$dm->type = 'link';
|
$dm->type = 'link';
|
||||||
$dm->meta = [
|
$dm->meta = [
|
||||||
'domain' => parse_url($msg, PHP_URL_HOST),
|
'domain' => parse_url($msg, PHP_URL_HOST),
|
||||||
'local' => parse_url($msg, PHP_URL_HOST) ==
|
'local' => parse_url($msg, PHP_URL_HOST) ==
|
||||||
parse_url(config('app.url'), PHP_URL_HOST)
|
parse_url(config('app.url'), PHP_URL_HOST)
|
||||||
];
|
];
|
||||||
$dm->save();
|
$dm->save();
|
||||||
|
@ -501,7 +501,7 @@ class DirectMessageController extends Controller
|
||||||
return [
|
return [
|
||||||
'required',
|
'required',
|
||||||
'mimes:' . config('pixelfed.media_types'),
|
'mimes:' . config('pixelfed.media_types'),
|
||||||
'max:' . config('pixelfed.max_photo_size'),
|
'max:' . config_cache('pixelfed.max_photo_size'),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
'to_id' => 'required'
|
'to_id' => 'required'
|
||||||
|
@ -525,7 +525,7 @@ class DirectMessageController extends Controller
|
||||||
if(config('pixelfed.enforce_account_limit') == true) {
|
if(config('pixelfed.enforce_account_limit') == true) {
|
||||||
$size = Cache::remember($user->storageUsedKey(), now()->addDays(3), function() use($user) {
|
$size = Cache::remember($user->storageUsedKey(), now()->addDays(3), function() use($user) {
|
||||||
return Media::whereUserId($user->id)->sum('size') / 1000;
|
return Media::whereUserId($user->id)->sum('size') / 1000;
|
||||||
});
|
});
|
||||||
$limit = (int) config('pixelfed.max_account_size');
|
$limit = (int) config('pixelfed.max_account_size');
|
||||||
if ($size >= $limit) {
|
if ($size >= $limit) {
|
||||||
abort(403, 'Account size limit reached.');
|
abort(403, 'Account size limit reached.');
|
||||||
|
|
|
@ -28,7 +28,7 @@ class StoryController extends Controller
|
||||||
return [
|
return [
|
||||||
'required',
|
'required',
|
||||||
'mimes:image/jpeg,image/png,video/mp4',
|
'mimes:image/jpeg,image/png,video/mp4',
|
||||||
'max:' . config('pixelfed.max_photo_size'),
|
'max:' . config_cache('pixelfed.max_photo_size'),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -43,11 +43,11 @@ class MediaStorageService {
|
||||||
|
|
||||||
$h = $r->getHeaders();
|
$h = $r->getHeaders();
|
||||||
|
|
||||||
if (isset($h['Content-Length'], $h['Content-Type']) == false ||
|
if (isset($h['Content-Length'], $h['Content-Type']) == false ||
|
||||||
empty($h['Content-Length']) ||
|
empty($h['Content-Length']) ||
|
||||||
empty($h['Content-Type']) ||
|
empty($h['Content-Type']) ||
|
||||||
$h['Content-Length'] < 10 ||
|
$h['Content-Length'] < 10 ||
|
||||||
$h['Content-Length'] > (config('pixelfed.max_photo_size') * 1000)
|
$h['Content-Length'] > (config_cache('pixelfed.max_photo_size') * 1000)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class MediaStorageService {
|
||||||
$pt = explode('/', $media->thumbnail_path);
|
$pt = explode('/', $media->thumbnail_path);
|
||||||
$thumbname = array_pop($pt);
|
$thumbname = array_pop($pt);
|
||||||
$storagePath = implode('/', $p);
|
$storagePath = implode('/', $p);
|
||||||
|
|
||||||
$disk = Storage::disk(config('filesystems.cloud'));
|
$disk = Storage::disk(config('filesystems.cloud'));
|
||||||
$file = $disk->putFileAs($storagePath, new File($path), $name, 'public');
|
$file = $disk->putFileAs($storagePath, new File($path), $name, 'public');
|
||||||
$url = $disk->url($file);
|
$url = $disk->url($file);
|
||||||
|
@ -102,11 +102,11 @@ class MediaStorageService {
|
||||||
}
|
}
|
||||||
|
|
||||||
$head = $this->head($media->remote_url);
|
$head = $this->head($media->remote_url);
|
||||||
|
|
||||||
if(!$head) {
|
if(!$head) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mimes = [
|
$mimes = [
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
'image/png',
|
'image/png',
|
||||||
|
@ -114,7 +114,7 @@ class MediaStorageService {
|
||||||
];
|
];
|
||||||
|
|
||||||
$mime = $head['mime'];
|
$mime = $head['mime'];
|
||||||
$max_size = (int) config('pixelfed.max_photo_size') * 1000;
|
$max_size = (int) config_cache('pixelfed.max_photo_size') * 1000;
|
||||||
$media->size = $head['length'];
|
$media->size = $head['length'];
|
||||||
$media->remote_media = true;
|
$media->remote_media = true;
|
||||||
$media->save();
|
$media->save();
|
||||||
|
@ -247,4 +247,4 @@ class MediaStorageService {
|
||||||
}
|
}
|
||||||
MediaDeletePipeline::dispatch($media);
|
MediaDeletePipeline::dispatch($media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue