Merge pull request #12460 from annando/photo-api

API: Fix interoperability between Friendica and Mastodon part
This commit is contained in:
Tobias Diekershoff 2022-12-18 08:15:49 +01:00 committed by GitHub
commit b3504dfdee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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