Skip to content

updated logic for get_asset_by_tp_media_id() now takes queryargs so w…#24

Open
tamw-wnet wants to merge 6 commits intomasterfrom
new_logic_for_legacy_tp_id_lookup
Open

updated logic for get_asset_by_tp_media_id() now takes queryargs so w…#24
tamw-wnet wants to merge 6 commits intomasterfrom
new_logic_for_legacy_tp_id_lookup

Conversation

@tamw-wnet
Copy link
Owner

…e can include a platform-slug arg

@tamw-wnet tamw-wnet requested a review from augustuswm November 1, 2017 17:08
@tamw-wnet
Copy link
Owner Author

@acrosman @jesseves @augustuswm I've made a proposed change to how get_asset_by_tp_media_id() works. I've added the ability to take an args array, same types of args we do for other endpoints (particularly the 'platform-slug' arg).

The current behavior is if the returned asset URL generates a 404, we'd append '/edit' to the request to try and get the 'private' record. I didn't love this because theoretically we might not be able to hit that endpoint for assets the client id doesn't have edit rights on. Also, I don't love that this can return unpublished assets, which doesn't seem right.

The proposed new behavior is to allow for passing a platform-slug arg (and other args) that would be appropriate for the asset we're looking for. I think the actual use-case we're looking for is usually going to be because the asset is platform restricted anyway.

Thoughts? I could modify this so it could also take a "private" arg, or maybe fallback to the old behavior if no queryargs are passed.

@augustuswm
Copy link
Collaborator

augustuswm commented Nov 1, 2017

I don't believe we rely on the auto-lookup of the edit endpoint here. Currently we use the get_updatable_object method.

I would be in favor of seeing if anyone else is using it. If it is not being used I like the idea of separating the two (and increasing the version). Currently it is weird in that you can't necessarily determine based on a 404 why you got the error. ie. "Non-existence" is equivalent to "No access"

@tamw-wnet
Copy link
Owner Author

To @augustuswm 's comment, I realize I also prefer not doing the auto-lookup of the edit endpoint because the new approach keeps the resolved asset URL unedited. That leaves it a bit more logical to do the get_updatable_object on the response.

@acrosman
Copy link
Contributor

acrosman commented Nov 1, 2017

We aren't doing anything with the edit links at the moment. So any changes to how they are discovered or access should not effect our projects. We have picked up a couple more stations using the module, but as far as I can tell from issues they have opened on Drupal.org they are also just using the functions in the module and not the full library (although they can access it) – which is to say some time in the future we may have more feedback on and concern about editing related features.

@jesseves
Copy link
Contributor

jesseves commented Nov 1, 2017

As @acrosman said, we're not currently doing anything with the edit links. So, as long as this doesn't introduce a breaking change to the core use of the function (send ID, get asset), then I don't see an issue.

$query = "/assets/legacy/?tp_media_id=" . $tp_media_id;
$response = $this->get_request($query);
$endpoint = "/assets/legacy/?tp_media_id=" . $tp_media_id;
$response = $this->get_request($endpoint);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing it, but is there a reason to perform this query without the $queryargs if they are passed in?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've confirmed -- /assets/legacy/?platform-slug=partnerplayer&tp_media_id=[someid] returns a 404, and the URL returned does not include the platform-slug (or any other) arg. So yeah, there's no point in including the queryargs on the initial call.

@tamw-wnet
Copy link
Owner Author

@jesseves @acrosman this might actually be 'breaking' in a certain way. You are probably going to get more 404s, unless you update your calls to include the queryargs with 'platform-slug' => 'partnerplayer' . The 'edit' endpoint we were failing over to ignores platform. I could easily conditionalize this like so:
IF queryargs IS NULL, fallback to edit endpoint.

@tamw-wnet
Copy link
Owner Author

@augustuswm I'm not sure if PBS's actual legacy endpoint even understands additional queryargs. I'll check and see; if it does, I'll include the args in the initial query.

@augustuswm
Copy link
Collaborator

@tamw-wnet Good call, I did not consider that

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

Successfully merging this pull request may close these issues.

4 participants