<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
*/
class Update extends BaseApi
{
- public static function rawContent(array $parameters = [])
+ protected function post(array $request = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
- $request = self::getRequest([
+ $request = $this->getRequest([
'album' => '', // Current album name
'album_new' => '', // New album name
- ]);
+ ], $request);
// we do not allow calls without album string
- if ($request['album'] == "") {
+ if (empty($request['album'])) {
throw new BadRequestException("no albumname specified");
}
- if ($request['album_new'] == "") {
+ if (empty($request['album_new'])) {
throw new BadRequestException("no new albumname specified");
}
// check if album is existing
// 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'] . '`.'];
- DI::apiResponse()->exit('photoalbum_update', ['$result' => $answer], $parameters['extension'] ?? null);
+ $this->response->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
} else {
throw new InternalServerErrorException("unknown error - updating in database failed");
}