]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Api/Mastodon/Statuses/Context.php
Context: use the correct "select functionality
[friendica.git] / src / Module / Api / Mastodon / Statuses / Context.php
index afa42f7b4048bf43ed32b87b761c2618d811ee3f..226e52c9ea42224c8958ff6918e374fda41244ce 100644 (file)
@@ -58,8 +58,8 @@ class Context extends BaseApi
                $parents  = [];
                $children = [];
 
-               $posts = Post::select(['uri-id', 'thr-parent-id'],
-                       ['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]], [], false);
+               $posts = Post::selectPosts(['uri-id', 'thr-parent-id'],
+                       ['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]], []);
                while ($post = Post::fetch($posts)) {
                        if ($post['uri-id'] == $post['thr-parent-id']) {
                                continue;
@@ -72,22 +72,18 @@ class Context extends BaseApi
 
                $statuses = ['ancestors' => [], 'descendants' => []];
 
-               $ancestors = [];
-               foreach (self::getParents($id, $parents) as $ancestor) {
-                       $ancestors[] = $ancestor;
-               }
+               $ancestors = self::getParents($id, $parents);
 
                asort($ancestors);
+
                foreach (array_slice($ancestors, 0, $request['limit']) as $ancestor) {
                        $statuses['ancestors'][] = DI::mstdnStatus()->createFromUriId($ancestor, $uid);;
                }
 
-               $descendants = [];
-               foreach (self::getChildren($id, $children) as $descendant) {
-                       $descendants[] = $descendant; 
-               }
+               $descendants = self::getChildren($id, $children);
 
                asort($descendants);
+
                foreach (array_slice($descendants, 0, $request['limit']) as $descendant) {
                        $statuses['descendants'][] = DI::mstdnStatus()->createFromUriId($descendant, $uid);
                }