plegall / Piwigo-community

11 stars 23 forks source link

Not compatible with the Android app Piwigoclient #43

Closed jessie-github closed 5 years ago

jessie-github commented 5 years ago

Hello, It seems that a recent changes is making the plugin incompatible with the Android app Piwigoclient. It is not possible to display albums anymore in Piwigoclient. If I deactivate the Community plugin, everything is working.

I've contacted the Piwigoclient author and here is his answer:

 The answer is:

Short answer:

The community plugin has either been altered or you have altered the permissions of albums on your server.

Long answer:

The piwigo client could never get an album list when users used the community plugin in the past because it made the album list return just those you could upload to unless you were not logged in. So... I changed it, I force guest access when requesting album lists if you're using the community plugin. This then allows you to browse the album correctly and it uses the user account when retrieving images and or uploading etc.

So, I would suggest very carefully thinking what changes you've made to your server. Then, presuming you have done nothing, read the release notes and maybe even look at the source code changes since the working version of the community plugin and the piwigo server (or raise a bug report with the community plugin).

Quick fix:

Enable guest access to all albums you want users to be able to view using the piwigo client (images can still be restricted to require user access)

Personal thoughts:

I've not read the source code of the community plugin, but it seemed to have very weird effects on my server and since I didnt need it I deleted it and decided not to support it in my app... until someone requested it (maybe it was you?).

I can't magically make it work for you at the moment. Sorry.

Make use of the webservice api test page to see what responses my app gets. If you can tell me what I need to call to get the correct responses, please do so, but I cannot see them.

Do you know what I can do to help the Piwigoclient author to make it compatible with the Community plugin ?

jessie-github commented 5 years ago

It seems that it is because the Community plugin is changing the web API. For instance with the Community plugin deactivate, we can retrieve the Categories list with pwg.categories.getList:

<rsp stat="ok"><categories><category id="287" status="private" nb_images="2" total_nb_images="2" date_last="2018-07-21 21:04:06" max_date_last="2018-07-21 21:04:06" nb_categories="0" url="https://photos.example.com/index.php?/category/287"><name>Piwigoclient test</name><comment/><uppercats>287</uppercats><global_rank>1</global_rank><representative_picture_id>7266</representative_picture_id><tn_url>https://photos.example.com/_data/i/upload/2018/07/21/20180721210400-59d1302f-th.jpg</tn_url></category></categories></rsp>

But with the Community plugin activated, the same method return an empty result:

<rsp stat="ok"><categories><category id="286" nb_images="0" total_nb_images="0" nb_categories="0" url="https://photos.example.com/index.php?/category/286"><name>Community</name><uppercats>286</uppercats><global_rank>2</global_rank><comment/></category></categories></rsp>

So how can we retrieve the Categories list with the plugin activated ?

jessie-github commented 5 years ago

Relevant issue: https://github.com/Piwigo/Piwigo-Mobile/issues/117

But I also don't get any result either with community.categories.getList

EddyLB commented 5 years ago

Hi @jessie-github

Here is the way Piwigo iOS does the job:

  1. Call reflection.getMethodList to determine whether the Community extension is installed (by detecting the presence of community.session.getStatus)
  2. Call pwg.session.login to authenticate the user
  3. If the Community extension is installed, call community.session.getStatus to determine the real user rights (admin or webmaster).
  4. Call pwg.session.getStatus to check Piwigo version, get token, available image sizes, upload file types, etc. Set the user rights from this call only when the Community extension is not used.
  5. Call pwg.categories.getList with parameters cat_id, recursive and faked_by_community. As explained in https://github.com/plegall/Piwigo-community/issues/23 the value of faked_by_community must be "false" if the Community extension is installed and "true" otherwise.
  6. If the Community extension is installed, call community.categories.getList to identify albums having upload rights

The actions proposed to the user will then depend on his/her rights: [admin], [upload rights on specific albums] or [none].

Cheers

jessie-github commented 5 years ago

Solved in the current release of Android piwigoclient.