Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.github/dependabot.yml`: Upstream made changes while we have dropped this file. Keep the file deleted. - `.prettierignore`: Upstream made changes at the end of the file, where we had our extra lines. Just moved our extra lines back at the end. - `app/serializers/initial_state_serializer.rb`: Upstream code style changes. Applied them. - `app/services/backup_service.rb`: Upstream code style changes. Applied them.
This commit is contained in:
@@ -18,13 +18,11 @@ module Admin
|
||||
private
|
||||
|
||||
def redis_info
|
||||
@redis_info ||= begin
|
||||
if redis.is_a?(Redis::Namespace)
|
||||
redis.redis.info
|
||||
else
|
||||
redis.info
|
||||
end
|
||||
end
|
||||
@redis_info ||= if redis.is_a?(Redis::Namespace)
|
||||
redis.redis.info
|
||||
else
|
||||
redis.info
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -90,9 +90,7 @@ module Admin
|
||||
end
|
||||
|
||||
def action_from_button
|
||||
if params[:save]
|
||||
'save'
|
||||
end
|
||||
'save' if params[:save]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -45,15 +45,11 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_account_followers_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_account_followers_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @accounts.empty?
|
||||
api_v1_account_followers_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_account_followers_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -45,15 +45,11 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_account_following_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @accounts.empty?
|
||||
api_v1_account_following_index_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_account_following_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -39,15 +39,11 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_account_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @statuses.empty?
|
||||
api_v1_account_statuses_url pagination_params(min_id: pagination_since_id)
|
||||
end
|
||||
api_v1_account_statuses_url pagination_params(min_id: pagination_since_id) unless @statuses.empty?
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
|
@@ -120,9 +120,7 @@ class Api::V1::Admin::AccountsController < Api::BaseController
|
||||
translated_params[:status] = status.to_s if params[status].present?
|
||||
end
|
||||
|
||||
if params[:staff].present?
|
||||
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id)
|
||||
end
|
||||
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id) if params[:staff].present?
|
||||
|
||||
translated_params
|
||||
end
|
||||
|
@@ -18,9 +18,7 @@ class Api::V1::AnnouncementsController < Api::BaseController
|
||||
private
|
||||
|
||||
def set_announcements
|
||||
@announcements = begin
|
||||
Announcement.published.chronological
|
||||
end
|
||||
@announcements = Announcement.published.chronological
|
||||
end
|
||||
|
||||
def set_announcement
|
||||
|
@@ -33,15 +33,11 @@ class Api::V1::BlocksController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_blocks_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless paginated_blocks.empty?
|
||||
api_v1_blocks_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_blocks_url pagination_params(since_id: pagination_since_id) unless paginated_blocks.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -40,15 +40,11 @@ class Api::V1::ConversationsController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_conversations_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_conversations_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @conversations.empty?
|
||||
api_v1_conversations_url pagination_params(min_id: pagination_since_id)
|
||||
end
|
||||
api_v1_conversations_url pagination_params(min_id: pagination_since_id) unless @conversations.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -43,15 +43,11 @@ class Api::V1::DomainBlocksController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_domain_blocks_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @blocks.empty?
|
||||
api_v1_domain_blocks_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_domain_blocks_url pagination_params(since_id: pagination_since_id) unless @blocks.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -35,17 +35,13 @@ class Api::V1::EndorsementsController < Api::BaseController
|
||||
def next_path
|
||||
return if unlimited?
|
||||
|
||||
if records_continue?
|
||||
api_v1_endorsements_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_endorsements_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
return if unlimited?
|
||||
|
||||
unless @accounts.empty?
|
||||
api_v1_endorsements_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_endorsements_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -36,15 +36,11 @@ class Api::V1::FavouritesController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_favourites_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_favourites_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless results.empty?
|
||||
api_v1_favourites_url pagination_params(min_id: pagination_since_id)
|
||||
end
|
||||
api_v1_favourites_url pagination_params(min_id: pagination_since_id) unless results.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -53,15 +53,11 @@ class Api::V1::FollowRequestsController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_follow_requests_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @accounts.empty?
|
||||
api_v1_follow_requests_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_follow_requests_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -62,17 +62,13 @@ class Api::V1::Lists::AccountsController < Api::BaseController
|
||||
def next_path
|
||||
return if unlimited?
|
||||
|
||||
if records_continue?
|
||||
api_v1_list_accounts_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_list_accounts_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
return if unlimited?
|
||||
|
||||
unless @accounts.empty?
|
||||
api_v1_list_accounts_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_list_accounts_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -33,15 +33,11 @@ class Api::V1::MutesController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_mutes_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_mutes_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless paginated_mutes.empty?
|
||||
api_v1_mutes_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_mutes_url pagination_params(since_id: pagination_since_id) unless paginated_mutes.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -67,15 +67,11 @@ class Api::V1::NotificationsController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
unless @notifications.empty?
|
||||
api_v1_notifications_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_notifications_url pagination_params(max_id: pagination_max_id) unless @notifications.empty?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @notifications.empty?
|
||||
api_v1_notifications_url pagination_params(min_id: pagination_since_id)
|
||||
end
|
||||
api_v1_notifications_url pagination_params(min_id: pagination_since_id) unless @notifications.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -52,15 +52,11 @@ class Api::V1::ScheduledStatusesController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_scheduled_statuses_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @statuses.empty?
|
||||
api_v1_scheduled_statuses_url pagination_params(min_id: pagination_since_id)
|
||||
end
|
||||
api_v1_scheduled_statuses_url pagination_params(min_id: pagination_since_id) unless @statuses.empty?
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
|
@@ -41,15 +41,11 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_status_favourited_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @accounts.empty?
|
||||
api_v1_status_favourited_by_index_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_status_favourited_by_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -37,15 +37,11 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless @accounts.empty?
|
||||
api_v1_status_reblogged_by_index_url pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
api_v1_status_reblogged_by_index_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
|
@@ -18,13 +18,11 @@ class Api::V1::Trends::LinksController < Api::BaseController
|
||||
end
|
||||
|
||||
def set_links
|
||||
@links = begin
|
||||
if enabled?
|
||||
links_from_trends.offset(offset_param).limit(limit_param(DEFAULT_LINKS_LIMIT))
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
@links = if enabled?
|
||||
links_from_trends.offset(offset_param).limit(limit_param(DEFAULT_LINKS_LIMIT))
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def links_from_trends
|
||||
|
@@ -16,13 +16,11 @@ class Api::V1::Trends::StatusesController < Api::BaseController
|
||||
end
|
||||
|
||||
def set_statuses
|
||||
@statuses = begin
|
||||
if enabled?
|
||||
cache_collection(statuses_from_trends.offset(offset_param).limit(limit_param(DEFAULT_STATUSES_LIMIT)), Status)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
@statuses = if enabled?
|
||||
cache_collection(statuses_from_trends.offset(offset_param).limit(limit_param(DEFAULT_STATUSES_LIMIT)), Status)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def statuses_from_trends
|
||||
|
@@ -18,13 +18,11 @@ class Api::V1::Trends::TagsController < Api::BaseController
|
||||
end
|
||||
|
||||
def set_tags
|
||||
@tags = begin
|
||||
if enabled?
|
||||
tags_from_trends.offset(offset_param).limit(limit_param(DEFAULT_TAGS_LIMIT))
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
@tags = if enabled?
|
||||
tags_from_trends.offset(offset_param).limit(limit_param(DEFAULT_TAGS_LIMIT))
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def tags_from_trends
|
||||
|
@@ -25,9 +25,7 @@ class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController
|
||||
def translated_filter_params
|
||||
translated_params = filter_params.slice(*AccountFilter::KEYS)
|
||||
|
||||
if params[:permissions] == 'staff'
|
||||
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id)
|
||||
end
|
||||
translated_params[:role_ids] = UserRole.that_can(:manage_reports).map(&:id) if params[:permissions] == 'staff'
|
||||
|
||||
translated_params
|
||||
end
|
||||
|
@@ -31,9 +31,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
def update
|
||||
super do |resource|
|
||||
if resource.saved_change_to_encrypted_password?
|
||||
resource.clear_other_sessions(current_session.session_id)
|
||||
end
|
||||
resource.clear_other_sessions(current_session.session_id) if resource.saved_change_to_encrypted_password?
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -115,9 +115,7 @@ class Auth::SessionsController < Devise::SessionsController
|
||||
def home_paths(resource)
|
||||
paths = [about_path]
|
||||
|
||||
if single_user_mode? && resource.is_a?(User)
|
||||
paths << short_account_path(username: resource.account)
|
||||
end
|
||||
paths << short_account_path(username: resource.account) if single_user_mode? && resource.is_a?(User)
|
||||
|
||||
paths
|
||||
end
|
||||
|
@@ -6,13 +6,11 @@ module RateLimitHeaders
|
||||
class_methods do
|
||||
def override_rate_limit_headers(method_name, options = {})
|
||||
around_action(only: method_name, if: :current_account) do |_controller, block|
|
||||
begin
|
||||
block.call
|
||||
ensure
|
||||
rate_limiter = RateLimiter.new(current_account, options)
|
||||
rate_limit_headers = rate_limiter.to_headers
|
||||
response.headers.merge!(rate_limit_headers) unless response.headers['X-RateLimit-Remaining'].present? && rate_limit_headers['X-RateLimit-Remaining'].to_i > response.headers['X-RateLimit-Remaining'].to_i
|
||||
end
|
||||
block.call
|
||||
ensure
|
||||
rate_limiter = RateLimiter.new(current_account, options)
|
||||
rate_limit_headers = rate_limiter.to_headers
|
||||
response.headers.merge!(rate_limit_headers) unless response.headers['X-RateLimit-Remaining'].present? && rate_limit_headers['X-RateLimit-Remaining'].to_i > response.headers['X-RateLimit-Remaining'].to_i
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -67,6 +65,6 @@ module RateLimitHeaders
|
||||
end
|
||||
|
||||
def reset_period_offset
|
||||
api_throttle_data[:period] - request_time.to_i % api_throttle_data[:period]
|
||||
api_throttle_data[:period] - (request_time.to_i % api_throttle_data[:period])
|
||||
end
|
||||
end
|
||||
|
@@ -81,13 +81,11 @@ module TwoFactorAuthenticationConcern
|
||||
|
||||
@body_classes = 'lighter'
|
||||
@webauthn_enabled = user.webauthn_enabled?
|
||||
@scheme_type = begin
|
||||
if user.webauthn_enabled? && user_params[:otp_attempt].blank?
|
||||
'webauthn'
|
||||
else
|
||||
'totp'
|
||||
end
|
||||
end
|
||||
@scheme_type = if user.webauthn_enabled? && user_params[:otp_attempt].blank?
|
||||
'webauthn'
|
||||
else
|
||||
'totp'
|
||||
end
|
||||
|
||||
set_locale { render :two_factor }
|
||||
end
|
||||
|
@@ -43,9 +43,7 @@ class Filters::StatusesController < ApplicationController
|
||||
end
|
||||
|
||||
def action_from_button
|
||||
if params[:remove]
|
||||
'remove'
|
||||
end
|
||||
'remove' if params[:remove]
|
||||
end
|
||||
|
||||
def set_body_classes
|
||||
|
@@ -58,7 +58,7 @@ class TagsController < ApplicationController
|
||||
def collection_presenter
|
||||
ActivityPub::CollectionPresenter.new(
|
||||
id: tag_url(@tag),
|
||||
type: :ordered,
|
||||
type: :ordered
|
||||
)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user