Browse Source

add room access options

main
ghost 12 months ago
parent
commit
71229df9e3
  1. 6
      .env
  2. 2
      config/services.yaml
  3. 17
      src/Controller/ModuleController.php
  4. 4
      src/Controller/RoomController.php

6
.env

@ -41,6 +41,12 @@ APP_KEVACOIN_MINE_ADDRESS=EDIT_ME @@ -41,6 +41,12 @@ APP_KEVACOIN_MINE_ADDRESS=EDIT_ME
# Allowed room namespaces, separated with | (must be owned to accept posts)
APP_KEVACOIN_ROOM_NAMESPACES=EDIT_ME
# Allowed room namespaces for read only (e.g. project news) separated with |
APP_KEVACOIN_ROOM_NAMESPACES_READONLY=EDIT_ME
# Redirect from index page to default room
APP_KEVACOIN_ROOM_NAMESPACE_DEFAULT=EDIT_ME
# Allow remotes to create new rooms (namespaces)
APP_ADD_ROOM_REMOTE_IP_REGEX=/.*/

2
config/services.yaml

@ -13,6 +13,8 @@ parameters: @@ -13,6 +13,8 @@ parameters:
app.kevacoin.username: '%env(APP_KEVACOIN_USERNAME)%'
app.kevacoin.password: '%env(APP_KEVACOIN_PASSWORD)%'
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.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)%'

17
src/Controller/ModuleController.php

@ -70,7 +70,7 @@ class ModuleController extends AbstractController @@ -70,7 +70,7 @@ class ModuleController extends AbstractController
$name = $value['displayName'];
}
// Check namespace enabled as room in settings
// Check namespace enabled as room in .env
if (in_array($value['namespaceId'], $rooms))
{
$list[$value['namespaceId']] = $value['displayName'];
@ -95,6 +95,7 @@ class ModuleController extends AbstractController @@ -95,6 +95,7 @@ class ModuleController extends AbstractController
Request $request
): Response
{
// Connect wallet
$client = new \Kevachat\Kevacoin\Client(
$this->getParameter('app.kevacoin.protocol'),
$this->getParameter('app.kevacoin.host'),
@ -103,18 +104,26 @@ class ModuleController extends AbstractController @@ -103,18 +104,26 @@ class ModuleController extends AbstractController
$this->getParameter('app.kevacoin.password')
);
// Get room settings
$rooms = explode('|', $this->getParameter('app.kevacoin.room.namespaces'));
$readonly = explode('|', $this->getParameter('app.kevacoin.room.namespaces.readonly'));
// Get wallet namespaces (to enable post module there)
$namespaces = [];
$public = [];
foreach ((array) $client->kevaListNamespaces() as $value)
{
$namespaces[] = $value['namespaceId'];
// Check namespace enabled as room in .env
if (in_array($value['namespaceId'], $rooms) && !in_array($value['namespaceId'], $readonly))
{
$public[] = $value['namespaceId'];
}
}
return $this->render(
'default/module/post.html.twig',
[
'enabled' => in_array($request->get('namespace'), $namespaces),
'enabled' => in_array($request->get('namespace'), $public),
'namespace' => $request->get('namespace'),
'message' => $request->get('message'),
'user' => $request->get('user'),

4
src/Controller/RoomController.php

@ -23,7 +23,7 @@ class RoomController extends AbstractController @@ -23,7 +23,7 @@ class RoomController extends AbstractController
return $this->redirectToRoute(
'room_namespace',
[
'namespace' => explode('|', $this->getParameter('app.kevacoin.room.namespaces'))[0]
'namespace' => $this->getParameter('app.kevacoin.room.namespace.default')
]
);
}
@ -176,7 +176,7 @@ class RoomController extends AbstractController @@ -176,7 +176,7 @@ class RoomController extends AbstractController
return $this->redirectToRoute(
'room_namespace',
[
'namespace' => explode('|', $this->getParameter('app.kevacoin.room.namespaces'))[0]
'namespace' => $request->get('namespace')
]
);
}

Loading…
Cancel
Save