From 8f56aa316b9e156c1d8f6073fbe0330a98acb701 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 12:48:50 -0500 Subject: [PATCH 01/16] Allow album to be empty string thus defaulting to i10n "Wall Photos" like in UI --- src/Module/Api/Friendica/Photo/Create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/Api/Friendica/Photo/Create.php b/src/Module/Api/Friendica/Photo/Create.php index bb3dc63b2..868296342 100644 --- a/src/Module/Api/Friendica/Photo/Create.php +++ b/src/Module/Api/Friendica/Photo/Create.php @@ -64,8 +64,8 @@ class Create extends BaseApi // do several checks on input parameters // we do not allow calls without album string - if ($album == null) { - throw new HTTPException\BadRequestException('no albumname specified'); + if ($album === null) { + throw new HTTPException\BadRequestException('no album name specified'); } // error if no media posted in create-mode From 800f94495b99feb91b053ef581f54128927092da Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:27:23 -0500 Subject: [PATCH 02/16] Add Photo album cache flushes to Friendica Photo endpoints --- src/Module/Api/Friendica/Photo/Create.php | 1 + src/Module/Api/Friendica/Photo/Delete.php | 2 +- src/Module/Api/Friendica/Photo/Update.php | 1 + src/Module/Api/Friendica/Photoalbum/Delete.php | 1 + src/Module/Api/Friendica/Photoalbum/Update.php | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photo/Create.php b/src/Module/Api/Friendica/Photo/Create.php index 868296342..1f60998b7 100644 --- a/src/Module/Api/Friendica/Photo/Create.php +++ b/src/Module/Api/Friendica/Photo/Create.php @@ -88,6 +88,7 @@ class Create extends BaseApi // return success of updating or error message if (!empty($photo)) { + Photo::clearAlbumCache($uid); $data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)]; $this->response->exit('photo_create', $data, $this->parameters['extension'] ?? null); } else { diff --git a/src/Module/Api/Friendica/Photo/Delete.php b/src/Module/Api/Friendica/Photo/Delete.php index e8dabe3a1..64cc2e03a 100644 --- a/src/Module/Api/Friendica/Photo/Delete.php +++ b/src/Module/Api/Friendica/Photo/Delete.php @@ -60,7 +60,7 @@ class Delete extends BaseApi // to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion) $condition = ['uid' => $uid, 'resource-id' => $request['photo_id'], 'post-type' => Item::PT_IMAGE, 'origin' => true]; Item::deleteForUser($condition, $uid); - + Photo::clearAlbumCache($uid); $result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.']; $this->response->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null); } else { diff --git a/src/Module/Api/Friendica/Photo/Update.php b/src/Module/Api/Friendica/Photo/Update.php index 44fd554b0..83ceb7a5c 100644 --- a/src/Module/Api/Friendica/Photo/Update.php +++ b/src/Module/Api/Friendica/Photo/Update.php @@ -135,6 +135,7 @@ class Update extends BaseApi // return success of updating or error message if ($result) { + Photo::clearAlbumCache($uid); $answer = ['result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.']; $this->response->exit('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null); return; diff --git a/src/Module/Api/Friendica/Photoalbum/Delete.php b/src/Module/Api/Friendica/Photoalbum/Delete.php index 4215ddda7..76062b2fd 100644 --- a/src/Module/Api/Friendica/Photoalbum/Delete.php +++ b/src/Module/Api/Friendica/Photoalbum/Delete.php @@ -66,6 +66,7 @@ class Delete extends BaseApi // return success of deletion or error message if ($result) { + Photo::clearAlbumCache($uid); $answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.']; $this->response->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { diff --git a/src/Module/Api/Friendica/Photoalbum/Update.php b/src/Module/Api/Friendica/Photoalbum/Update.php index 0eca5b22e..3fa01fe1b 100644 --- a/src/Module/Api/Friendica/Photoalbum/Update.php +++ b/src/Module/Api/Friendica/Photoalbum/Update.php @@ -58,6 +58,7 @@ class Update extends BaseApi // return success of updating or error message if ($result) { + Photo::clearAlbumCache($uid); $answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.']; $this->response->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { From e1823c7138e74815aea4b181ce0fab583bc64108 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:28:34 -0500 Subject: [PATCH 03/16] Add Photo Album index endpoint to Friendica API --- src/Module/Api/Friendica/Photoalbum/Index.php | 53 +++++++++++++++++++ static/routes.config.php | 1 + 2 files changed, 54 insertions(+) create mode 100644 src/Module/Api/Friendica/Photoalbum/Index.php diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php new file mode 100644 index 000000000..84c5f2d60 --- /dev/null +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -0,0 +1,53 @@ +. +* +*/ + +namespace Friendica\Module\Api\Friendica\Photoalbum; + +use Friendica\Database\DBA; +use Friendica\Model\Photo; +use Friendica\Module\BaseApi; + +/** + * api/friendica/photoalbum + * + * @package Friendica\Module\Api\Friendica\Photoalbum + */ +class Index extends BaseApi +{ + protected function rawContent(array $request = []) + { + self::checkAllowedScope(self::SCOPE_READ); + $uid = self::getCurrentUserID(); + + $albums = Photo::getAlbums($uid); + + $items = []; + foreach ($albums as $album) { + $items[] = [ + 'name' => $album['album'], + 'created' => $album['created'], + 'count' => $album['total'], + ]; + } + + $this->response->exit('albums', ['albums' => $items], $this->parameters['extension'] ?? null); + } +} diff --git a/static/routes.config.php b/static/routes.config.php index e3c87f150..dc1f97b68 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -93,6 +93,7 @@ $apiRoutes = [ '/group_delete[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Group\Delete::class, [ R::POST]], '/group_update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Group\Update::class, [ R::POST]], '/profile/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Profile\Show::class, [R::GET ]], + '/photoalbums[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Index::class, [R::GET ]], '/photoalbum/delete[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Delete::class, [ R::POST]], '/photoalbum/update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Update::class, [ R::POST]], '/photos/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photo\Lists::class, [R::GET ]], From 951b221e214a0b3472a3d5f53d9597b01057c036 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:31:10 -0500 Subject: [PATCH 04/16] Fix Friendica API Photo Album list documentation to reflect endpoint --- src/Module/Api/Friendica/Photoalbum/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 84c5f2d60..b7038c6dc 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -26,7 +26,7 @@ use Friendica\Model\Photo; use Friendica\Module\BaseApi; /** - * api/friendica/photoalbum + * api/friendica/photoalbums * * @package Friendica\Module\Api\Friendica\Photoalbum */ From 5b52533749dfca10fe8fc1a35b52e0fbf53036fb Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 14:14:58 -0500 Subject: [PATCH 05/16] Fix Friendica API Photo Album list documentation to reflect endpoint --- src/Module/Api/Friendica/Photoalbum/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index b7038c6dc..84c5f2d60 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -26,7 +26,7 @@ use Friendica\Model\Photo; use Friendica\Module\BaseApi; /** - * api/friendica/photoalbums + * api/friendica/photoalbum * * @package Friendica\Module\Api\Friendica\Photoalbum */ From 4fc01c93ce0f3dfd61c00422e399a4cab50f3fcf Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 14:16:08 -0500 Subject: [PATCH 06/16] Add photo album show endpoint that lists photos in an album --- src/Module/Api/Friendica/Photoalbum/Show.php | 111 +++++++++++++++++++ static/routes.config.php | 1 + 2 files changed, 112 insertions(+) create mode 100644 src/Module/Api/Friendica/Photoalbum/Show.php diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php new file mode 100644 index 000000000..20c5c4a6f --- /dev/null +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -0,0 +1,111 @@ +. + * + */ + +namespace Friendica\Module\Api\Friendica\Photoalbum; + +use Friendica\App; +use Friendica\Core\L10n; +use Friendica\Database\DBA; +use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto; +use Friendica\Model\Contact; +use Friendica\Model\Photo; +use Friendica\Module\Api\ApiResponse; +use Friendica\Module\BaseApi; +use Friendica\Network\HTTPException; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; + +/** + * api/friendica/photoalbum/:name + * + * @package Friendica\Module\Api\Friendica\Photoalbum + */ +class Show extends BaseApi +{ + /** @var FriendicaPhoto */ + private $friendicaPhoto; + + + public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + { + parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->friendicaPhoto = $friendicaPhoto; + } + + protected function rawContent(array $request = []) + { + BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $uid = BaseApi::getCurrentUserID(); + $type = $this->getRequestValue($this->parameters, 'extension', 'json'); + $request = $this->getRequest([ + 'album' => '', // Get pictures in this album + 'offset' => 0, // Return results offset by this value + 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 + ], $request); + if (empty($request['album'])) { + throw new HTTPException\BadRequestException('No album name specified.'); + } + + + $album = $request['album']; + $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; + $params = ['order' => ['id'], 'group_by' => ['resource-id']]; + + //'limit' => [$request['offset'], $request['limit']] + $limit = $request['limit']; + if ($limit > 500) { + $limit = 500; + } + + if ($limit <= 0) { + $limit = 1; + } + + if(!empty($request['offset'])) { + $params['limit'] = [$request['offset'], $limit]; + } else { + $params['limit'] = $limit; + } + + $photos = Photo::selectToArray(['resource-id'], $condition, $params); + + $data = ['photo' => []]; + if (DBA::isResult($photos)) { + foreach ($photos as $photo) { + $element = $this->friendicaPhoto->createFromId($photo['resource-id'], null, $uid, 'json', false); + + $element['thumb'] = end($element['link']); + unset($element['link']); + + if ($type == 'xml') { + $thumb = $element['thumb']; + unset($element['thumb']); + $data['photo'][] = ['@attributes' => $element, '1' => $thumb]; + } else { + $data['photo'][] = $element; + } + } + } + + $this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid)); + } +} diff --git a/static/routes.config.php b/static/routes.config.php index dc1f97b68..e84dde9b9 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -94,6 +94,7 @@ $apiRoutes = [ '/group_update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Group\Update::class, [ R::POST]], '/profile/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Profile\Show::class, [R::GET ]], '/photoalbums[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Index::class, [R::GET ]], + '/photoalbum[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Show::class, [R::GET ]], '/photoalbum/delete[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Delete::class, [ R::POST]], '/photoalbum/update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Update::class, [ R::POST]], '/photos/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photo\Lists::class, [R::GET ]], From 991c5fa6de529df26fb91365158472a748f04d85 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 15:41:24 -0500 Subject: [PATCH 07/16] Add latest_first parameter to photo gallery listing Friendica API endpoint --- src/Module/Api/Friendica/Photoalbum/Show.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 20c5c4a6f..da16cbedc 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -60,15 +60,17 @@ class Show extends BaseApi 'album' => '', // Get pictures in this album 'offset' => 0, // Return results offset by this value 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 + 'latest_first' => false, // Whether to reverse the order so newest are first ], $request); if (empty($request['album'])) { throw new HTTPException\BadRequestException('No album name specified.'); } + $orderDescending = $request['latest_first']; $album = $request['album']; $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; - $params = ['order' => ['id'], 'group_by' => ['resource-id']]; + $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; //'limit' => [$request['offset'], $request['limit']] $limit = $request['limit']; From 8576610c54b8db9d96ed6279141e8f4177424769 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 15:58:03 -0500 Subject: [PATCH 08/16] Fix copyright header issues... --- src/Module/Api/Friendica/Photoalbum/Index.php | 36 +++++++++---------- src/Module/Api/Friendica/Photoalbum/Show.php | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 84c5f2d60..0666fd2b1 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -1,23 +1,23 @@ . -* -*/ + * @copyright Copyright (C) 2010-2022, the Friendica project + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ namespace Friendica\Module\Api\Friendica\Photoalbum; diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index da16cbedc..34bffcb24 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -1,6 +1,6 @@ Date: Tue, 13 Dec 2022 15:59:45 -0500 Subject: [PATCH 09/16] Fix space missing after if style error in src/Module/Api/Friendica/Photoalbum/Show.php --- src/Module/Api/Friendica/Photoalbum/Show.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 34bffcb24..c1a795950 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -82,7 +82,7 @@ class Show extends BaseApi $limit = 1; } - if(!empty($request['offset'])) { + if (!empty($request['offset'])) { $params['limit'] = [$request['offset'], $limit]; } else { $params['limit'] = $limit; From 5288ed46d4c2809349060608a87642518fad280d Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 16:04:03 -0500 Subject: [PATCH 10/16] Remove extraneous comment and fix whitespace between lines for style --- src/Module/Api/Friendica/Photoalbum/Show.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index c1a795950..ac9573da3 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -62,17 +62,16 @@ class Show extends BaseApi 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 'latest_first' => false, // Whether to reverse the order so newest are first ], $request); + if (empty($request['album'])) { throw new HTTPException\BadRequestException('No album name specified.'); } - $orderDescending = $request['latest_first']; $album = $request['album']; $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; - //'limit' => [$request['offset'], $request['limit']] $limit = $request['limit']; if ($limit > 500) { $limit = 500; From d74345782aa315c2a668109e47dd529d35d1e24b Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:45:34 -0500 Subject: [PATCH 11/16] Update src/Module/Api/Friendica/Photoalbum/Index.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 0666fd2b1..46778bc45 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -42,9 +42,9 @@ class Index extends BaseApi $items = []; foreach ($albums as $album) { $items[] = [ - 'name' => $album['album'], - 'created' => $album['created'], - 'count' => $album['total'], + 'name' => $album['album'], + 'created' => $album['created'], + 'count' => $album['total'], ]; } From 7bb60776c6e91722e396eabd6a42bad2c84dc6cf Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:45:49 -0500 Subject: [PATCH 12/16] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index ac9573da3..e47ef51da 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -54,13 +54,13 @@ class Show extends BaseApi protected function rawContent(array $request = []) { BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); - $uid = BaseApi::getCurrentUserID(); - $type = $this->getRequestValue($this->parameters, 'extension', 'json'); + $uid = BaseApi::getCurrentUserID(); + $type = $this->getRequestValue($this->parameters, 'extension', 'json'); $request = $this->getRequest([ - 'album' => '', // Get pictures in this album - 'offset' => 0, // Return results offset by this value - 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 - 'latest_first' => false, // Whether to reverse the order so newest are first + 'album' => '', // Get pictures in this album + 'offset' => 0, // Return results offset by this value + 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 + 'latest_first' => false, // Whether to reverse the order so newest are first ], $request); if (empty($request['album'])) { From ae8f1a1c5b21ae80501f7a903d197f3f78174659 Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:45:56 -0500 Subject: [PATCH 13/16] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index e47ef51da..485b3e91e 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -68,9 +68,9 @@ class Show extends BaseApi } $orderDescending = $request['latest_first']; - $album = $request['album']; - $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; - $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; + $album = $request['album']; + $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; + $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; $limit = $request['limit']; if ($limit > 500) { From 6af4bfae21f00b11a5ae8a91b6a5c6990f84f7b4 Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:46:16 -0500 Subject: [PATCH 14/16] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 22 +++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 485b3e91e..14f561a99 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -90,20 +90,18 @@ class Show extends BaseApi $photos = Photo::selectToArray(['resource-id'], $condition, $params); $data = ['photo' => []]; - if (DBA::isResult($photos)) { - foreach ($photos as $photo) { - $element = $this->friendicaPhoto->createFromId($photo['resource-id'], null, $uid, 'json', false); + foreach ($photos as $photo) { + $element = $this->friendicaPhoto->createFromId($photo['resource-id'], null, $uid, 'json', false); - $element['thumb'] = end($element['link']); - unset($element['link']); + $element['thumb'] = end($element['link']); + unset($element['link']); - if ($type == 'xml') { - $thumb = $element['thumb']; - unset($element['thumb']); - $data['photo'][] = ['@attributes' => $element, '1' => $thumb]; - } else { - $data['photo'][] = $element; - } + if ($type == 'xml') { + $thumb = $element['thumb']; + unset($element['thumb']); + $data['photo'][] = ['@attributes' => $element, '1' => $thumb]; + } else { + $data['photo'][] = $element; } } From 2338a268d33397ed9423276292878e7438a03766 Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:52:21 -0500 Subject: [PATCH 15/16] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 14f561a99..1a50416ec 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -23,7 +23,6 @@ namespace Friendica\Module\Api\Friendica\Photoalbum; use Friendica\App; use Friendica\Core\L10n; -use Friendica\Database\DBA; use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto; use Friendica\Model\Contact; use Friendica\Model\Photo; From 7072a7178896c567caf5003e94a8f8045221bd8f Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:52:28 -0500 Subject: [PATCH 16/16] Update src/Module/Api/Friendica/Photoalbum/Index.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 46778bc45..83fbb5d3d 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -21,7 +21,6 @@ namespace Friendica\Module\Api\Friendica\Photoalbum; -use Friendica\Database\DBA; use Friendica\Model\Photo; use Friendica\Module\BaseApi;