plegall / Piwigo-community

11 stars 23 forks source link

API method for submitting, rejecting, removing and validating images ? #25

Open EddyLB opened 7 years ago

EddyLB commented 7 years ago

Would it be possible to provide methods for submitting, rejecting, removing and validating images uploaded by Community users as for Piwigo demo?

plegall commented 7 years ago

I can add, for admins only:

We already have pwg.images.delete.

Would that be fine?

EddyLB commented 7 years ago

Mostly yes, but I also need to know whether a freshly uploaded image will have to be validated:

Today, the iOS app assumes that the freshly uploaded image is immediately available and it therefore refreshes the album content. How can the iOS app know that it won't be possible ?

So I suggest that you also add a community.images.submit or community.images.upload command returning that information and sending an email to the Admin (raised in #24)?

plegall commented 7 years ago

Yes, I clearly have this problem with the new HTML5 upload form in Community: on frontend side, after pwg.images.upload, I have no idea if the image is waiting for moderation. What I'm implementing is a new method community.images.uploadCompleted : you give the list of image_ids and Community does 2 things:

  1. notify the admins some photos have been uploaded
  2. returns the list of photos waiting for moderation
EddyLB commented 7 years ago

If I understand well, when a non-admin user uploads images, the iOS app will have to do the following to determine if it should refresh the content of the alum:

  1. get the list of image_ids with pwg.categories.getImages to identify those already on the server,
  2. upload images with pwg.images.upload,
  3. get a second list of image_ids with pwg.categories.getImages and build the list of freshly uploaded image_ids by comparing the two lists,
  4. usecommunity.images.uploadCompleted to determine if the freshly updated images are waiting for moderation,
  5. and finally refresh the content of the album if needed.

A bit heavy, no ? Unless I misunderstood…

plegall commented 7 years ago
  1. get the list of image_ids with pwg.categories.getImages to identify those already on the server,

You should already have done it earlier, no? Or you could have a local list of photos already uploaded to this Piwigo.

2 + 3 + 4

no, this is how Community web form does the job:

a. perform the pwg.images.upload and save the returned image_id b. once all files are uploaded, perform the community.images.uploadCompleted

Here is the javascript version (simplified):

jQuery("#uploader").pluploadQueue({
  url : 'ws.php?method=pwg.images.upload&format=json',
  ...
  FileUploaded: function(up, file, info) {
    var data = jQuery.parseJSON(info.response);
    uploadedPhotos.push(parseInt(data.result.image_id));
  },
  UploadComplete: function(up, files) {
    jQuery.ajax({
      url: "ws.php?format=json&method=community.images.uploadCompleted",
      data: {
        pwg_token: pwg_token,
        image_id: uploadedPhotos.join(","),
        category_id: uploadCategory.id
      },
      ...
    });
  }
}
  1. and finally refresh the content of the album if needed.

Yes, unless community.images.uploadCompleted tells you all photos are moderation_pending

EddyLB commented 7 years ago

Thank for the detailed answer. As I did not work much on that part of the code, I did not know that pwg.images.upload did return image_ids. That looks fine.

EddyLB commented 6 years ago

@plegall, I now have a beta version 2.1 of Piwigo for iOS compatible with the Community extension. Do you have an idea when you will be able to provide the admin methods ?

I ask the question to determine whether I should wait for releasing version 2.1.