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