Config.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. namespace App\Util\Site;
  3. use Cache;
  4. use Illuminate\Support\Str;
  5. class Config {
  6. const CACHE_KEY = 'api:site:configuration:_v0.8';
  7. public static function get() {
  8. return Cache::remember(self::CACHE_KEY, 900, function() {
  9. $hls = [
  10. 'enabled' => config('media.hls.enabled'),
  11. ];
  12. if(config('media.hls.enabled')) {
  13. $hls = [
  14. 'enabled' => true,
  15. 'debug' => (bool) config('media.hls.debug'),
  16. 'p2p' => (bool) config('media.hls.p2p'),
  17. 'p2p_debug' => (bool) config('media.hls.p2p_debug'),
  18. 'tracker' => config('media.hls.tracker'),
  19. 'ice' => config('media.hls.ice')
  20. ];
  21. }
  22. return [
  23. 'version' => config('pixelfed.version'),
  24. 'open_registration' => (bool) config_cache('pixelfed.open_registration'),
  25. 'uploader' => [
  26. 'max_photo_size' => (int) config('pixelfed.max_photo_size'),
  27. 'max_caption_length' => (int) config('pixelfed.max_caption_length'),
  28. 'max_altext_length' => (int) config('pixelfed.max_altext_length', 150),
  29. 'album_limit' => (int) config_cache('pixelfed.max_album_length'),
  30. 'image_quality' => (int) config_cache('pixelfed.image_quality'),
  31. 'max_collection_length' => (int) config('pixelfed.max_collection_length', 18),
  32. 'optimize_image' => (bool) config('pixelfed.optimize_image'),
  33. 'optimize_video' => (bool) config('pixelfed.optimize_video'),
  34. 'media_types' => config_cache('pixelfed.media_types'),
  35. 'mime_types' => config_cache('pixelfed.media_types') ? explode(',', config_cache('pixelfed.media_types')) : [],
  36. 'enforce_account_limit' => (bool) config_cache('pixelfed.enforce_account_limit')
  37. ],
  38. 'activitypub' => [
  39. 'enabled' => (bool) config_cache('federation.activitypub.enabled'),
  40. 'remote_follow' => config('federation.activitypub.remoteFollow')
  41. ],
  42. 'ab' => config('exp'),
  43. 'site' => [
  44. 'name' => config_cache('app.name'),
  45. 'domain' => config('pixelfed.domain.app'),
  46. 'url' => config('app.url'),
  47. 'description' => config_cache('app.short_description')
  48. ],
  49. 'account' => [
  50. 'max_avatar_size' => config('pixelfed.max_avatar_size'),
  51. 'max_bio_length' => config('pixelfed.max_bio_length'),
  52. 'max_name_length' => config('pixelfed.max_name_length'),
  53. 'min_password_length' => config('pixelfed.min_password_length'),
  54. 'max_account_size' => config('pixelfed.max_account_size')
  55. ],
  56. 'username' => [
  57. 'remote' => [
  58. 'formats' => config('instance.username.remote.formats'),
  59. 'format' => config('instance.username.remote.format'),
  60. 'custom' => config('instance.username.remote.custom')
  61. ]
  62. ],
  63. 'features' => [
  64. 'timelines' => [
  65. 'local' => true,
  66. 'network' => (bool) config('federation.network_timeline'),
  67. ],
  68. 'mobile_apis' => (bool) config_cache('pixelfed.oauth_enabled'),
  69. 'stories' => (bool) config_cache('instance.stories.enabled'),
  70. 'video' => Str::contains(config_cache('pixelfed.media_types'), 'video/mp4'),
  71. 'import' => [
  72. 'instagram' => (bool) config_cache('pixelfed.import.instagram.enabled'),
  73. 'mastodon' => false,
  74. 'pixelfed' => false
  75. ],
  76. 'label' => [
  77. 'covid' => [
  78. 'enabled' => (bool) config('instance.label.covid.enabled'),
  79. 'org' => config('instance.label.covid.org'),
  80. 'url' => config('instance.label.covid.url'),
  81. ]
  82. ],
  83. 'hls' => $hls
  84. ]
  85. ];
  86. });
  87. }
  88. public static function json() {
  89. return json_encode(self::get(), JSON_FORCE_OBJECT);
  90. }
  91. }