From 1d00947bcde4b75cec21c9bf813ef8f109bafc1b Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 1 Dec 2022 07:07:59 +0000 Subject: [PATCH] Don't fetch sugestions for the system user / catch error on contact timeline --- src/Model/Contact/Relation.php | 4 ++++ src/Module/Api/Mastodon/Accounts/Statuses.php | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Model/Contact/Relation.php b/src/Model/Contact/Relation.php index bae59f48c..5616148fa 100644 --- a/src/Model/Contact/Relation.php +++ b/src/Model/Contact/Relation.php @@ -323,6 +323,10 @@ class Relation */ static public function getSuggestions(int $uid, int $start = 0, int $limit = 80): array { + if ($uid == 0) { + return []; + } + $cid = Contact::getPublicIdByUserId($uid); $totallimit = $start + $limit; $contacts = []; diff --git a/src/Module/Api/Mastodon/Accounts/Statuses.php b/src/Module/Api/Mastodon/Accounts/Statuses.php index b244c56fb..7de869940 100644 --- a/src/Module/Api/Mastodon/Accounts/Statuses.php +++ b/src/Module/Api/Mastodon/Accounts/Statuses.php @@ -21,6 +21,7 @@ namespace Friendica\Module\Api\Mastodon\Accounts; +use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; use Friendica\Database\DBA; @@ -113,7 +114,11 @@ class Statuses extends BaseApi $statuses = []; while ($item = Post::fetch($items)) { self::setBoundaries($item['uri-id']); - $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid); + try { + $statuses[] = DI::mstdnStatus()->createFromUriId($item['uri-id'], $uid); + } catch (\Throwable $th) { + Logger::info('Post not fetchable', ['uri-id' => $item['uri-id'], 'uid' => $uid, 'error' => $th]); + } } DBA::close($items);