Skip to content

Add deletion of Imgur uploads #417

Description

@tipa

Bug Report

Current Behavior
When using the Imgur image upload, those files cannot be deleted any more
Currently, this is not implemented:

/**
* In case deletion is not possible, return false.
*
* @param File $file
*
* @return File|bool
*/
public function delete(File $file)
{
// TODO: Implement delete() method.
return false;
}

The Imgur deletion API for anonymous image uploads (as used in this plugin) requires the deleteHash, which is returned upon image upload

At the moment, the plugin does not store this value:

// successful upload, let's get the generated URL
if ($response->getStatusCode() == 200) {
$meta = Arr::get(json_decode($response->getBody(), true), 'data', []);
$link = Arr::get($meta, 'link');
$file->url = $link;
$file->remote_id = Arr::get($meta, 'id');
}

Expected Behavior
Users (or at least admins) can delete images that have been uploaded using the Imgur integration

Environment

  • Flarum version: 1.8.8
  • Extension version: 1.5.5

Possible solution(s)
I don't know the internals of this plugin, but maybe the deleteHash could be stored in the remote_id instead of the id (unless the remote_id is used for some other purpose):

$file->remote_id = Arr::get($meta, 'id');

Additional Context
Related issue: #290

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugkeepIssues that should not be closed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions