Skip to content
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

[RNMobile] Fetch VideoPress token #29756

Merged
merged 6 commits into from
Apr 5, 2023
Merged

Conversation

fluiddot
Copy link
Contributor

@fluiddot fluiddot commented Mar 28, 2023

⚠️ This PR depends on WordPress/gutenberg#49371 and wordpress-mobile/gutenberg-mobile#5632, so we should hold the merge until that one is merged.

Closes wordpress-mobile/gutenberg-mobile#5512 and closes wordpress-mobile/gutenberg-mobile#5528.

Proposed changes:

  • d4fc8fb: Add getMediaToken. Part of the functionality of the web version is not implemented, specifically the fetch of the upload token and the persistence of the token.
  • dd070b1: Fetch the token in the block when getting the VideoPress GUID. The token is not used yet but I incorporated this change to have it as an example.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

N/A

Does this pull request change what data or activity we track or use?

N/A

Testing instructions:

Preparation:
Since the token is fetched via a POST request, we need to use changes from wordpress-mobile/gutenberg-mobile#5596.

  1. Apply the following patch:
diff --git forkSrcPrefix/projects/packages/videopress/src/client/block-editor/blocks/video/edit.native.tsx forkDstPrefix/projects/packages/videopress/src/client/block-editor/blocks/video/edit.native.tsx
index c3643e2c30a8b9d7ba081b50729af1e08cb3ec5c..8fc6df43a5be2613b4e2f7f9be5c138571f07f1f 100644
--- forkSrcPrefix/projects/packages/videopress/src/client/block-editor/blocks/video/edit.native.tsx
+++ forkDstPrefix/projects/packages/videopress/src/client/block-editor/blocks/video/edit.native.tsx
@@ -82,6 +82,7 @@ export default function VideoPressEdit( {
 			getMediaToken( 'upload', { guid, flushToken: true } )
 				.then( tokenData => {
 					setToken( tokenData.token );
+					console.log( { token: tokenData.token } );
 				} )
 				.catch( error => {
 					// eslint-disable-next-line no-console
  1. Open/create a post.
  2. Add a VideoPress block.
  3. Add a Video to the block.
  4. Save the post.
  5. Re-open the post.
  6. Observe that the token is shown in the console logs (i.e. {"token": "<TOKEN>").

@github-actions
Copy link
Contributor

github-actions bot commented Mar 28, 2023

Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run

bin/jetpack-downloader test jetpack rnmobile/videopress-fetch-token

to get started. More details: p9dueE-5Nn-p2

@github-actions
Copy link
Contributor

github-actions bot commented Mar 28, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.

@fluiddot fluiddot force-pushed the rnmobile/videopress-fetch-token branch from 01f796c to 76682ea Compare March 30, 2023 10:29
SiobhyB
SiobhyB previously approved these changes Mar 31, 2023
Copy link

@SiobhyB SiobhyB left a comment

Choose a reason for hiding this comment

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

Works great for me! I left one comment, but this is just a question for my own learning. @fluiddot, thank you for all your work on these set of PRs! 👏 👏 🙇‍♀️

I'd be happy to also approve the gutenberg and gutenberg-mobile PRs that this one relies on pending the discussion on the gutenberg one. 🙇‍♀️

# Conflicts:
#	projects/packages/videopress/src/client/block-editor/blocks/video/edit.native.tsx
@fluiddot
Copy link
Contributor Author

fluiddot commented Apr 5, 2023

@SiobhyB your PR review got dismissed when merging trunk into the PR. Would you mind re-approving it? Thanks 🙇 !

@fluiddot fluiddot requested a review from SiobhyB April 5, 2023 14:35
Copy link

@SiobhyB SiobhyB left a comment

Choose a reason for hiding this comment

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

@fluiddot, absolutely, re-approved :D

@fluiddot fluiddot merged commit 9608824 into trunk Apr 5, 2023
@fluiddot fluiddot deleted the rnmobile/videopress-fetch-token branch April 5, 2023 14:56
@zinigor zinigor added this to the Jetpack/12.1 milestone Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch VideoPress token for private videos [Android] Fetch VideoPress token for private videos [iOS]
3 participants