Browse Source

draft post features

main
ghost 1 year ago
parent
commit
7e0d0e2b7d
  1. 8
      .env
  2. 5
      config/services.yaml
  3. 39
      src/Controller/RoomController.php

8
.env

@ -54,4 +54,10 @@ APP_ADD_ROOM_REMOTE_IP_REGEX=/.*/ @@ -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
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}/

5
config/services.yaml

@ -18,6 +18,11 @@ parameters: @@ -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

39
src/Controller/RoomController.php

@ -148,7 +148,7 @@ class RoomController extends AbstractController @@ -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 @@ -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 @@ -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',
[

Loading…
Cancel
Save