From e1823c7138e74815aea4b181ce0fab583bc64108 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:28:34 -0500 Subject: [PATCH] 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 0000000000..84c5f2d604 --- /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 e3c87f1502..dc1f97b687 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 ]], -- 2.39.5