Save video metadata and improve video OpenGraph tags (#6481)
* Save metadata from video attachments, put correct dimensions into OG tags * Add twitter:player for videos * Fix code style and test
This commit is contained in:
parent
1122579216
commit
9dbae6e8a1
11 changed files with 151 additions and 44 deletions
|
@ -3,20 +3,26 @@
|
|||
class MediaController < ApplicationController
|
||||
include Authorization
|
||||
|
||||
before_action :verify_permitted_status
|
||||
before_action :set_media_attachment
|
||||
before_action :verify_permitted_status!
|
||||
|
||||
def show
|
||||
redirect_to media_attachment.file.url(:original)
|
||||
redirect_to @media_attachment.file.url(:original)
|
||||
end
|
||||
|
||||
def player
|
||||
@body_classes = 'player'
|
||||
raise ActiveRecord::RecordNotFound unless @media_attachment.video? || @media_attachment.gifv?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def media_attachment
|
||||
MediaAttachment.attached.find_by!(shortcode: params[:id])
|
||||
def set_media_attachment
|
||||
@media_attachment = MediaAttachment.attached.find_by!(shortcode: params[:id] || params[:medium_id])
|
||||
end
|
||||
|
||||
def verify_permitted_status
|
||||
authorize media_attachment.status, :show?
|
||||
def verify_permitted_status!
|
||||
authorize @media_attachment.status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
# Reraise in order to get a 404 instead of a 403 error code
|
||||
raise ActiveRecord::RecordNotFound
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue