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
commit 7b55f93027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,9 +60,14 @@ class Account extends BaseFactory
public function createFromContactId(int $contactId, int $uid = 0): \Friendica\Object\Api\Mastodon\Account
{
$contact = Contact::getById($contactId, ['uri-id']);
if (empty($contact)) {
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);
}