Browse Source

fix pending rooms display

main
ghost 10 months ago
parent
commit
65fbdb9729
  1. 2
      .env
  2. 86
      src/Controller/RoomController.php

2
.env

@ -19,7 +19,7 @@ APP_ENV=dev
APP_SECRET=EDIT_ME APP_SECRET=EDIT_ME
###< symfony/framework-bundle ### ###< symfony/framework-bundle ###
APP_VERSION=1.8.1 APP_VERSION=1.8.2
APP_NAME=KevaChat APP_NAME=KevaChat

86
src/Controller/RoomController.php

@ -65,29 +65,33 @@ class RoomController extends AbstractController
continue; continue;
} }
// Calculate room totals // Add to room list
$total = 0; $list[$value['namespaceId']] = // keep unique
[
foreach ((array) $client->kevaFilter($value['namespaceId']) as $post) 'namespace' => $value['namespaceId'],
{ 'total' => $this->_total(
// Skip values with meta keys $value['namespaceId']
if (str_starts_with($post['key'], '_')) ),
{ 'pinned' => in_array(
continue; $value['namespaceId'],
(array) explode(
'|',
$this->getParameter('app.kevacoin.room.namespaces.pinned')
)
)
];
} }
// Require valid kevachat meta // Get rooms contain pending data
if ($this->_post($post)) foreach ((array) $client->kevaPending() as $value)
{ {
$total++;
}
}
// Add to room list // Add to room list
$list[] = $list[$value['namespace']] = // keep unique
[ [
'namespace' => $value['namespaceId'], 'namespace' => $value['namespace'],
'total' => $total, 'total' => $this->_total(
$value['namespace']
),
'pinned' => in_array( 'pinned' => in_array(
$value['namespaceId'], $value['namespaceId'],
(array) explode( (array) explode(
@ -918,4 +922,50 @@ class RoomController extends AbstractController
return $tree; return $tree;
} }
private function _total(string $namespace): int
{
// Connect kevacoin
$client = new \Kevachat\Kevacoin\Client(
$this->getParameter('app.kevacoin.protocol'),
$this->getParameter('app.kevacoin.host'),
$this->getParameter('app.kevacoin.port'),
$this->getParameter('app.kevacoin.username'),
$this->getParameter('app.kevacoin.password')
);
$raw = [];
// Get pending
foreach ((array) $client->kevaPending() as $pending)
{
// Ignore other namespaces
if ($pending['namespace'] != $namespace)
{
continue;
}
$raw[] = $pending;
}
// Get records
foreach ((array) $this->_kevacoin->kevaFilter($namespace) as $record)
{
$raw[] = $record;
}
// Count begin
$total = 0;
foreach ($raw as $data)
{
// Is valid post
if ($this->_post($data))
{
$total++;
}
}
return $total;
}
} }
Loading…
Cancel
Save