1
0
Fork 0
pixelfed/app/Util/Site/Config.php

116 lines
4.7 KiB
PHP
Raw Normal View History

2019-08-02 08:14:30 +00:00
<?php
namespace App\Util\Site;
use Cache;
2019-12-18 03:56:09 +00:00
use Illuminate\Support\Str;
2019-08-02 08:14:30 +00:00
2024-03-10 10:19:44 +00:00
class Config
{
2023-10-23 07:15:02 +00:00
const CACHE_KEY = 'api:site:configuration:_v0.8';
2021-05-19 08:01:33 +00:00
2024-03-10 10:19:44 +00:00
public static function get()
{
return Cache::remember(self::CACHE_KEY, 900, function () {
2023-10-23 07:15:02 +00:00
$hls = [
'enabled' => config('media.hls.enabled'),
];
2024-03-10 10:19:44 +00:00
if (config('media.hls.enabled')) {
2023-10-23 07:15:02 +00:00
$hls = [
'enabled' => true,
'debug' => (bool) config('media.hls.debug'),
'p2p' => (bool) config('media.hls.p2p'),
'p2p_debug' => (bool) config('media.hls.p2p_debug'),
'tracker' => config('media.hls.tracker'),
2024-03-10 10:19:44 +00:00
'ice' => config('media.hls.ice'),
2023-10-23 07:15:02 +00:00
];
}
2024-03-10 10:19:44 +00:00
2023-10-23 07:15:02 +00:00
return [
'version' => config('pixelfed.version'),
'open_registration' => (bool) config_cache('pixelfed.open_registration'),
'uploader' => [
'max_photo_size' => (int) config('pixelfed.max_photo_size'),
2024-03-10 10:19:44 +00:00
'max_caption_length' => (int) config_cache('pixelfed.max_caption_length'),
2024-03-10 10:37:22 +00:00
'max_altext_length' => (int) config_cache('pixelfed.max_altext_length', 150),
2023-10-23 07:15:02 +00:00
'album_limit' => (int) config_cache('pixelfed.max_album_length'),
'image_quality' => (int) config_cache('pixelfed.image_quality'),
2019-08-02 08:14:30 +00:00
2023-10-23 07:15:02 +00:00
'max_collection_length' => (int) config('pixelfed.max_collection_length', 18),
2020-12-10 08:02:56 +00:00
2023-10-23 07:15:02 +00:00
'optimize_image' => (bool) config('pixelfed.optimize_image'),
'optimize_video' => (bool) config('pixelfed.optimize_video'),
2019-08-02 08:14:30 +00:00
2023-10-23 07:15:02 +00:00
'media_types' => config_cache('pixelfed.media_types'),
'mime_types' => config_cache('pixelfed.media_types') ? explode(',', config_cache('pixelfed.media_types')) : [],
2024-03-10 10:19:44 +00:00
'enforce_account_limit' => (bool) config_cache('pixelfed.enforce_account_limit'),
2023-10-23 07:15:02 +00:00
],
2019-08-02 08:14:30 +00:00
2023-10-23 07:15:02 +00:00
'activitypub' => [
'enabled' => (bool) config_cache('federation.activitypub.enabled'),
2024-03-10 10:19:44 +00:00
'remote_follow' => config('federation.activitypub.remoteFollow'),
2023-10-23 07:15:02 +00:00
],
2019-08-02 08:14:30 +00:00
2023-10-23 07:15:02 +00:00
'ab' => config('exp'),
2019-08-02 08:14:30 +00:00
2023-10-23 07:15:02 +00:00
'site' => [
'name' => config_cache('app.name'),
'domain' => config('pixelfed.domain.app'),
2024-03-10 10:19:44 +00:00
'url' => config('app.url'),
'description' => config_cache('app.short_description'),
2023-10-23 07:15:02 +00:00
],
2019-11-03 03:12:44 +00:00
2023-10-23 07:15:02 +00:00
'account' => [
'max_avatar_size' => config('pixelfed.max_avatar_size'),
'max_bio_length' => config('pixelfed.max_bio_length'),
'max_name_length' => config('pixelfed.max_name_length'),
'min_password_length' => config('pixelfed.min_password_length'),
2024-03-10 10:19:44 +00:00
'max_account_size' => config('pixelfed.max_account_size'),
2023-10-23 07:15:02 +00:00
],
2023-04-12 04:12:09 +00:00
2023-10-23 07:15:02 +00:00
'username' => [
'remote' => [
'formats' => config('instance.username.remote.formats'),
'format' => config('instance.username.remote.format'),
2024-03-10 10:19:44 +00:00
'custom' => config('instance.username.remote.custom'),
],
2023-10-23 07:15:02 +00:00
],
2019-12-18 03:56:09 +00:00
2023-10-23 07:15:02 +00:00
'features' => [
'timelines' => [
'local' => true,
'network' => (bool) config('federation.network_timeline'),
],
'mobile_apis' => (bool) config_cache('pixelfed.oauth_enabled'),
'stories' => (bool) config_cache('instance.stories.enabled'),
'video' => Str::contains(config_cache('pixelfed.media_types'), 'video/mp4'),
'import' => [
'instagram' => (bool) config_cache('pixelfed.import.instagram.enabled'),
'mastodon' => false,
2024-03-10 10:19:44 +00:00
'pixelfed' => false,
2023-10-23 07:15:02 +00:00
],
'label' => [
'covid' => [
'enabled' => (bool) config('instance.label.covid.enabled'),
'org' => config('instance.label.covid.org'),
'url' => config('instance.label.covid.url'),
2024-03-10 10:19:44 +00:00
],
2023-10-23 07:15:02 +00:00
],
2024-03-10 10:19:44 +00:00
'hls' => $hls,
],
2023-10-23 07:15:02 +00:00
];
});
}
2019-08-02 08:14:30 +00:00
2024-03-10 10:37:22 +00:00
public static function refresh()
{
Cache::forget(self::CACHE_KEY);
return self::get();
}
2024-03-10 10:19:44 +00:00
public static function json()
{
2023-10-23 07:15:02 +00:00
return json_encode(self::get(), JSON_FORCE_OBJECT);
}
2019-08-02 08:14:30 +00:00
}