before_action :set_account
before_action :set_link_headers
+ before_action :authenticate_user!, only: [:follow, :unfollow]
+ before_action :check_account_suspension
def show
respond_to do |format|
def webfinger_account_url
webfinger_url(resource: "acct:#{@account.acct}@#{Rails.configuration.x.local_domain}")
end
+
+ def check_account_suspension
+ head 410 if @account.suspended?
+ end
end
before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
before_action :set_locale
before_action :set_user_activity
+ before_action :check_suspension, if: :user_signed_in?
def raise_not_found
raise ActionController::RoutingError, "No route matches #{params[:unmatched_route]}"
current_user.touch(:current_sign_in_at) if !current_user.nil? && (current_user.current_sign_in_at.nil? || current_user.current_sign_in_at < 24.hours.ago)
end
+ def check_suspension
+ head 403 if current_user.account.suspended?
+ end
+
protected
def not_found
before_action :authenticate_user!
- def show
- end
+ def show; end
def update
current_user.settings(:notification_emails).follow = user_params[:notification_emails][:follow] == '1'
obfuscate_filename [:account, :avatar]
obfuscate_filename [:account, :header]
- def show
- end
+ def show; end
def update
if @account.update(account_params)
before_action :set_account
before_action :set_stream_entry
before_action :set_link_headers
+ before_action :check_account_suspension
def show
@type = @stream_entry.activity_type.downcase
def set_stream_entry
@stream_entry = @account.stream_entries.find(params[:id])
end
+
+ def check_account_suspension
+ head 410 if @account.suspended?
+ end
end
def call(source_account, uri)
target_account = follow_remote_account_service.call(uri)
- raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id
+ raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
follow = source_account.follow!(target_account)
end
def blocked?
- blocked = false
- blocked ||= @recipient.id == @notification.from_account.id
- blocked ||= @recipient.blocking?(@notification.from_account)
- blocked ||= (@notification.from_account.silenced? && !@recipient.following?(@notification.from_account))
- blocked ||= (@recipient.user.settings(:interactions).must_be_follower && !@notification.from_account.following?(@recipient))
- blocked ||= (@recipient.user.settings(:interactions).must_be_following && !@recipient.following?(@notification.from_account))
- blocked ||= send("blocked_#{@notification.type}?")
+ blocked = @recipient.suspended? # Skip if the recipient account is suspended anyway
+ blocked ||= @recipient.id == @notification.from_account.id # Skip for interactions with self
+ blocked ||= @recipient.blocking?(@notification.from_account) # Skip for blocked accounts
+ blocked ||= (@notification.from_account.silenced? && !@recipient.following?(@notification.from_account)) # Hellban
+ blocked ||= (@recipient.user.settings(:interactions).must_be_follower && !@notification.from_account.following?(@recipient)) # Options
+ blocked ||= (@recipient.user.settings(:interactions).must_be_following && !@recipient.following?(@notification.from_account)) # Options
+ blocked ||= send("blocked_#{@notification.type}?") # Type-dependent filters
blocked
end
--- /dev/null
+# frozen_string_literal: true
+
+class Admin::SuspensionWorker
+ include Sidekiq::Worker
+
+ def perform(account_id)
+ SuspendAccountService.new.call(Account.find(account_id))
+ end
+end