pixelfed/app/Util/Site/Config.php

85 lines
2.5 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
class Config {
2021-08-05 02:29:21 +00:00
const CACHE_KEY = 'api:site:configuration:_v0.4';
2021-05-19 08:01:33 +00:00
2019-08-02 08:14:30 +00:00
public static function get() {
2021-05-19 08:01:33 +00:00
return Cache::remember(self::CACHE_KEY, now()->addMinutes(5), function() {
2019-08-02 08:14:30 +00:00
return [
2021-05-11 05:23:09 +00:00
'open_registration' => (bool) config_cache('pixelfed.open_registration'),
2019-08-02 08:14:30 +00:00
'uploader' => [
'max_photo_size' => config('pixelfed.max_photo_size'),
'max_caption_length' => config('pixelfed.max_caption_length'),
2021-05-11 03:04:23 +00:00
'album_limit' => config_cache('pixelfed.max_album_length'),
'image_quality' => config_cache('pixelfed.image_quality'),
2019-08-02 08:14:30 +00:00
2020-12-10 08:02:56 +00:00
'max_collection_length' => config('pixelfed.max_collection_length', 18),
'optimize_image' => (bool) config('pixelfed.optimize_image'),
'optimize_video' => (bool) config('pixelfed.optimize_video'),
2019-08-02 08:14:30 +00:00
2021-05-11 03:11:43 +00:00
'media_types' => config_cache('pixelfed.media_types'),
'enforce_account_limit' => (bool) config_cache('pixelfed.enforce_account_limit')
2019-08-02 08:14:30 +00:00
],
'activitypub' => [
'enabled' => (bool) config_cache('federation.activitypub.enabled'),
2019-08-02 08:14:30 +00:00
'remote_follow' => config('federation.activitypub.remoteFollow')
],
'ab' => [
'lc' => config('exp.lc'),
'rec' => config('exp.rec'),
2021-01-17 08:36:03 +00:00
'loops' => config('exp.loops'),
2021-08-05 02:29:21 +00:00
'top' => config('exp.top'),
'polls' => config('exp.polls')
2019-08-02 08:14:30 +00:00
],
'site' => [
2021-05-08 03:47:51 +00:00
'name' => config_cache('app.name'),
2019-08-02 08:14:30 +00:00
'domain' => config('pixelfed.domain.app'),
2019-12-18 03:56:09 +00:00
'url' => config('app.url'),
2021-05-08 03:47:51 +00:00
'description' => config_cache('app.short_description')
2019-11-03 03:12:44 +00:00
],
'username' => [
'remote' => [
'formats' => config('instance.username.remote.formats'),
'format' => config('instance.username.remote.format'),
'custom' => config('instance.username.remote.custom')
]
2019-12-18 03:56:09 +00:00
],
'features' => [
'mobile_apis' => (bool) config_cache('pixelfed.oauth_enabled'),
2019-12-18 03:56:09 +00:00
'circles' => false,
'stories' => (bool) config_cache('instance.stories.enabled'),
2021-05-11 03:11:43 +00:00
'video' => Str::contains(config_cache('pixelfed.media_types'), 'video/mp4'),
2019-12-18 03:56:09 +00:00
'import' => [
2021-05-12 01:07:03 +00:00
'instagram' => config_cache('pixelfed.import.instagram.enabled'),
2019-12-18 03:56:09 +00:00
'mastodon' => false,
'pixelfed' => false
],
'label' => [
'covid' => [
'enabled' => (bool) config('instance.label.covid.enabled'),
'org' => config('instance.label.covid.org'),
'url' => config('instance.label.covid.url'),
]
2019-12-18 03:56:09 +00:00
]
2019-08-02 08:14:30 +00:00
]
];
});
}
public static function json() {
return json_encode(self::get(), JSON_FORCE_OBJECT);
}
}