Skip to content

Commit

Permalink
conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgoldstein committed Nov 30, 2023
2 parents 98348df + 9633549 commit 291faa5
Show file tree
Hide file tree
Showing 74 changed files with 621 additions and 497 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Lint/NonLocalExitFromIterator:

# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 144
Max: 125

# Configuration parameters: CountBlocks, Max.
Metrics/BlockNesting:
Expand Down
6 changes: 5 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
sudo apt-add-repository 'deb https://dl.yarnpkg.com/debian/ stable main'
# Add repo for NodeJS
curl -sL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
# Add firewall rule to redirect 80 to PORT and save
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port #{ENV["PORT"]}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def default_statuses
end

def only_media_scope
Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id)
Status.joins(:media_attachments).merge(@account.media_attachments).group(:id)
end

def no_replies_scope
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/export_domain_allows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Admin
class ExportDomainAllowsController < BaseController
include AdminExportControllerConcern
include Admin::ExportControllerConcern

before_action :set_dummy_import!, only: [:new]

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/export_domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module Admin
class ExportDomainBlocksController < BaseController
include AdminExportControllerConcern
include Admin::ExportControllerConcern

before_action :set_dummy_import!, only: [:new]

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class Api::BaseController < ApplicationController
DEFAULT_STATUSES_LIMIT = 20
DEFAULT_ACCOUNTS_LIMIT = 40

include RateLimitHeaders
include AccessTokenTrackingConcern
include ApiCachingConcern
include Api::RateLimitHeaders
include Api::AccessTokenTrackingConcern
include Api::CachingConcern
include Api::ContentSecurityPolicy

skip_before_action :require_functional!, unless: :limited_federation_mode?
Expand Down Expand Up @@ -105,7 +105,7 @@ def require_authenticated_user!
end

def require_not_suspended!
render json: { error: 'Your login is currently disabled' }, status: 403 if current_user&.account&.suspended?
render json: { error: 'Your login is currently disabled' }, status: 403 if current_user&.account&.unavailable?
end

def require_user!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def load_accounts
end

