Crowdin / Upload translations / upload-translations (push) Skipped
Historical data migration test / test (14-alpine) (push) Canceled after 0s
Historical data migration test / test (15-alpine) (push) Canceled after 0s
Historical data migration test / test (16-alpine) (push) Canceled after 0s
Historical data migration test / test (17-alpine) (push) Canceled after 0s
Bundler Audit / security (push) Canceled after 0s
Haml Linting / lint (push) Canceled after 0s
JavaScript Linting / lint (push) Canceled after 0s
Ruby Linting / lint (push) Canceled after 0s
JavaScript Testing / test (push) Canceled after 0s
Ruby Testing / build (production) (push) Canceled after 0s
Ruby Testing / test (.ruby-version) (push) Canceled after 0s
Ruby Testing / test (3.3) (push) Canceled after 0s
Ruby Testing / test (3.4) (push) Canceled after 0s
Ruby Testing / End to End testing (.ruby-version) (push) Canceled after 0s
Ruby Testing / End to End testing (3.3) (push) Canceled after 0s
Ruby Testing / End to End testing (3.4) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check i18n / check-i18n (push) Canceled after 0s
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (javascript) (push) Canceled after 0s
CodeQL / Analyze (ruby) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check formatting / lint (push) Canceled after 0s
CSS Linting / lint (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Canceled after 0s
Chromatic / Check for relevant changes (push) Canceled after 0s
Chromatic / Run Chromatic (push) Canceled after 0s
Snapshot of upstream tag v4.7.3 (commit 8ff11c2bb7b9f0714e947b10fa3629c6542c7121) from https://github.com/mastodon/mastodon, unmodified.
86 lines
2.5 KiB
Ruby
86 lines
2.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Admin
|
|
class InstancesController < BaseController
|
|
before_action :set_instances, only: :index
|
|
before_action :set_instance, except: :index
|
|
|
|
LOGS_LIMIT = 5
|
|
|
|
def index
|
|
authorize :instance, :index?
|
|
preload_delivery_failures!
|
|
end
|
|
|
|
def show
|
|
authorize :instance, :show?
|
|
|
|
@instance_moderation_note = @instance.moderation_notes.new
|
|
@instance_moderation_notes = @instance.moderation_notes.includes(:account).chronological
|
|
@time_period = (6.days.ago.to_date..Time.now.utc.to_date)
|
|
@action_logs = Admin::ActionLogFilter.new(target_domain: @instance.domain).results.limit(LOGS_LIMIT)
|
|
end
|
|
|
|
def destroy
|
|
authorize :instance, :destroy?
|
|
Admin::DomainPurgeWorker.perform_async(@instance.domain)
|
|
log_action :destroy, @instance
|
|
redirect_to admin_instances_path, notice: I18n.t('admin.instances.destroyed_msg', domain: @instance.domain)
|
|
end
|
|
|
|
def clear_delivery_errors
|
|
authorize :delivery, :clear_delivery_errors?
|
|
@instance.delivery_failure_tracker.clear_failures!
|
|
redirect_to admin_instance_path(@instance.domain)
|
|
end
|
|
|
|
def restart_delivery
|
|
authorize :delivery, :restart_delivery?
|
|
|
|
if @instance.unavailable?
|
|
@instance.delivery_failure_tracker.track_success!
|
|
log_action :destroy, @instance.unavailable_domain
|
|
end
|
|
|
|
redirect_to admin_instance_path(@instance.domain)
|
|
end
|
|
|
|
def stop_delivery
|
|
authorize :delivery, :stop_delivery?
|
|
unavailable_domain = UnavailableDomain.create!(domain: @instance.domain)
|
|
log_action :create, unavailable_domain
|
|
redirect_to admin_instance_path(@instance.domain)
|
|
end
|
|
|
|
private
|
|
|
|
def set_instance
|
|
@instance = Instance.find_or_initialize_by(domain: normalized_domain)
|
|
end
|
|
|
|
def normalized_domain
|
|
TagManager.instance.normalize_domain(params[:id])
|
|
end
|
|
|
|
def set_instances
|
|
@instances = filtered_instances.page(params[:page])
|
|
end
|
|
|
|
def preload_delivery_failures!
|
|
warning_domains_map = DeliveryFailureTracker.warning_domains_map(@instances.map(&:domain))
|
|
|
|
@instances.each do |instance|
|
|
instance.failure_days = warning_domains_map[instance.domain]
|
|
end
|
|
end
|
|
|
|
def filtered_instances
|
|
InstanceFilter.new(limited_federation_mode? ? { allowed: true } : filter_params).results
|
|
end
|
|
|
|
def filter_params
|
|
params.slice(*InstanceFilter::KEYS).permit(*InstanceFilter::KEYS)
|
|
end
|
|
end
|
|
end
|