Browse Source

add record exist validation on route request

main
yggverse 2 months ago
parent
commit
67c6fab4cf
  1. 24
      src/Controller/Server/Nex.php

24
src/Controller/Server/Nex.php

@ -88,13 +88,16 @@ class Nex implements MessageComponentInterface @@ -88,13 +88,16 @@ class Nex implements MessageComponentInterface
break;
// Chanel item
case (bool) preg_match('/\/(?<id>\d+)($|\.gmi)$/i', $request, $attribute):
case preg_match(
'/\/(?<id>\d+)($|\.gmi)$/i',
$request,
$attribute
) && $channelItem = $this->_database->getChannelItem(
$attribute['id']
):
$lines = [];
// Get channel item info
if ($channelItem = $this->_database->getChannelItem($attribute['id']))
{
if ($channelItem->title)
{
$lines[] = sprintf(
@ -134,7 +137,6 @@ class Nex implements MessageComponentInterface @@ -134,7 +137,6 @@ class Nex implements MessageComponentInterface
$channelItem->link
);
}
}
// Get channel info
if ($channel = $this->_database->getChannel($channelItem->channelId))
@ -155,13 +157,16 @@ class Nex implements MessageComponentInterface @@ -155,13 +157,16 @@ class Nex implements MessageComponentInterface
break;
// Channel page
case (bool) preg_match('/^\/(?<alias>.+)$/i', $request, $attribute):
case preg_match(
'/^\/(?<alias>.+)$/i',
$request,
$attribute
) && $channel = $this->_database->getChannelByAlias(
$attribute['alias']
):
$lines = [];
// Get channel info
if ($channel = $this->_database->getChannelByAlias($attribute['alias']))
{
if ($channel->title)
{
$lines[] = sprintf(
@ -202,7 +207,6 @@ class Nex implements MessageComponentInterface @@ -202,7 +207,6 @@ class Nex implements MessageComponentInterface
) . PHP_EOL;
}
}
}
// Build response
$response = implode(

Loading…
Cancel
Save