add record exist validation on route request

This commit is contained in:
yggverse 2024-05-05 04:49:23 +03:00
parent cf36d79cad
commit 67c6fab4cf

View file

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