-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Videopress: Request upload token with correct user #39796
base: trunk
Are you sure you want to change the base?
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! |
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super familiar with VideoPress so I've been playing around with it and reading the docs to figure out how it's supposed to work.
Upload a video with User B and verify that the correct author attached to the video is User B
VideoPress seems to change the concept of an uploaded media file belonging to a particular user. The docs mention special considerations about roles (only admins can properly manage videos), and if you look at the VideoPress dashboard at /wp-admin/admin.php?page=jetpack-videopress
it doesn't mention anything about the "owner" of a piece of media—unlike the usual media gallery.
Unlike videos uploaded without VideoPress
That's because I believe VideoPress keeps your media files elsewhere; off your site. You can confirm this with a call to wp post list --post_type=attachment
. The CDN where we keep videos mustn't have finegrained ownership metadata.
So I think the idea from #72900 of trying to correct the metadata so it has the "correct" owner isn't the right approach. It doesn't seem compatible with VideoPress.
We can of course still have the activity log record the user who does the uploading correctly. But in that case maybe we should keep using the JETPACK__ANY_USER_TOKEN
to do the upload and then find a way to record the activity log correctly as an independent thing.
@@ -205,8 +205,7 @@ public function wp_ajax_videopress_get_upload_token() { | |||
); | |||
|
|||
$endpoint = "sites/{$video_blog_id}/media/token"; | |||
$result = Client::wpcom_json_api_request_as_blog( $endpoint, Client::WPCOM_JSON_API_VERSION, $args ); | |||
|
|||
$result = Client::wpcom_json_api_request_as_blog( $endpoint, Client::WPCOM_JSON_API_VERSION, $args, array( 'external_user_id' => get_current_user_id() ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment on D165318-code for why this external_user_id
isn't always going to be enough to generate a user-specific token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to pass that external_user_id
property? There's an already existing Client::wpcom_json_api_request_as_user
method we can use to pass the user id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to pass that external_user_id property? There's an already existing Client::wpcom_json_api_request_as_user method we can use to pass the user id.
For some reason when this function is used it fails with error You must be logged-in to get an upload token
, I suspect because the upload endpoint is an older endpoint it might need some additional configuration for it to work. wanted to get eyes on the PR for discussion so didn't look into it too much. can revisit it.
Related: #39034 |
Thanks for taking the time to dig into this! At this point you know better what the flows are and if you feel this is the right approach, I'll trust you with it. That said, I can only think about what this means in terms of licensing: a user paying for VP immediately attaches the license to a blog and allows all (capable) users to upload videos. I do like this, just noting that we need to be able to track down users (or uploads) by a given token that, in turn, can be tracked down to the license owner. Not a problem, just something to keep in mind. @vykes-mac if you update (merge or rebase) I'll give it one last spin, but I also encourage you to go forth and try to super test this with as many edge cases as you can think of :) Ping me! |
@CGastrell I did a rebase, you can perform some test! |
Testing from an AT site running this build, I'm getting very mixed results. Simply editing a post and uploading a video produces the wrong activity author and then some bunch of follow up activities, also with mixed authors: This was a single video upload with user B (later seen as yabranh), but the activity claims I did it with user A (cgastrell): When that "multiple users" thing is uncollapsed, I see this: Anything I might have done wrong? Is this expected @vykes-mac ? |
Interesting 🤔, I know there are some thumbnails generated when uploading a video that will be logged as the primary owner but the video upload itself should be logged as uploaded by user B. The accompanied diff is applied to your sandbox ? |
Yes. |
Removing this out of the review queue. @vykes-mac - I've updated the branch to trunk. Can you get this back around to the team for review (if ready) etc? Thank you! |
Fixes Automattic/wp-calypso#72900
Proposed changes:
Currently the generated token use for uploading videos does not take the user uploading the video into account but always use the blog owner as the user. This causes the blog owner to be attached as the author for every video that's uploaded. This affects audits as the activity log shows incorrect author on the video upload. See the issue for more information
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: