Closed plegall closed 6 years ago
@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.
@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!
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 ?
OK @EddyLB we're near the solution :-)
When calling pwg.categories.getList, add the parameter faked_by_community=false
that I introduced in bb9f033a96f72d8cae86b8784910b664025aa613
Thank you @plegall. The iOS app follows that route:
pwg.categories.getList
and the option faked_by_community=false
community.categories.getList
And does that check:
if (method "community.session.getStatus" exists)
to remain compatible with old versions of Community as well?
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:
pwg.session.getStatus
, check if Piwigo version >= 2.7, get available sizesreflection.getMethodList
, check if community.session.getStatus
is availablecommunity.session.getStatus
and get real user statuspwg.plugins.getList
to determine if VideoJS is installed.@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 ?
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).
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
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?"
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).
I guess you can close this issue.
As described on https://github.com/Piwigo/Piwigo-Mobile/issues/117 Community should be able to avoid faking pwg.categories.getList to return the real list of "reachable" albums.