Merge pull request #11037 from MrPetovan/bug/11023-api-photo-delete

Fix Api\Friendica\Photo|album\Delete endpoints
This commit is contained in:
Hypolite Petovan 2021-11-29 08:44:33 -05:00 committed by GitHub
commit 2ba3b7f771
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 103 additions and 10 deletions

View file

@ -21,7 +21,6 @@
namespace Friendica\Module\Api\Friendica\Photo;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Module\BaseApi;
@ -35,11 +34,10 @@ class Delete extends BaseApi
{
protected function rawContent(array $request = [])
{
self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID();
$request = self::getRequest([
'photo_id' => null, // Photo id
'photo_id' => '', // Photo id
], $request);
// do several checks on input parameters
@ -60,7 +58,7 @@ class Delete extends BaseApi
if ($result) {
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
// 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'], 'type' => 'photo'];
$condition = ['uid' => $uid, 'resource-id' => $request['photo_id'], 'post-type' => Item::PT_IMAGE, 'origin' => true];
Item::deleteForUser($condition, $uid);
$result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.'];

View file

@ -58,7 +58,7 @@ class Delete extends BaseApi
// function for setting the items to "deleted = 1" which ensures that comments, likes etc. are not shown anymore
// to the user and the contacts of the users (drop_items() performs the federation of the deletion to other networks
$condition = ['uid' => $uid, 'resource-id' => $resourceIds, 'type' => 'photo'];
$condition = ['uid' => $uid, 'resource-id' => $resourceIds, 'post-type' => Item::PT_IMAGE, 'origin' => true];
Item::deleteForUser($condition, $uid);
// now let's delete all photos from the album