From 800f94495b99feb91b053ef581f54128927092da Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:27:23 -0500 Subject: [PATCH] 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 {