mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-13 07:48:15 +00:00
Compare commits
2 Commits
2b3eae7d43
...
5fbf7619b8
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5fbf7619b8 | ||
![]() |
b3ba07e6fa |
48
app/models/concerns/media_attachment/extensions.rb
Normal file
48
app/models/concerns/media_attachment/extensions.rb
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module MediaAttachment::Extensions
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
AUDIO_FILE_EXTENSIONS = %w(
|
||||||
|
.3gp
|
||||||
|
.aac
|
||||||
|
.flac
|
||||||
|
.m4a
|
||||||
|
.mp3
|
||||||
|
.oga
|
||||||
|
.ogg
|
||||||
|
.opus
|
||||||
|
.wav
|
||||||
|
.wma
|
||||||
|
).freeze
|
||||||
|
|
||||||
|
IMAGE_FILE_EXTENSIONS = %w(
|
||||||
|
.avif
|
||||||
|
.gif
|
||||||
|
.heic
|
||||||
|
.heif
|
||||||
|
.jpeg
|
||||||
|
.jpg
|
||||||
|
.png
|
||||||
|
.webp
|
||||||
|
).freeze
|
||||||
|
|
||||||
|
VIDEO_FILE_EXTENSIONS = %w(
|
||||||
|
.m4v
|
||||||
|
.mov
|
||||||
|
.mp4
|
||||||
|
.webm
|
||||||
|
).freeze
|
||||||
|
|
||||||
|
class_methods do
|
||||||
|
def supported_file_extensions
|
||||||
|
[
|
||||||
|
AUDIO_FILE_EXTENSIONS,
|
||||||
|
IMAGE_FILE_EXTENSIONS,
|
||||||
|
VIDEO_FILE_EXTENSIONS,
|
||||||
|
]
|
||||||
|
.flatten
|
||||||
|
.sort
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -33,6 +33,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
self.inheritance_column = nil
|
self.inheritance_column = nil
|
||||||
|
|
||||||
include Attachmentable
|
include Attachmentable
|
||||||
|
include MediaAttachment::Extensions
|
||||||
|
|
||||||
enum :type, { image: 0, gifv: 1, video: 2, unknown: 3, audio: 4 }
|
enum :type, { image: 0, gifv: 1, video: 2, unknown: 3, audio: 4 }
|
||||||
enum :processing, { queued: 0, in_progress: 1, complete: 2, failed: 3 }, prefix: true
|
enum :processing, { queued: 0, in_progress: 1, complete: 2, failed: 3 }, prefix: true
|
||||||
|
@ -46,10 +47,6 @@ class MediaAttachment < ApplicationRecord
|
||||||
MAX_VIDEO_FRAME_RATE = 120
|
MAX_VIDEO_FRAME_RATE = 120
|
||||||
MAX_VIDEO_FRAMES = 36_000 # Approx. 5 minutes at 120 fps
|
MAX_VIDEO_FRAMES = 36_000 # Approx. 5 minutes at 120 fps
|
||||||
|
|
||||||
IMAGE_FILE_EXTENSIONS = %w(.jpg .jpeg .png .gif .webp .heic .heif .avif).freeze
|
|
||||||
VIDEO_FILE_EXTENSIONS = %w(.webm .mp4 .m4v .mov).freeze
|
|
||||||
AUDIO_FILE_EXTENSIONS = %w(.ogg .oga .mp3 .wav .flac .opus .aac .m4a .3gp .wma).freeze
|
|
||||||
|
|
||||||
META_KEYS = %i(
|
META_KEYS = %i(
|
||||||
focus
|
focus
|
||||||
colors
|
colors
|
||||||
|
@ -294,10 +291,6 @@ class MediaAttachment < ApplicationRecord
|
||||||
IMAGE_MIME_TYPES + VIDEO_MIME_TYPES + AUDIO_MIME_TYPES
|
IMAGE_MIME_TYPES + VIDEO_MIME_TYPES + AUDIO_MIME_TYPES
|
||||||
end
|
end
|
||||||
|
|
||||||
def supported_file_extensions
|
|
||||||
IMAGE_FILE_EXTENSIONS + VIDEO_FILE_EXTENSIONS + AUDIO_FILE_EXTENSIONS
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def file_styles(attachment)
|
def file_styles(attachment)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user