]> git.mxchange.org Git - friendica.git/commitdiff
Fix context order / notice fixed
authorMichael <heluecht@pirati.ca>
Tue, 11 May 2021 19:53:19 +0000 (19:53 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 11 May 2021 19:53:19 +0000 (19:53 +0000)
src/Factory/Api/Mastodon/Card.php
src/Module/Api/Mastodon/Statuses/Context.php
src/Module/OAuth/Token.php

index cc160b1022740f808a549ab1f3f14fdf22f11ac7..1505fa85292cda475d805e1c5b529608ff69950f 100644 (file)
@@ -40,6 +40,8 @@ class Card extends BaseFactory
                $item = Post::selectFirst(['nody'], ['uri-id' => $uriId]);
                if (!empty($item['body'])) {
                        $data = BBCode::getAttachmentData($item['body']);
+               } else {
+                       $data = [];
                }
 
                foreach (Post\Media::getByURIId($uriId, [Post\Media::HTML]) as $attached) {
index bf49d265ca777804311e6a077236a6e879e0e09e..5615e41cc94d4b7291ac31426afa313d589c36b8 100644 (file)
@@ -54,7 +54,8 @@ class Context extends BaseApi
                $parents  = [];
                $children = [];
 
-               $posts = Post::select(['uri-id', 'thr-parent-id'], ['parent-uri-id' => $parent['parent-uri-id']], [], false);
+               $posts = Post::select(['uri-id', 'thr-parent-id'],
+                       ['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]], [], false);
                while ($post = Post::fetch($posts)) {
                        if ($post['uri-id'] == $post['thr-parent-id']) {
                                continue;
@@ -67,12 +68,24 @@ class Context extends BaseApi
 
                $statuses = ['ancestors' => [], 'descendants' => []];
 
+               $ancestors = [];
                foreach (self::getParents($id, $parents) as $ancestor) {
-                       $statuses['ancestors'][] = DI::mstdnStatus()->createFromUriId($ancestor, $uid);
+                       $ancestors[$ancestor] = DI::mstdnStatus()->createFromUriId($ancestor, $uid);
                }
 
+               ksort($ancestors);
+               foreach ($ancestors as $ancestor) {
+                       $statuses['ancestors'][] = $ancestor;
+               }
+
+               $descendants = [];
                foreach (self::getChildren($id, $children) as $descendant) {
-                       $statuses['descendants'][] = DI::mstdnStatus()->createFromUriId($descendant, $uid);
+                       $descendants[] = DI::mstdnStatus()->createFromUriId($descendant, $uid);
+               }
+
+               ksort($descendants);
+               foreach ($descendants as $descendant) {
+                       $statuses['descendants'][] = $descendant;
                }
 
                System::jsonExit($statuses);
index 6e574a8af199475e6318d48bfac3528f9aa2c3f2..1d0b43cd67fecebe8552875cdf8fd3a2b1f33bb1 100644 (file)
@@ -55,7 +55,7 @@ class Token extends BaseApi
 
                $condition = ['application-id' => $application['id'], 'code' => $code];
 
-               $token = DBA::selectFirst('application-token', ['access_token'], $condition);
+               $token = DBA::selectFirst('application-token', ['access_token', 'created_at'], $condition);
                if (!DBA::isResult($token)) {
                        Logger::warning('Token not found', $condition);
                        DI::mstdnError()->RecordNotFound();