Merge pull request #11709 from Quix0r/fixes/type-error-null-uri-id

Avoid TypeError because of missing "uri-id" entry
This commit is contained in:
Philipp
2022-07-05 19:38:18 +02:00
committed by GitHub

View File

@@ -60,9 +60,14 @@ class Account extends BaseFactory
public function createFromContactId(int $contactId, int $uid = 0): \Friendica\Object\Api\Mastodon\Account public function createFromContactId(int $contactId, int $uid = 0): \Friendica\Object\Api\Mastodon\Account
{ {
$contact = Contact::getById($contactId, ['uri-id']); $contact = Contact::getById($contactId, ['uri-id']);
if (empty($contact)) { if (empty($contact)) {
throw new HTTPException\NotFoundException('Contact ' . $contactId . ' not found'); throw new HTTPException\NotFoundException('Contact ' . $contactId . ' not found');
} }
if (empty($contact['uri-id'])) {
throw new HTTPException\NotFoundException('Contact ' . $contactId . ' has no uri-id set');
}
return self::createFromUriId($contact['uri-id'], $uid); return self::createFromUriId($contact['uri-id'], $uid);
} }