Add Photo album cache flushes to Friendica Photo endpoints

This commit is contained in:
Hank Grabowski 2022-12-13 13:27:23 -05:00
parent 8f56aa316b
commit 800f94495b
5 changed files with 5 additions and 1 deletions

View file

@ -88,6 +88,7 @@ class Create extends BaseApi
// return success of updating or error message // return success of updating or error message
if (!empty($photo)) { if (!empty($photo)) {
Photo::clearAlbumCache($uid);
$data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)]; $data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)];
$this->response->exit('photo_create', $data, $this->parameters['extension'] ?? null); $this->response->exit('photo_create', $data, $this->parameters['extension'] ?? null);
} else { } else {

View file

@ -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) // 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]; $condition = ['uid' => $uid, 'resource-id' => $request['photo_id'], 'post-type' => Item::PT_IMAGE, 'origin' => true];
Item::deleteForUser($condition, $uid); Item::deleteForUser($condition, $uid);
Photo::clearAlbumCache($uid);
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.']; $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); $this->response->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null);
} else { } else {

View file

@ -135,6 +135,7 @@ class Update extends BaseApi
// return success of updating or error message // return success of updating or error message
if ($result) { if ($result) {
Photo::clearAlbumCache($uid);
$answer = ['result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.']; $answer = ['result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.'];
$this->response->exit('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null); $this->response->exit('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
return; return;

View file

@ -66,6 +66,7 @@ class Delete extends BaseApi
// return success of deletion or error message // return success of deletion or error message
if ($result) { if ($result) {
Photo::clearAlbumCache($uid);
$answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.']; $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); $this->response->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null);
} else { } else {

View file

@ -58,6 +58,7 @@ class Update extends BaseApi
// return success of updating or error message // return success of updating or error message
if ($result) { if ($result) {
Photo::clearAlbumCache($uid);
$answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.']; $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); $this->response->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null);
} else { } else {