Route status URLs back through StatusesController

This commit is contained in:
Alex Gleason 2019-11-17 21:28:18 -06:00
parent d3ee46c328
commit b3bdddf374
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 9 additions and 13 deletions

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
class StatusesController < ApplicationController class StatusesController < ReactController
include SignatureAuthentication include SignatureAuthentication
include Authorization include Authorization
@ -8,8 +8,6 @@ class StatusesController < ApplicationController
DESCENDANTS_LIMIT = 60 DESCENDANTS_LIMIT = 60
DESCENDANTS_DEPTH_LIMIT = 20 DESCENDANTS_DEPTH_LIMIT = 20
layout 'public'
before_action :set_account before_action :set_account
before_action :set_status before_action :set_status
before_action :set_instance_presenter before_action :set_instance_presenter
@ -32,12 +30,7 @@ class StatusesController < ApplicationController
expires_in 10.seconds, public: true expires_in 10.seconds, public: true
end end
@body_classes = 'with-modals' return process(:react)
set_ancestors
set_descendants
render 'stream_entries/show'
end end
format.json do format.json do
@ -111,7 +104,7 @@ class StatusesController < ApplicationController
end end
def set_account def set_account
@account = Account.find_local!(params[:account_username]) @account = Account.find_acct!(params[:account_username])
end end
def set_ancestors def set_ancestors
@ -174,6 +167,8 @@ class StatusesController < ApplicationController
end end
def set_link_headers def set_link_headers
return if !@account.local? # TODO: Handle remote accounts
response.headers['Link'] = LinkHeader.new( response.headers['Link'] = LinkHeader.new(
[ [
[account_stream_entry_url(@account, @status.stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]], [account_stream_entry_url(@account, @status.stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]],
@ -185,7 +180,7 @@ class StatusesController < ApplicationController
def set_status def set_status
@status = @account.statuses.find(params[:id]) @status = @account.statuses.find(params[:id])
@stream_entry = @status.stream_entry @stream_entry = @status.stream_entry
@type = @stream_entry.activity_type.downcase @type = @stream_entry&.activity_type&.downcase
authorize @status, :show? authorize @status, :show?
rescue GabSocial::NotPermittedError rescue GabSocial::NotPermittedError

View File

@ -46,6 +46,7 @@ Rails.application.routes.draw do
get '/users/:username', to: redirect('/%{username}'), constraints: html_only get '/users/:username', to: redirect('/%{username}'), constraints: html_only
get '/users/:username/followers', to: redirect('/%{username}/followers'), constraints: html_only get '/users/:username/followers', to: redirect('/%{username}/followers'), constraints: html_only
get '/users/:username/following', to: redirect('/%{username}/following'), constraints: html_only get '/users/:username/following', to: redirect('/%{username}/following'), constraints: html_only
get '/users/:username/statuses/:id', to: redirect('/%{username}/posts/%{id}'), constraints: html_only
get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" } get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
@ -462,8 +463,8 @@ Rails.application.routes.draw do
get '/:username/with_replies', to: 'accounts#show', as: :short_account_with_replies get '/:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
get '/:username/media', to: 'accounts#show', as: :short_account_media get '/:username/media', to: 'accounts#show', as: :short_account_media
get '/:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag get '/:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag
get '/:username/posts/:statusId/reblogs', to: 'react#react' get '/:username/posts/:statusId/reblogs', to: 'statuses#show'
get '/:account_username/posts/:id', to: 'react#react', as: :short_account_status get '/:account_username/posts/:id', to: 'statuses#show', as: :short_account_status
get '/:account_username/posts/:id/embed', to: 'statuses#embed', as: :embed_short_account_status get '/:account_username/posts/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
get '/(*any)', to: 'react#react', as: :web get '/(*any)', to: 'react#react', as: :web