Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility iOS app, avoid faking pwg.categories.getList #23

Closed
plegall opened this issue May 26, 2017 · 13 comments
Closed

compatibility iOS app, avoid faking pwg.categories.getList #23

plegall opened this issue May 26, 2017 · 13 comments
Assignees
Milestone

Comments

@plegall
Copy link
Owner

plegall commented May 26, 2017

As described on Piwigo/Piwigo-Mobile#117 Community should be able to avoid faking pwg.categories.getList to return the real list of "reachable" albums.

@plegall plegall self-assigned this May 26, 2017
plegall added a commit that referenced this issue May 29, 2017
to know what is the real user status (not the faked one) and the method to call
to get the uploadable categories list.
@EddyLB
Copy link

EddyLB commented May 31, 2017

@plegall, I've prepared a few albums on the demo site to understand how I should exploit this new method and modify the iOS app.

Without Community installed, the iOS app uses pwg.categories.getList to collect the list of albums accessible to the user. If this user has Admin or Webmaster rights, he can also upload images and change albums. That is the way Piwigo for iOS operates for the time being.

With Community installed (I tested as Guest, User and Admin):

  • pwg.categories.getList always returns "Method name is not valid".
  • community.categories.getList returns categories for which the user has Upload rights.
  • pwg.categories.getAdminList returns only categories to "really" Admin users.

How can I get the list of albums for which the user has no Upload rights but read rights (the option &public=true does not work) ?

Thanking you in advance for your help.

@plegall
Copy link
Owner Author

plegall commented Jun 1, 2017

@EddyLB so the problem is the "Method name is not valid" on pwg.categories.getList, because it should work and give you exactly what you need, ie the list of albums reachable to the current user.

If I go to https://piwigo.us/dev/eddy/tools/ws.htm (where Community is currently installed and activated), I can request pwg.categories.getList with no problem!

@plegall plegall reopened this Jun 1, 2017
@EddyLB
Copy link

EddyLB commented Jun 1, 2017

Sorry for bothering you @plegall, I've realised this evening that there was a typo error in the pwg.categories.getList URL :=(

So I checked again and got these results when logged as User:

  • pwg.categories.getList returns categories for which the user has Upload rights.
  • community.categories.getList returns categories for which the user has Upload rights.
  • pwg.categories.getAdminList returns only categories to "really" Admin users.

With the web interface, when I am logged as User, I see the 3 albums, which is normal because they are public. Both pwg.categories.getList and community.categories.getList methods return only one album, the one for which the user has upload rights. To my opinion, the iOS app should behave like the web interface. So how can I get the list of public albums as well ?

@plegall
Copy link
Owner Author

plegall commented Jun 2, 2017

OK @EddyLB we're near the solution :-)

When calling pwg.categories.getList, add the parameter faked_by_community=false that I introduced in bb9f033

@EddyLB
Copy link

EddyLB commented Jun 18, 2017

Thank you @plegall. The iOS app follows that route:

  1. collect the full list of albums to display with pwg.categories.getList and the option faked_by_community=false
  2. collect the list of albums for which the user has upload rights with community.categories.getList
  3. update the user rights for that albums

#23 can be closed.

@plegall
Copy link
Owner Author

plegall commented Jun 18, 2017

And does that check:

if (method "community.session.getStatus" exists)

to remain compatible with old versions of Community as well?

@EddyLB
Copy link

EddyLB commented Jul 11, 2017

Sorry for the slow answer, I travel a lot these days for my work (Belgium, Italy and now in Korea).
Yes, to be complete, the app does the following right after login:

  1. pwg.session.getStatus, check if Piwigo version >= 2.7, get available sizes
  2. reflection.getMethodList, check if community.session.getStatus is available
  3. if Community is available community.session.getStatus and get real user status
  4. if user has admin rights execute pwg.plugins.getList to determine if VideoJS is installed.

@EddyLB
Copy link

EddyLB commented Jul 29, 2017

@plegall,
The method pwg.categories.getList with options faked_by_community=false does not return empty sub-albums, preventing users from uploading images in them while that is possible with the web interface.

For example, when sending the following request while logged as user:
https://piwigo.us/dev/eddy/ws.php?format=json&method=pwg.categories.getList&faked_by_community=false