def hide_results?
@account.suspended? || (@account.hides_followers? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
@account.unavailable? || (@account.hides_followers? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
end

def default_accounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def load_accounts
end

def hide_results?
@account.suspended? || (@account.hides_following? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
@account.unavailable? || (@account.hides_following? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
end

def default_accounts
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/accounts/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def set_account
end

def load_statuses
@account.suspended? ? [] : cached_account_statuses
@account.unavailable? ? [] : cached_account_statuses
end

def cached_account_statuses
Expand Down
31 changes: 27 additions & 4 deletions app/controllers/api/v2/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class Api::V2::SearchController < Api::BaseController
before_action -> { authorize_if_got_token! :read, :'read:search' }
before_action :validate_search_params!

with_options unless: :user_signed_in? do
before_action :query_pagination_error, if: :pagination_requested?
before_action :remote_resolve_error, if: :remote_resolve_requested?
end

def index
@search = Search.new(search_results)
render json: @search, serializer: REST::SearchSerializer
Expand All @@ -21,20 +26,38 @@ def index

def validate_search_params!
params.require(:q)
end

def query_pagination_error
render json: { error: 'Search queries pagination is not supported without authentication' }, status: 401
end

return if user_signed_in?
def remote_resolve_error
render json: { error: 'Search queries that resolve remote resources are not supported without authentication' }, status: 401
end

return render json: { error: 'Search queries pagination is not supported without authentication' }, status: 401 if params[:offset].present?
def remote_resolve_requested?
truthy_param?(:resolve)
end

render json: { error: 'Search queries that resolve remote resources are not supported without authentication' }, status: 401 if truthy_param?(:resolve)
def pagination_requested?
params[:offset].present?
end

def search_results
SearchService.new.call(
params[:q],
current_account,
limit_param(RESULTS_LIMIT),
search_params.merge(resolve: truthy_param?(:resolve), exclude_unreviewed: truthy_param?(:exclude_unreviewed), following: truthy_param?(:following))
combined_search_params
)
end

def combined_search_params
search_params.merge(
resolve: truthy_param?(:resolve),
exclude_unreviewed: truthy_param?(:exclude_unreviewed),
following: truthy_param?(:following)
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/confirmations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Auth::ConfirmationsController < Devise::ConfirmationsController
include CaptchaConcern
include Auth::CaptchaConcern

layout 'auth'

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Auth::RegistrationsController < Devise::RegistrationsController
include RegistrationHelper
include RegistrationSpamConcern
include Auth::RegistrationSpamConcern

layout :determine_layout

Expand Down Expand Up @@ -120,7 +120,7 @@ def set_strikes
end

def require_not_suspended!
forbidden if current_account.suspended?
forbidden if current_account.unavailable?
end

def set_rules
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Auth::SessionsController < Devise::SessionsController

prepend_before_action :check_suspicious!, only: [:create]

include TwoFactorAuthenticationConcern
include Auth::TwoFactorAuthenticationConcern

before_action :set_body_classes

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/concerns/account_owned_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def check_account_confirmation
end

def check_account_suspension
if @account.suspended_permanently?
permanent_suspension_response
if @account.permanently_unavailable?
permanent_unavailability_response
elsif @account.suspended? && !skip_temporary_suspension_response?
temporary_suspension_response
end
Expand All @@ -45,7 +45,7 @@ def skip_temporary_suspension_response?
false
end

def permanent_suspension_response
def permanent_unavailability_response
expires_in(3.minutes, public: true)
gone
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module AdminExportControllerConcern
module Admin::ExportControllerConcern
extend ActiveSupport::Concern

private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module AccessTokenTrackingConcern
module Api::AccessTokenTrackingConcern
extend ActiveSupport::Concern

ACCESS_TOKEN_UPDATE_FREQUENCY = 24.hours.freeze
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ApiCachingConcern
module Api::CachingConcern
extend ActiveSupport::Concern

def cache_if_unauthenticated!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module RateLimitHeaders
module Api::RateLimitHeaders
extend ActiveSupport::Concern

class_methods do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module CaptchaConcern
module Auth::CaptchaConcern
extend ActiveSupport::Concern

include Hcaptcha::Adapters::ViewMethods
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module RegistrationSpamConcern
module Auth::RegistrationSpamConcern
extend ActiveSupport::Concern

def set_registration_form_time
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module TwoFactorAuthenticationConcern
module Auth::TwoFactorAuthenticationConcern
extend ActiveSupport::Concern

included do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ExportControllerConcern
module Settings::ExportControllerConcern
extend ActiveSupport::Concern

included do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def store_current_location
end

def require_not_suspended!
forbidden if current_account.suspended?
forbidden if current_account.unavailable?
end

def set_cache_headers
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/settings/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def set_cache_headers
end

def require_not_suspended!
forbidden if current_account.suspended?
forbidden if current_account.unavailable?
end
end
2 changes: 1 addition & 1 deletion app/controllers/settings/deletes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def resource_params
end

def require_not_suspended!
forbidden if current_account.suspended?
forbidden if current_account.unavailable?
end

def challenge_passed?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Settings
module Exports
class BlockedAccountsController < BaseController
include ExportControllerConcern
include Settings::ExportControllerConcern

def index
send_export_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Settings
module Exports
class BlockedDomainsController < BaseController
include ExportControllerConcern
include Settings::ExportControllerConcern

def index
send_export_file
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/settings/exports/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Settings
module Exports
class BookmarksController < BaseController
include ExportControllerConcern
include Settings::ExportControllerConcern

def index
send_export_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Settings
module Exports
class FollowingAccountsController < BaseController
include ExportControllerConcern
include Settings::ExportControllerConcern

def index
send_export_file
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/settings/exports/lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Settings
module Exports
class ListsController < BaseController
include ExportControllerConcern
include Settings::ExportControllerConcern

def index
send_export_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Settings
module Exports
class MutedAccountsController < BaseController
include ExportControllerConcern
include Settings::ExportControllerConcern

def index
send_export_file
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/well_known/webfinger_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def resource_param
end

def check_account_suspension
gone if @account.suspended_permanently?
gone if @account.permanently_unavailable?
end

def gone
Expand Down
Loading

0 comments on commit 291faa5

Please sign in to comment.