diff --git a/app/Http/Controllers/LiveStreamController.php b/app/Http/Controllers/LiveStreamController.php index a25cc3f12..51cc160f9 100644 --- a/app/Http/Controllers/LiveStreamController.php +++ b/app/Http/Controllers/LiveStreamController.php @@ -217,4 +217,20 @@ class LiveStreamController extends Controller return; } + + public function getConfig(Request $request) + { + abort_if(!config('livestreaming.enabled'), 400); + abort_if(!$request->user(), 403); + + $res = [ + 'enabled' => config('livestreaming.enabled'), + 'broadcast' => [ + 'sources' => config('livestreaming.broadcast.sources'), + 'limits' => config('livestreaming.broadcast.limits') + ], + ]; + + return response()->json($res, 200, [], JSON_UNESCAPED_SLASHES); + } } diff --git a/config/livestreaming.php b/config/livestreaming.php index 00ad13fd4..a5c08ba20 100644 --- a/config/livestreaming.php +++ b/config/livestreaming.php @@ -10,14 +10,19 @@ return [ ], 'broadcast' => [ - 'max_duration' => env('HLS_LIVE_BROADCAST_MAX_DURATION', 60), - 'max_active' => env('HLS_LIVE_BROADCAST_MAX_ACTIVE', 10), + 'max_duration' => (int) env('HLS_LIVE_BROADCAST_MAX_DURATION', 60), + 'max_active' => (int) env('HLS_LIVE_BROADCAST_MAX_ACTIVE', 10), 'limits' => [ - 'enabled' => env('HLS_LIVE_BROADCAST_LIMITS', true), - 'min_follower_count' => env('HLS_LIVE_BROADCAST_LIMITS_MIN_FOLLOWERS', 100), - 'min_account_age' => env('HLS_LIVE_BROADCAST_LIMITS_MIN_ACCOUNT_AGE', 14), - 'admins_only' => env('HLS_LIVE_BROADCAST_LIMITS_ADMINS_ONLY', true) + 'enabled' => (bool) env('HLS_LIVE_BROADCAST_LIMITS', true), + 'min_follower_count' => (int) env('HLS_LIVE_BROADCAST_LIMITS_MIN_FOLLOWERS', 100), + 'min_account_age' => (int) env('HLS_LIVE_BROADCAST_LIMITS_MIN_ACCOUNT_AGE', 14), + 'admins_only' => (bool) env('HLS_LIVE_BROADCAST_LIMITS_ADMINS_ONLY', true) + ], + + 'sources' => [ + 'app' => (bool) env('HLS_LIVE_BROADCAST_SOURCE_APP', false), + 'web' => (bool) env('HLS_LIVE_BROADCAST_SOURCE_WEB', false) ] ], diff --git a/routes/api.php b/routes/api.php index 982e6f81d..844942c36 100644 --- a/routes/api.php +++ b/routes/api.php @@ -105,5 +105,6 @@ Route::group(['prefix' => 'api'], function() use($middleware) { Route::get('chat/latest', 'LiveStreamController@getLatestChat')->middleware($middleware); Route::post('chat/message', 'LiveStreamController@addChatComment')->middleware($middleware); Route::post('chat/delete', 'LiveStreamController@deleteChatComment')->middleware($middleware); + Route::get('config', 'LiveStreamController@getConfig')->middleware($middleware); }); });