mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-11 17:44:27 +02:00
Use account-user-view entry to instantiate Api\Mastodon\FollowRequest objects
- Address https://github.com/friendica/friendica/issues/11993#issuecomment-1354395861
This commit is contained in:
parent
af4164b86a
commit
c7e53cb9b4
3 changed files with 8 additions and 15 deletions
|
@ -24,6 +24,7 @@ namespace Friendica\Factory\Api\Mastodon;
|
|||
use Friendica\App\BaseURL;
|
||||
use Friendica\BaseFactory;
|
||||
use Friendica\Contact\Introduction\Entity\Introduction;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\APContact;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -49,18 +50,12 @@ class FollowRequest extends BaseFactory
|
|||
*/
|
||||
public function createFromIntroduction(Introduction $introduction): \Friendica\Object\Api\Mastodon\FollowRequest
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContactID($introduction->cid, $introduction->uid);
|
||||
|
||||
if (empty($cdata)) {
|
||||
$account = DBA::selectFirst('account-user-view', [], ['id' => $introduction->cid, 'uid' => [0, $introduction->uid]]);
|
||||
if (empty($account)) {
|
||||
$this->logger->warning('Wrong introduction data', ['Introduction' => $introduction]);
|
||||
throw new HTTPException\InternalServerErrorException('Wrong introduction data');
|
||||
}
|
||||
|
||||
$publicContact = Contact::getById($cdata['public']);
|
||||
$userContact = Contact::getById($cdata['user']);
|
||||
|
||||
$apContact = APContact::getByURL($publicContact['url'], false);
|
||||
|
||||
return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $publicContact, $apContact, $userContact);
|
||||
return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $account);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue