UniversityRadioYork / MyRadio

University Radio York's back-end radio management system
https://ury.org.uk/myradio
16 stars 16 forks source link

MyRadio_Podcast::getPodgetPodcastsAttachedToUser: fix API #1015

Closed markspolakovs closed 3 years ago

markspolakovs commented 3 years ago

The API thinks a MyRadio_User param is an int. It is not.

markspolakovs commented 3 years ago

Tested working on staging with the latest commit. To try it yourself, go to https://ury.org.uk/api-staging/v2/podcast/podcastsattachedtouser?api_key=YOUR_API_KEY&user=AN_USER_ID

markspolakovs commented 3 years ago

Wait, hang on, it's misbehaving.

markspolakovs commented 3 years ago

Right, that should work.

markspolakovs commented 3 years ago

r?'ing @mstratford as this now touches some MyRadio internals and I'd appreciate an extra pair of eyes

mstratford commented 3 years ago

I've never been 100% sure how the mixins work, I'd appreciate finding out why the mixins come into these changes?

markspolakovs commented 3 years ago

@mstratford Mixins are only ever used in ServiceAPI::toDataSource() to customise what fields you want (e.g. compare https://ury.org.uk/api/v2/user/currentuser and https://ury.org.uk/api/v2/user/currentuser?mixins=training,shows,personal_data,all_officerships).

They shouldn't be finding their way into any other methods, yet when I used this branch as of the commit-before-last with a mixin (e.g. https://ury.org.uk/api-staging/v2/podcast/podcastsattachedtouser?api_key=YOUR_API_KEY&user=AN_USER_ID&mixins=show) I got an error about the $user parameter - sticking in a var_dump revealed that it was passing in the value of the mixins field into the $user parameter. The simplest fix was to filter it out like we already do with api_key.