about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-06-19 23:42:38 +0200
committermultiple creatures <dev@multiple-creature.party>2020-02-21 03:40:29 -0600
commit480a83e843b92cc1fa4378b576bfd173024f3f8c (patch)
treeb5cb7b592bdb9bffb0f95970cbef8b7a1ee8f12e /app/controllers
parentb956d469846e9530dd6fa020a1161cd1b9d2b7dd (diff)
port tootsuite#11123 to monsterfork: Add audio uploads
* Add audio uploads

Fix #4827

Accept uploads of OGG, WAV, FLAC, OPUS and MP3 files, and converts
them to OGG. Media attachments get a new `audio` type. In the UI,
audio uploads are displayed identically to video uploads.

* Improve code style
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/media_controller.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb
index 352a04c54..05cf09c28 100644
--- a/app/controllers/media_controller.rb
+++ b/app/controllers/media_controller.rb
@@ -9,6 +9,8 @@ class MediaController < ApplicationController
   before_action :authenticate_user!, if: :whitelist_mode?
   before_action :set_media_attachment
   before_action :verify_permitted_status!
+  before_action :check_playable, only: :player
+  before_action :allow_iframing, only: :player
 
   content_security_policy only: :player do |p|
     p.frame_ancestors(false)
@@ -20,8 +22,6 @@ class MediaController < ApplicationController
 
   def player
     @body_classes = 'player'
-    response.headers['X-Frame-Options'] = 'ALLOWALL'
-    raise ActiveRecord::RecordNotFound unless @media_attachment.video? || @media_attachment.gifv?
   end
 
   private
@@ -35,4 +35,12 @@ class MediaController < ApplicationController
   rescue Mastodon::NotPermittedError
     raise ActiveRecord::RecordNotFound
   end
+
+  def check_playable
+    not_found unless @media_attachment.larger_media_format?
+  end
+
+  def allow_iframing
+    response.headers['X-Frame-Options'] = 'ALLOWALL'
+  end
 end