From 816e8c61db5b5595f5b70154e62eaf4bc7231f60 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 6 Dec 2023 05:02:11 +0200 Subject: [PATCH] add external room settings --- .env | 3 +++ config/services.yaml | 1 + src/Controller/RoomController.php | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 59aec13..10bbc26 100644 --- a/.env +++ b/.env @@ -51,6 +51,9 @@ APP_KEVACOIN_ROOM_NAMESPACES_READONLY=EDIT_ME # Redirect from index page to default room APP_KEVACOIN_ROOM_NAMESPACE_DEFAULT=EDIT_ME +# Allow users to read external node rooms (true|false) +APP_KEVACOIN_ROOM_NAMESPACE_EXTERNAL=false + # Allow remotes to create new rooms (namespaces) APP_ADD_ROOM_REMOTE_IP_REGEX=/.*/ diff --git a/config/services.yaml b/config/services.yaml index c43c3ae..0000ce4 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -16,6 +16,7 @@ parameters: app.kevacoin.room.namespaces: '%env(APP_KEVACOIN_ROOM_NAMESPACES)%' app.kevacoin.room.namespaces.readonly: '%env(APP_KEVACOIN_ROOM_NAMESPACES_READONLY)%' app.kevacoin.room.namespace.default: '%env(APP_KEVACOIN_ROOM_NAMESPACE_DEFAULT)%' + app.kevacoin.room.namespace.external: '%env(APP_KEVACOIN_ROOM_NAMESPACE_EXTERNAL)%' app.kevacoin.mine.address: '%env(APP_KEVACOIN_MINE_ADDRESS)%' app.kevacoin.mine.pool.url: '%env(APP_KEVACOIN_MINE_POOL_URL)%' app.kevacoin.mine.solo.url: '%env(APP_KEVACOIN_MINE_SOLO_URL)%' diff --git a/src/Controller/RoomController.php b/src/Controller/RoomController.php index 30fe9fb..1776b48 100644 --- a/src/Controller/RoomController.php +++ b/src/Controller/RoomController.php @@ -75,6 +75,21 @@ class RoomController extends AbstractController } } + // Check for external rooms reading allowed in config + if ( + !in_array( + $request->get('namespace'), + (array) explode('|', $this->getParameter('app.kevacoin.room.namespaces')) + ) + && + $this->getParameter('app.kevacoin.room.namespace.external') === 'false' + ) { + // @TODO process to error page instead of redirect to default room + return $this->redirectToRoute( + 'room_index' + ); + } + // Get room feed $feed = []; @@ -225,7 +240,7 @@ class RoomController extends AbstractController ); } - // Check namespace writable + // Check namespace defined in config if (!in_array($request->get('namespace'), (array) explode('|', $this->getParameter('app.kevacoin.room.namespaces')))) { return $this->redirectToRoute(