Add API to manage Favorites #807

Closed
opened 2026-10-05 00:18:20 +02:00 by adam · 6 comments
Owner

I may have missed something but I could not find API methods to add an image to favorites and to get the list of favorites. Could this be implemented in a not too far future?

I may have missed something but I could not find API methods to add an image to favorites and to get the list of favorites. Could this be implemented in a not too far future? <!-- github-sync-id:342873552 -->
adam closed this issue 2026-10-05 00:18:20 +02:00
Author
Owner

#810 will do the adding and removing.

#810 will do the adding and removing. <!-- github-comment-id:406478094 -->
Author
Owner

@abrenoch I'm making some changes on your code (indentation, function rename...) and I understand that you have never checked the "fetch another user's favorite photos" because you automatically get a fatal error. Considering you've made the code far more complex just to be able to get another user favorites, I'm confused. Even if I include the appropriate function file to have get_username function, the code doesn't work (I get some photos that are not accessible to the user...)

In my opinion, we should remove the user_id input parameter on pwg.users.getFavorites and simply use check_user_favorites and get_sql_condition_FandF mature functions. Later maybe, when needed we can add the user_id parameter. Allright?

The exact question is : for now, for Piwigo 2.10, do you really need to be able to fetch favorites of any user or getting the current user favorites would be enough?

@abrenoch I'm making some changes on your code (indentation, function rename...) and I understand that you have never checked the "fetch another user's favorite photos" because you automatically get a fatal error. Considering you've made the code far more complex just to be able to get another user favorites, I'm confused. Even if I include the appropriate function file to have `get_username` function, the code doesn't work (I get some photos that are not accessible to the user...) In my opinion, we should remove the user_id input parameter on pwg.users.getFavorites and simply use `check_user_favorites` and `get_sql_condition_FandF` mature functions. Later maybe, when needed we can add the user_id parameter. Allright? The exact question is : for now, for Piwigo 2.10, do you really need to be able to fetch favorites of any user or getting the current user favorites would be enough? <!-- github-comment-id:512244193 -->
Author
Owner

@plegall that sounds totally fine... it was a while ago I put this together so I can't even remember my original use-case. The current user's favorites are certainly sufficient.

Thanks for looking into including it!

@plegall that sounds totally fine... it was a while ago I put this together so I can't even remember my original use-case. The current user's favorites are certainly sufficient. Thanks for looking into including it! <!-- github-comment-id:512244868 -->
Author
Owner

Yes, the current user's favorites would already satisfy a large number of users.

Yes, the current user's favorites would already satisfy a large number of users. <!-- github-comment-id:512251080 -->
Author
Owner

Good, I've made some simplifications :-) and IMHO a better naming for methods. Listed on https://piwigo.org/doc/doku.php?id=dev:changes_in_2.10&#new_methods_for_web_api

Good, I've made some simplifications :-) and IMHO a better naming for methods. Listed on https://piwigo.org/doc/doku.php?id=dev:changes_in_2.10&#new_methods_for_web_api <!-- github-comment-id:512264015 -->
Author
Owner

Excellent, looking forward to the update!

Excellent, looking forward to the update! <!-- github-comment-id:512266647 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#807