Merge remote-tracking branch 'upstream/develop' into feature/frontend_refactor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AccountsController < ApplicationController
|
||||
class AccountsController < ReactController
|
||||
PAGE_SIZE = 20
|
||||
|
||||
include AccountControllerConcern
|
||||
@@ -11,24 +11,7 @@ class AccountsController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
mark_cacheable! unless user_signed_in?
|
||||
|
||||
@body_classes = 'with-modals'
|
||||
@pinned_statuses = []
|
||||
@endorsed_accounts = @account.endorsed_accounts.to_a.sample(4)
|
||||
|
||||
if current_account && @account.blocking?(current_account)
|
||||
@statuses = []
|
||||
return
|
||||
end
|
||||
|
||||
@pinned_statuses = cache_collection(@account.pinned_statuses, Status) if show_pinned_statuses?
|
||||
@statuses = filtered_status_page(params)
|
||||
@statuses = cache_collection(@statuses, Status)
|
||||
|
||||
unless @statuses.empty?
|
||||
@older_url = older_url if @statuses.last.id > filtered_statuses.last.id
|
||||
@newer_url = newer_url if @statuses.first.id < filtered_statuses.first.id
|
||||
end
|
||||
return process(:react)
|
||||
end
|
||||
|
||||
format.atom do
|
||||
|
||||
@@ -11,12 +11,7 @@ class Api::V1::AccountByUsernameController < Api::BaseController
|
||||
end
|
||||
|
||||
def set_account
|
||||
username, domain = params[:username].split("@")
|
||||
if domain
|
||||
@account = Account.find_remote!(username, domain)
|
||||
else
|
||||
@account = Account.find_local!(username)
|
||||
end
|
||||
@account = Account.find_acct!(params[:username])
|
||||
end
|
||||
|
||||
def check_account_suspension
|
||||
|
||||
@@ -6,8 +6,6 @@ module AccountControllerConcern
|
||||
FOLLOW_PER_PAGE = 12
|
||||
|
||||
included do
|
||||
layout 'public'
|
||||
|
||||
before_action :set_account
|
||||
before_action :check_account_approval
|
||||
before_action :check_account_suspension
|
||||
@@ -18,7 +16,7 @@ module AccountControllerConcern
|
||||
private
|
||||
|
||||
def set_account
|
||||
@account = Account.find_local!(username_param)
|
||||
@account = Account.find_acct!(username_param)
|
||||
end
|
||||
|
||||
def set_instance_presenter
|
||||
@@ -26,6 +24,8 @@ module AccountControllerConcern
|
||||
end
|
||||
|
||||
def set_link_headers
|
||||
return if !@account.local? # TODO: Handle remote users
|
||||
|
||||
response.headers['Link'] = LinkHeader.new(
|
||||
[
|
||||
webfinger_account_link,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class HomeController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :set_referrer_policy_header
|
||||
before_action :set_initial_state_json
|
||||
before_action :set_data_for_meta
|
||||
class ReactController < ApplicationController
|
||||
before_action :authenticate_user!, only: :react
|
||||
before_action :set_referrer_policy_header, only: :react
|
||||
before_action :set_initial_state_json, only: :react
|
||||
before_action :set_data_for_meta, only: :react
|
||||
|
||||
def index
|
||||
#
|
||||
def react
|
||||
@body_classes = 'app-body'
|
||||
end
|
||||
|
||||
private
|
||||
@@ -15,18 +15,6 @@ class HomeController < ApplicationController
|
||||
def set_data_for_meta
|
||||
return if find_route_matches
|
||||
|
||||
if params[:username].present?
|
||||
@account = Account.find_local(params[:username])
|
||||
elsif params[:account_username].present?
|
||||
@account = Account.find_local(params[:account_username])
|
||||
|
||||
if params[:id].present? && !@account.nil?
|
||||
@status = @account.statuses.find(params[:id])
|
||||
@stream_entry = @status.stream_entry
|
||||
@type = @stream_entry.activity_type.downcase
|
||||
end
|
||||
end
|
||||
|
||||
if request.path.starts_with?('/tags') && params[:tag].present?
|
||||
@tag = Tag.find_normalized(params[:tag])
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StatusesController < ApplicationController
|
||||
class StatusesController < ReactController
|
||||
include SignatureAuthentication
|
||||
include Authorization
|
||||
|
||||
@@ -8,8 +8,6 @@ class StatusesController < ApplicationController
|
||||
DESCENDANTS_LIMIT = 60
|
||||
DESCENDANTS_DEPTH_LIMIT = 20
|
||||
|
||||
layout 'public'
|
||||
|
||||
before_action :set_account
|
||||
before_action :set_status
|
||||
before_action :set_instance_presenter
|
||||
@@ -32,12 +30,7 @@ class StatusesController < ApplicationController
|
||||
expires_in 10.seconds, public: true
|
||||
end
|
||||
|
||||
@body_classes = 'with-modals'
|
||||
|
||||
set_ancestors
|
||||
set_descendants
|
||||
|
||||
render 'stream_entries/show'
|
||||
return process(:react)
|
||||
end
|
||||
|
||||
format.json do
|
||||
@@ -111,7 +104,7 @@ class StatusesController < ApplicationController
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find_local!(params[:account_username])
|
||||
@account = Account.find_acct!(params[:account_username])
|
||||
end
|
||||
|
||||
def set_ancestors
|
||||
@@ -174,6 +167,8 @@ class StatusesController < ApplicationController
|
||||
end
|
||||
|
||||
def set_link_headers
|
||||
return if !@account.local? # TODO: Handle remote accounts
|
||||
|
||||
response.headers['Link'] = LinkHeader.new(
|
||||
[
|
||||
[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
|
||||
@status = @account.statuses.find(params[:id])
|
||||
@stream_entry = @status.stream_entry
|
||||
@type = @stream_entry.activity_type.downcase
|
||||
@type = @stream_entry&.activity_type&.downcase
|
||||
|
||||
authorize @status, :show?
|
||||
rescue GabSocial::NotPermittedError
|
||||
|
||||
Reference in New Issue
Block a user