diff --git a/.env b/.env index c85004d..532e120 100644 --- a/.env +++ b/.env @@ -54,4 +54,10 @@ APP_ADD_ROOM_REMOTE_IP_REGEX=/.*/ APP_ADD_POST_REMOTE_IP_REGEX=/.*/ # Time quota for remote publications by IP (seconds) -APP_ADD_POST_REMOTE_IP_DELAY=60 \ No newline at end of file +APP_ADD_POST_REMOTE_IP_DELAY=60 + +# Skip access limits for following IPs separated by | +APP_ADD_POST_REMOTE_IP_MODERATORS= + +# Post content rules (for kevacoin value) +APP_ADD_POST_VALUE_REGEX=/[\w]{2,3072}/ \ No newline at end of file diff --git a/config/services.yaml b/config/services.yaml index 56617f0..253487f 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -18,6 +18,11 @@ parameters: 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)%' + app.add.room.remote.ip.regex: '%env(APP_ADD_ROOM_REMOTE_IP_REGEX)%' + app.add.post.remote.ip.regex: '%env(APP_ADD_POST_REMOTE_IP_REGEX)%' + app.add.post.remote.ip.delay: '%env(APP_ADD_POST_REMOTE_IP_DELAY)%' + app.add.post.remote.ip.moderators: '%env(APP_ADD_POST_REMOTE_IP_MODERATORS)%' + app.add.post.value.regex: '%env(APP_ADD_POST_VALUE_REGEX)%' services: # default configuration for services in *this* file diff --git a/src/Controller/RoomController.php b/src/Controller/RoomController.php index 4472831..c62e830 100644 --- a/src/Controller/RoomController.php +++ b/src/Controller/RoomController.php @@ -148,7 +148,7 @@ class RoomController extends AbstractController } #[Route( - '/room/{namespace}/post', + '/room/{namespace}', name: 'room_post', requirements: [ @@ -172,7 +172,7 @@ class RoomController extends AbstractController $this->getParameter('app.kevacoin.password') ); - // Check namespace exist for this wallet + // Get local namespaces $namespaces = []; foreach ((array) $client->kevaListNamespaces() as $value) @@ -180,14 +180,45 @@ class RoomController extends AbstractController $namespaces[] = $value['namespaceId']; } + // Check namespace exist for this wallet if (!in_array($request->get('namespace'), $namespaces)) { exit('Namespace not related with this node!'); } - // @TODO + // Check namespace writable + if (!in_array($request->get('namespace'), (array) explode('|', $this->getParameter('app.kevacoin.room.namespaces')))) + { + exit('Namespace not listed in settings!'); + } + + // Validate access to the room namespace + if + ( + // Ignore this rule for is moderators + !in_array( + (array) explode('|', $this->getParameter('app.add.post.remote.ip.moderators')) + ) && + + // Check namespace writable or user is moderator + in_array( + $request->get('namespace'), + (array) explode('|', $this->getParameter('app.kevacoin.room.namespaces.readonly')) + ) + ) + { + exit('Namespace for read only!'); + } + + // Validate remote IP regex + + // Validate remote IP limits + + // Validate funds + + // @TODO Send message to DHT - // Redirect back to the room + // Redirect back to room return $this->redirectToRoute( 'room_namespace', [