|
|
@ -50,6 +50,22 @@ class UserController extends AbstractController |
|
|
|
public function list( |
|
|
|
public function list( |
|
|
|
?Request $request |
|
|
|
?Request $request |
|
|
|
): Response |
|
|
|
): Response |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Connect memcached |
|
|
|
|
|
|
|
$memcached = new \Memcached(); |
|
|
|
|
|
|
|
$memcached->addServer( |
|
|
|
|
|
|
|
$this->getParameter('app.memcached.host'), |
|
|
|
|
|
|
|
$this->getParameter('app.memcached.port') |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$memory = md5( |
|
|
|
|
|
|
|
sprintf( |
|
|
|
|
|
|
|
'%s.UserController::list:list', |
|
|
|
|
|
|
|
__DIR__, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$list = $memcached->get($memory)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$list = []; |
|
|
|
$list = []; |
|
|
|
|
|
|
|
|
|
|
@ -81,19 +97,32 @@ class UserController extends AbstractController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Get room stats |
|
|
|
// Get room stats |
|
|
|
$total = 0; |
|
|
|
|
|
|
|
$rooms = []; |
|
|
|
$rooms = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->_rooms($client) as $room => $name) |
|
|
|
foreach ((array) $client->kevaListNamespaces() as $value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (empty($value['namespaceId'])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($value['displayName'])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (str_starts_with($value['displayName'], '_')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$posts = 0; |
|
|
|
$posts = 0; |
|
|
|
|
|
|
|
|
|
|
|
foreach ((array) $client->kevaFilter($room, sprintf('^[\d]+@%s$', $user['key'])) as $post) |
|
|
|
foreach ((array) $client->kevaFilter($value['namespaceId'], sprintf('^[\d]+@%s$', $user['key'])) as $post) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$total++; |
|
|
|
|
|
|
|
$posts++; |
|
|
|
$posts++; |
|
|
|
|
|
|
|
|
|
|
|
$rooms[$room] = $posts; |
|
|
|
$rooms[$value['displayName']] = $posts; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -107,7 +136,6 @@ class UserController extends AbstractController |
|
|
|
'address' => $client->getAccountAddress( |
|
|
|
'address' => $client->getAccountAddress( |
|
|
|
$user['key'] |
|
|
|
$user['key'] |
|
|
|
), |
|
|
|
), |
|
|
|
'total' => $total, |
|
|
|
|
|
|
|
'rooms' => $rooms, |
|
|
|
'rooms' => $rooms, |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
@ -124,6 +152,13 @@ class UserController extends AbstractController |
|
|
|
$list |
|
|
|
$list |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cache result |
|
|
|
|
|
|
|
$memcached->set( |
|
|
|
|
|
|
|
$memory, |
|
|
|
|
|
|
|
$list |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RSS |
|
|
|
// RSS |
|
|
|
if ('rss' === $request->get('feed')) |
|
|
|
if ('rss' === $request->get('feed')) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -882,35 +917,6 @@ class UserController extends AbstractController |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function _rooms( |
|
|
|
|
|
|
|
\Kevachat\Kevacoin\Client $client |
|
|
|
|
|
|
|
): array |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$rooms = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ((array) $client->kevaListNamespaces() as $value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (empty($value['namespaceId'])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($value['displayName'])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (str_starts_with($value['displayName'], '_')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rooms[$value['namespaceId']] = $value['displayName']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $rooms; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function _hash( |
|
|
|
private function _hash( |
|
|
|
\Kevachat\Kevacoin\Client $client, |
|
|
|
\Kevachat\Kevacoin\Client $client, |
|
|
|
string $namespace, |
|
|
|
string $namespace, |
|
|
|