]> git.mxchange.org Git - friendica.git/commitdiff
Catch not fetchable posts
authorMichael <heluecht@pirati.ca>
Wed, 25 Jan 2023 23:03:51 +0000 (23:03 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 25 Jan 2023 23:03:51 +0000 (23:03 +0000)
src/Factory/Api/Mastodon/Status.php
src/Module/Api/Mastodon/Bookmarks.php
src/Module/Api/Mastodon/Favourited.php
src/Module/Api/Mastodon/Search.php
src/Module/Api/Mastodon/Timelines/Home.php
src/Module/Api/Mastodon/Timelines/ListTimeline.php
src/Module/Api/Mastodon/Timelines/Tag.php
src/Module/Api/Mastodon/Trends/Statuses.php

index ad2d9bab35ef616fcf0b21be6716988d6667c5e8..acc7afeb5e2e3329c373e52590a3a7e917ebbb55 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\BaseFactory;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Item as ContentItem;
 use Friendica\Content\Text\BBCode;
+use Friendica\Core\Logger;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
@@ -249,13 +250,23 @@ class Status extends BaseFactory
                }
 
                if ($is_reshare) {
-                       $reshare = $this->createFromUriId($uriId, $uid, $display_quote, false, false)->toArray();
+                       try {
+                               $reshare = $this->createFromUriId($uriId, $uid, $display_quote, false, false)->toArray();
+                       } catch (\Throwable $th) {
+                               Logger::info('Reshare not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                               $reshare = [];
+                       }
                } else {
                        $reshare = [];
                }
 
                if ($in_reply_status && ($item['gravity'] == Item::GRAVITY_COMMENT)) {
-                       $in_reply = $this->createFromUriId($item['thr-parent-id'], $uid, $display_quote, false, false)->toArray();
+                       try {
+                               $in_reply = $this->createFromUriId($item['thr-parent-id'], $uid, $display_quote, false, false)->toArray();
+                       } catch (\Throwable $th) {
+                               Logger::info('Reply post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                               $in_reply = [];
+                       }
                } else {
                        $in_reply = [];
                }
@@ -283,7 +294,12 @@ class Status extends BaseFactory
                }
 
                if (!empty($quote_id)) {
-                       $quote = $this->createFromUriId($quote_id, $uid, false, false, false)->toArray();
+                       try {
+                               $quote = $this->createFromUriId($quote_id, $uid, false, false, false)->toArray();
+                       } catch (\Throwable $th) {
+                               Logger::info('Quote not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                               $quote = [];
+                       }
                } else {
                        $quote = [];
                }
index 411e8b1d06da927a15ce9da278dbf09eb383bd4b..615bfc501f5031d4d51209474e268ede80bad9e2 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon;
 
+use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -74,7 +75,11 @@ class Bookmarks extends BaseApi
                $statuses = [];
                while ($item = Post::fetch($items)) {
                        self::setBoundaries($item['uri-id']);
-                       $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       try {
+                               $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       } catch (\Throwable $th) {
+                               Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                       }
                }
                DBA::close($items);
 
index dfbaa0ded55db6c0b375e2f9795dc427b1999ca9..93c9ef243658c831f7c2054cd7a48945dc00e12d 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon;
 
+use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -76,7 +77,11 @@ class Favourited extends BaseApi
                $statuses = [];
                while ($item = Post::fetch($items)) {
                        self::setBoundaries($item['thr-parent-id']);
-                       $statuses[] = DI::mstdnStatus()->createFromUriId($item['thr-parent-id'], $uid, $display_quotes);
+                       try {
+                               $statuses[] = DI::mstdnStatus()->createFromUriId($item['thr-parent-id'], $uid, $display_quotes);
+                       } catch (\Throwable $th) {
+                               Logger::info('Post not fetchable', ['uri-id' => $item['thr-parent-id'], 'uid' => $uid, 'error' => $th]);
+                       }
                }
                DBA::close($items);
 
index a991052c7fc5041b5fad91c2f64bb3a500781fde..07d1daa19e57931af26fd93052e2ae8457a574e1 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon;
 
+use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
@@ -181,7 +182,11 @@ class Search extends BaseApi
                $statuses = [];
                while ($item = Post::fetch($items)) {
                        self::setBoundaries($item['uri-id']);
-                       $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       try {
+                               $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       } catch (\Throwable $th) {
+                               Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                       }
                }
                DBA::close($items);
 
index a72957b9d8d4c5e7c1e8a0cbbcb01988393e143d..5efaf4930ebbe380c26c38e857917b152f0f4040 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon\Timelines;
 
+use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -96,7 +97,11 @@ class Home extends BaseApi
                $statuses = [];
                while ($item = Post::fetch($items)) {
                        self::setBoundaries($item['uri-id']);
-                       $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       try {
+                               $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       } catch (\Throwable $th) {
+                               Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                       }
                }
                DBA::close($items);
 
index 83ab204e7b83654ea52a989afc414e37be2fc770..a8de13056ec45fb0b1367c31813453f8c63b6bf3 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon\Timelines;
 
+use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -101,7 +102,11 @@ class ListTimeline extends BaseApi
                $statuses = [];
                while ($item = Post::fetch($items)) {
                        self::setBoundaries($item['uri-id']);
-                       $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       try {
+                               $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       } catch (\Throwable $th) {
+                               Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                       }
                }
                DBA::close($items);
 
index c5a06e28c23593eeb8272433e881fbf4b235564e..1d04dec6255170979e7a82bf0b1ada3e02bcf432 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon\Timelines;
 
+use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
@@ -110,7 +111,11 @@ class Tag extends BaseApi
                $statuses = [];
                while ($item = Post::fetch($items)) {
                        self::setBoundaries($item['uri-id']);
-                       $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       try {
+                               $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid, $display_quotes);
+                       } catch (\Throwable $th) {
+                               Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]);
+                       }
                }
                DBA::close($items);
 
index 7fad480cb05e644074aed4772c97d78bd1bf95c3..cf287e59c3307d6909196be60b5711a797b5dfe3 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Api\Mastodon\Trends;
 
+use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
@@ -53,7 +54,11 @@ class Statuses extends BaseApi
                $trending = [];
                $statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => $request['limit'], 'order' => ['total-actors' => true]]);
                while ($status = Post::fetch($statuses)) {
-                       $trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
+                       try {
+                               $trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
+                       } catch (\Throwable $th) {
+                               Logger::info('Post not fetchable', ['uri-id' => $status['uri-id'], 'uid' => $uid, 'error' => $th]);
+                       }
                }
                DBA::close($statuses);