I get data for 5 albums, not 7 (sub-albums with id 6 and 7 are empty):
{"stat":"ok","result":{"categories":[{"id":4,"name":"Videos","comment":"","permalink":null,"status":"public","uppercats":"4","global_rank":"2","id_uppercat":null,"nb_images":1,"total_nb_images":1,"representative_picture_id":"107","date_last":"2017-07-02 16:05:29","max_date_last":"2017-07-02 16:05:29","nb_categories":0,"url":"https:\/\/piwigo.us\/dev\/eddy\/index.php?\/category\/4","tn_url":"https:\/\/piwigo.us\/dev\/eddy\/_data\/i\/upload\/2017\/07\/02\/20170702160529-2a0e54fa-th.jpg"},{"id":3,"name":"Admin's album","comment":"","permalink":null,"status":"public","uppercats":"3","global_rank":"3","id_uppercat":null,"nb_images":1,"total_nb_images":1,"representative_picture_id":"152","date_last":"2017-07-29 16:21:32","max_date_last":"2017-07-29 16:21:32","nb_categories":0,"url":"https:\/\/piwigo.us\/dev\/eddy\/index.php?\/category\/3","tn_url":"https:\/\/piwigo.us\/dev\/eddy\/_data\/i\/upload\/2017\/07\/29\/20170729162132-4970ce75-th.jpg"},{"id":2,"name":"User's album","comment":"","permalink":null,"status":"public","uppercats":"2","global_rank":"4","id_uppercat":null,"nb_images":6,"total_nb_images":6,"representative_picture_id":"7","date_last":"2017-07-29 08:41:02","max_date_last":"2017-07-29 08:41:02","nb_categories":0,"url":"https:\/\/piwigo.us\/dev\/eddy\/index.php?\/category\/2","tn_url":"https:\/\/piwigo.us\/dev\/eddy\/i.php?\/upload\/2017\/05\/29\/20170529231245-3ee74305-th.jpg"},{"id":1,"name":"Community","comment":"","permalink":null,"status":"public","uppercats":"1","global_rank":"5","id_uppercat":null,"nb_images":5,"total_nb_images":6,"representative_picture_id":"151","date_last":"2017-07-29 17:01:36","max_date_last":"2017-07-29 17:01:36","nb_categories":1,"url":"https:\/\/piwigo.us\/dev\/eddy\/index.php?\/category\/1","tn_url":"https:\/\/piwigo.us\/dev\/eddy\/_data\/i\/upload\/2017\/07\/29\/20170729161011-890b6c24-th.jpg"},{"id":7,"name":"Sub-album 2","comment":"","permalink":null,"status":"public","uppercats":"1,7","global_rank":"5.2","id_uppercat":"1","nb_images":1,"total_nb_images":1,"representative_picture_id":"154","date_last":"2017-07-29 17:01:36","max_date_last":"2017-07-29 17:01:36","nb_categories":0,"url":"https:\/\/piwigo.us\/dev\/eddy\/index.php?\/category\/7","tn_url":"https:\/\/piwigo.us\/dev\/eddy\/_data\/i\/upload\/2017\/07\/29\/20170729170042-e3f38664-th.jpg"}]}}

How should I proceed ? can you fix the faked_by_community=false option ?

@plegall
Copy link
Owner Author

plegall commented Aug 22, 2017

The method pwg.categories.getList with options faked_by_community=false does
not return empty sub-albums, preventing users from uploading images

That is "on purpose". This is not related to Community.

I suppose the Community user can see the empty albums in the "Upload" bottom menu (so we can't say the user has no possibility to upload photos in empty albums).

Only true admin can see empty albums. I agree it would be better that Community users can see empty albums where they have upload permission. I have to think about how to do that. Not super easy to implement (to say the least).

@EddyLB
Copy link

EddyLB commented Sep 3, 2017

When Community 2.8a is installed, for users having upload rights in Community albums (non true admins or webmasters), the method pwg.categories.getList does not return:

  • id_uppercat
  • representative_picture_id
  • tn_url
  • status

@plegall
Copy link
Owner Author

plegall commented Sep 4, 2017

OK @EddyLB but we can't go back in time and what's in Community 2.8.a cannot be modified, remote apps have to deal with it :-/

What's important is "does new versions of Community return data your need?"

@EddyLB
Copy link

EddyLB commented Sep 4, 2017

Ok @plegall, that will stay like this. I sent this message because I did not know to which extentpwg.categories.getList depends on Community.

Users have started requesting more capabilities, e.g. the ability to delete their photos, to create sub-albums and visualise empty albums (in addition to the admin APIs requested in #25).

@EddyLB
Copy link

EddyLB commented Jan 13, 2018

I guess you can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants