-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Limit video uploads on free sites #17689
Conversation
…a does not exceed video limit duration, if it's a video
…a do not exceed video limit duration, if it's a video
…ss-iOS into issue/limit-video-uploads-on-free-sites
…o exceeds the allowed duration on free sites
…sers about video limit exceeded
…videos that cannot be selected in the media picker
…do not exceed allowed duration on free sites
… exceed allowed duration on free sites
…new video limits for free sites to WP Stories
… free sites to the editor
You can trigger an installable build for these changes by visiting CircleCI here. |
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
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.
For the most part, this is working really well! I tested across the Media library, blog post editor, and stories editor. I'm seeing one issue where I think the logic is wrong where we're using a guard statement, which wouldn't let me upload a video to my paid blog.
My other main comment is that we're duplicating a snippet of logic across many places to check if we can upload an asset, so perhaps we should extract that somewhere central.
The newly added files also need adding to the Jetpack target, as it's currently failing to build.
/// - Parameters: | ||
/// - viewController: presenting UIViewController | ||
/// - title: title of the alert | ||
private func persentVideoLimitsAlert(on viewController: UIViewController, title: String) { |
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.
Nitpick, typo: persent
-> present
extension GutenbergMediaPickerHelper: WPMediaPickerViewControllerDelegate { | ||
|
||
func mediaPickerController(_ picker: WPMediaPickerViewController, didFinishPicking assets: [WPMediaAsset]) { | ||
invokeMediaPickerCallback(asset: assets) | ||
picker.dismiss(animated: true, completion: nil) | ||
if picker == self.cameraPicker, |
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.
Can omit all uses of self
in this method.
asset.exceedsFreeSitesAllowance() && | ||
!post.blog.hasPaidPlan |
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.
We're repeating this bit of logic in three places in this class – perhaps we should create a smaller helper method?
func canUploadAsset(_ asset: WPMediaAsset, for blog: Blog) -> Bool {
asset.exceeedsFreeSitesAllowance() && !blog.hasPaidPlan
}
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.
Or thinking about it, we're using this same bit of logic across a whole range of classes multiple times. Perhaps we should move it onto Blog
? canUploadAsset(_ asset: WPMediaAsset)
?
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.
That makes perfect sense @frosty ! Only one minor change to the above snippet, I think the condition for a blog that can upload video assets should be (if we put it in Blog
):
func canUploadAsset(_ asset: WPMediaAsset) -> Bool {
hasPaidPlan || !asset.exceedsFreeSitesAllowance()
}
does it sound right?
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.
Yep, that makes sense to me!
return | ||
guard let media = media as? PHAsset, | ||
!media.exceedsFreeSitesAllowance(), | ||
!blog.hasPaidPlan else { |
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 think this logic isn't correct. I'm seeing a case where media is exceeding the free sizes allowance, but the blog has a paid plan, but I'm not allowed to upload it. We only want to present the limit if both the media exceeds the limit and the blog doesn't have a paid plan.
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.
Thanks for catching this @frosty ! This is one more case where your suggestion to extract the canUploadAsset
method comes in handy.
… didFinishPicking assets: [WPMediaAsset]) in GutenbergMediaPickerHelper, removed unnecessary use of self
…if the blog can upload the given asset
Thanks for reviewing @frosty ! PR is ready for another pass, whenever you can. |
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.
Great changes! Just one small typo, and one question but otherwise let's
@@ -0,0 +1,7 @@ | |||
extension Blog { | |||
|
|||
/// returns true if the blog is allowed upload the given asset, true otherwise |
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.
Nitpick allowed _to_ upload
Also, false
otherwise! :)
picker !== cameraPicker && | ||
asset.exceedsFreeSitesAllowance() && | ||
!post.blog.hasPaidPlan | ||
!post.blog.canUploadAsset(asset) |
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 still need to check if it's not the camera picker here?
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.
Yes, thanks for catching this!!
Does this just check for the video length, or does it also check that the file size is less than 100MB? Reason I'm asking is that it is much easier for us to check the file size at the api endpoint rather than the file length, so it'd be good to tell the user in the app that their files should be under 100MB. |
Hey @roundhill , we are only checking duration. The main reason is that users can control duration much more than size, especially with newer devices allowing 4K videos. Potentially there could be shorter videos that exceed the size and longer ones that do not. Also, the current UI of both the media picker and the camera capture do not provide info about the size. This could probably be changed, but we'd need to investigate and do a separate project for this. |
…not the camera picker prior to show an overlay for disallowed videos
…ss-iOS into issue/limit-video-uploads-on-free-sites
This PR prevents videos longer than 5 minutes to be uploaded on free sites. This applies to captured or selected videos from:
Notes:
Fixes #NA
To test:
Pre requisites:
WPMediaAsset+VideoLimits.swift
)let maximumVideoDurationForFreeSites: CGFloat = 300
choosing a shorter value than 5 minutes (e.g. 5 seconds)
Regression Notes
Potential unintended areas of impact
Limited impact: these changes impact the video upload sections in media, Gutenberg and Stories
What I did to test those areas of impact (or what existing automated tests I relied on)
Test all the impacted cases, both with free and paid plans
What automated tests I added (or what prevented me from doing so)
None
PR submission checklist:
RELEASE-NOTES.txt
if necessary.