Merge remote-tracking branch 'upstream/develop' into diaspora-reshare

This commit is contained in:
Michael 2022-12-20 06:58:36 +00:00
commit 4db4d1843d
52 changed files with 5745 additions and 5298 deletions

View file

@ -74,12 +74,13 @@ class Photo extends BaseFactory
if (empty($photos)) {
throw new HTTPException\NotFoundException();
}
$data = $photos[0];
$data['id'] = $data['resource-id'];
$data = $photos[0];
$data['media-id'] = $data['id'];
$data['id'] = $data['resource-id'];
if (is_int($scale)) {
$data['data'] = base64_encode(ModelPhoto::getImageDataForPhoto($data));
} else {
unset($data['datasize']); //needed only with scale param
}
if ($type == 'xml') {
@ -99,12 +100,21 @@ class Photo extends BaseFactory
} else {
$data['link'][$id] = $link;
}
if (is_null($scale)) {
$data['scales'][] = [
'id' => $photo['id'],
'scale' => $photo['scale'],
'link' => $link,
'width' => $photo['width'],
'height' => $photo['height'],
'size' => $photo['datasize'],
];
}
}
unset($data['backend-class']);
unset($data['backend-ref']);
unset($data['resource-id']);
unset($data['scale']);
if ($with_posts) {
// retrieve item element for getting activities (like, dislike etc.) related to photo

View file

@ -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);
}
}