Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mastofe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Pleroma
mastofe
Commits
dc15c81e
Unverified
Commit
dc15c81e
authored
5 years ago
by
Eugen Rochko
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Change video uploads to enforce certain limits (#13218)
- Dimensions at most 1920x1200 - Frame rate at most 60
parent
7088633a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models/media_attachment.rb
+15
-0
15 additions, 0 deletions
app/models/media_attachment.rb
with
15 additions
and
0 deletions
app/models/media_attachment.rb
+
15
−
0
View file @
dc15c81e
...
...
@@ -126,6 +126,9 @@ class MediaAttachment < ApplicationRecord
IMAGE_LIMIT
=
10
.
megabytes
VIDEO_LIMIT
=
40
.
megabytes
MAX_VIDEO_MATRIX_LIMIT
=
2_304_000
# 1920x1200px
MAX_VIDEO_FRAME_RATE
=
60
belongs_to
:account
,
inverse_of: :media_attachments
,
optional:
true
belongs_to
:status
,
inverse_of: :media_attachments
,
optional:
true
belongs_to
:scheduled_status
,
inverse_of: :media_attachments
,
optional:
true
...
...
@@ -223,6 +226,7 @@ class MediaAttachment < ApplicationRecord
before_create
:set_processing
before_post_process
:set_type_and_extension
before_post_process
:check_video_dimensions
before_save
:set_meta
...
...
@@ -295,6 +299,17 @@ class MediaAttachment < ApplicationRecord
self
.
processing
=
delay_processing?
?
:queued
:
:complete
end
def
check_video_dimensions
return
unless
(
video?
||
gifv?
)
&&
file
.
queued_for_write
[
:original
].
present?
movie
=
FFMPEG
::
Movie
.
new
(
file
.
queued_for_write
[
:original
].
path
)
return
unless
movie
.
valid?
raise
Mastodon
::
DimensionsValidationError
,
"
#{
movie
.
width
}
x
#{
movie
.
height
}
videos are not supported"
if
movie
.
width
*
movie
.
height
>
MAX_VIDEO_MATRIX_LIMIT
raise
Mastodon
::
DimensionsValidationError
,
"
#{
movie
.
frame_rate
.
to_i
}
fps videos are not supported"
if
movie
.
frame_rate
>
MAX_VIDEO_FRAME_RATE
end
def
set_meta
meta
=
populate_meta
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment