|
|
@ -4,10 +4,13 @@ $response = [ |
|
|
|
'success' => false, |
|
|
|
'success' => false, |
|
|
|
'message' => _('Internal server error'), |
|
|
|
'message' => _('Internal server error'), |
|
|
|
'posts' => [], |
|
|
|
'posts' => [], |
|
|
|
|
|
|
|
'page' => 0, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
if (isset($_SESSION['userName'])) { |
|
|
|
if (isset($_SESSION['userName'])) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$page = isset($_GET['page']) ? Filter::int($_GET['page']) : 1; |
|
|
|
|
|
|
|
|
|
|
|
$userNames = []; |
|
|
|
$userNames = []; |
|
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['userName']) && !empty($_GET['userName'])) { |
|
|
|
if (isset($_GET['userName']) && !empty($_GET['userName'])) { |
|
|
@ -22,11 +25,15 @@ if (isset($_SESSION['userName'])) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($result = $_twister->getPosts($userNames, APPLICATION_MAX_POST_FEED)) { |
|
|
|
if ($result = $_twister->getPosts($userNames, APPLICATION_MAX_POST_FEED * $page)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$postsTotal = 0; |
|
|
|
$posts = []; |
|
|
|
$posts = []; |
|
|
|
foreach ($result as $post) { |
|
|
|
foreach ($result as $post) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Count posts |
|
|
|
|
|
|
|
$postsTotal++; |
|
|
|
|
|
|
|
|
|
|
|
// Process reTwists |
|
|
|
// Process reTwists |
|
|
|
$reTwist = []; |
|
|
|
$reTwist = []; |
|
|
|
if ($post['reTwist']) { |
|
|
|
if ($post['reTwist']) { |
|
|
@ -50,7 +57,8 @@ if (isset($_SESSION['userName'])) { |
|
|
|
$response = [ |
|
|
|
$response = [ |
|
|
|
'success' => true, |
|
|
|
'success' => true, |
|
|
|
'message' => _('Posts successfully loaded'), |
|
|
|
'message' => _('Posts successfully loaded'), |
|
|
|
'posts' => $posts |
|
|
|
'posts' => $posts, |
|
|
|
|
|
|
|
'page' => $postsTotal == $page * APPLICATION_MAX_POST_FEED ? $page + 1 : 0 |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -59,6 +67,7 @@ if (isset($_SESSION['userName'])) { |
|
|
|
'success' => false, |
|
|
|
'success' => false, |
|
|
|
'message' => _('Could not receive post data'), |
|
|
|
'message' => _('Could not receive post data'), |
|
|
|
'posts' => [], |
|
|
|
'posts' => [], |
|
|
|
|
|
|
|
'page' => 0 |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -67,6 +76,7 @@ if (isset($_SESSION['userName'])) { |
|
|
|
'success' => false, |
|
|
|
'success' => false, |
|
|
|
'message' => _('Session expired'), |
|
|
|
'message' => _('Session expired'), |
|
|
|
'posts' => [], |
|
|
|
'posts' => [], |
|
|
|
|
|
|
|
'page' => 0 |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|