|
|
@ -103,14 +103,23 @@ class RoomController extends AbstractController |
|
|
|
// Require valid kevachat meta |
|
|
|
// Require valid kevachat meta |
|
|
|
if ($data = $this->_post($pending)) |
|
|
|
if ($data = $this->_post($pending)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$feed[] = |
|
|
|
// Detect parent post |
|
|
|
|
|
|
|
preg_match('/^@([A-z0-9]{64})\s/i', $data->message, $mention); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$feed[$data->id] = |
|
|
|
[ |
|
|
|
[ |
|
|
|
'id' => $data->id, |
|
|
|
'id' => $data->id, |
|
|
|
'user' => $data->user, |
|
|
|
'user' => $data->user, |
|
|
|
'icon' => $data->icon, |
|
|
|
'icon' => $data->icon, |
|
|
|
'message' => $data->message, |
|
|
|
'time' => $data->time, |
|
|
|
'timestamp' => $data->time, |
|
|
|
'parent' => isset($mention[1]) ? $mention[1] : null, |
|
|
|
'time' => date('c', $data->time), |
|
|
|
'message' => trim( |
|
|
|
|
|
|
|
preg_replace( // remove mention from folded message |
|
|
|
|
|
|
|
'/^@([A-z0-9]{64})\s/i', |
|
|
|
|
|
|
|
'', |
|
|
|
|
|
|
|
$data->message |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
), |
|
|
|
'pending' => true |
|
|
|
'pending' => true |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
@ -128,14 +137,23 @@ class RoomController extends AbstractController |
|
|
|
// Require valid kevachat meta |
|
|
|
// Require valid kevachat meta |
|
|
|
if ($data = $this->_post($post)) |
|
|
|
if ($data = $this->_post($post)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$feed[] = |
|
|
|
// Detect parent post |
|
|
|
|
|
|
|
preg_match('/^@([A-z0-9]{64})\s/i', $data->message, $mention); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$feed[$data->id] = |
|
|
|
[ |
|
|
|
[ |
|
|
|
'id' => $data->id, |
|
|
|
'id' => $data->id, |
|
|
|
'user' => $data->user, |
|
|
|
'user' => $data->user, |
|
|
|
'icon' => $data->icon, |
|
|
|
'icon' => $data->icon, |
|
|
|
'message' => $data->message, |
|
|
|
'time' => $data->time, |
|
|
|
'timestamp' => $data->time, |
|
|
|
'parent' => isset($mention[1]) ? $mention[1] : null, |
|
|
|
'time' => date('c', $data->time), |
|
|
|
'message' => trim( |
|
|
|
|
|
|
|
preg_replace( // remove mention from folded message |
|
|
|
|
|
|
|
'/^@([A-z0-9]{64})\s/i', |
|
|
|
|
|
|
|
'', |
|
|
|
|
|
|
|
$data->message |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
), |
|
|
|
'pending' => false |
|
|
|
'pending' => false |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
@ -151,6 +169,14 @@ class RoomController extends AbstractController |
|
|
|
$feed |
|
|
|
$feed |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init folding &data pool |
|
|
|
|
|
|
|
$fold = $feed; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Build threading tree |
|
|
|
|
|
|
|
$tree = $this->_tree( |
|
|
|
|
|
|
|
$fold |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// RSS |
|
|
|
// RSS |
|
|
|
if ('rss' === $request->get('feed')) |
|
|
|
if ('rss' === $request->get('feed')) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -176,6 +202,7 @@ class RoomController extends AbstractController |
|
|
|
'default/room/index.html.twig', |
|
|
|
'default/room/index.html.twig', |
|
|
|
[ |
|
|
|
[ |
|
|
|
'feed' => $feed, |
|
|
|
'feed' => $feed, |
|
|
|
|
|
|
|
'tree' => $tree, |
|
|
|
'request' => $request |
|
|
|
'request' => $request |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
@ -440,4 +467,36 @@ class RoomController extends AbstractController |
|
|
|
|
|
|
|
|
|
|
|
return $identicon->getImageDataUri('webp'); |
|
|
|
return $identicon->getImageDataUri('webp'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function _tree( |
|
|
|
|
|
|
|
array &$feed, |
|
|
|
|
|
|
|
?string $parent = null |
|
|
|
|
|
|
|
): array |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$tree = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($feed as $post) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ($post['parent'] == $parent) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$children = $this->_tree( |
|
|
|
|
|
|
|
$feed, |
|
|
|
|
|
|
|
$post['id'] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($children) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$post['tree'] = $children; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tree[$post['id']] = $post; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unset( |
|
|
|
|
|
|
|
$feed[$post['id']] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $tree; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |