diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-01-10 19:12:10 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-01-10 21:00:30 +0100 |
commit | a2a64ecd3e3551707412c47f0d16e484dea25632 (patch) | |
tree | bc4e0b8e0ca2a2735f527bff8bd73421c0ff72dd /app/controllers/admin | |
parent | fb0c906c717f2b21bb63610742a357850142b522 (diff) | |
parent | 70801b850c78d7879182eeba4eae509af42fafeb (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - .eslintrc.yml Removed, as upstream removed it. - app/controllers/admin/statuses_controller.rb Minor code cleanup when porting one of our features. - app/models/account.rb Note length validation has changed upstream. We now use upstream's validation (dropped legacy glitch-soc account metadata stuff) but with configurable limit. - app/services/post_status_service.rb Upstream has added support for scheduled toots, refactoring the code a bit. Adapted our changes to this refactoring. - app/views/stream_entries/_detailed_status.html.haml Not a real conflict, changes too close. - app/views/stream_entries/_simple_status.html.haml Not a real conflict, changes too close.
Diffstat (limited to 'app/controllers/admin')
-rw-r--r-- | app/controllers/admin/domain_blocks_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/admin/followers_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/admin/instances_controller.rb | 27 | ||||
-rw-r--r-- | app/controllers/admin/statuses_controller.rb | 2 |
4 files changed, 19 insertions, 27 deletions
diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index 90c70275a..5f307ddee 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -4,14 +4,9 @@ module Admin class DomainBlocksController < BaseController before_action :set_domain_block, only: [:show, :destroy] - def index - authorize :domain_block, :index? - @domain_blocks = DomainBlock.page(params[:page]) - end - def new authorize :domain_block, :create? - @domain_block = DomainBlock.new + @domain_block = DomainBlock.new(domain: params[:_domain]) end def create @@ -22,7 +17,7 @@ module Admin if @domain_block.save DomainBlockWorker.perform_async(@domain_block.id) log_action :create, @domain_block - redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.created_msg') + redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.created_msg') else render :new end @@ -36,7 +31,7 @@ module Admin authorize @domain_block, :destroy? UnblockDomainService.new.call(@domain_block, retroactive_unblock?) log_action :destroy, @domain_block - redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.destroyed_msg') + redirect_to admin_instances_path(limited: '1'), notice: I18n.t('admin.domain_blocks.destroyed_msg') end private diff --git a/app/controllers/admin/followers_controller.rb b/app/controllers/admin/followers_controller.rb index 819628b20..d826f47c5 100644 --- a/app/controllers/admin/followers_controller.rb +++ b/app/controllers/admin/followers_controller.rb @@ -8,15 +8,11 @@ module Admin def index authorize :account, :index? - @followers = followers.recent.page(params[:page]).per(PER_PAGE) + @followers = @account.followers.local.recent.page(params[:page]).per(PER_PAGE) end def set_account @account = Account.find(params[:account_id]) end - - def followers - Follow.includes(:account).where(target_account: @account) - end end end diff --git a/app/controllers/admin/instances_controller.rb b/app/controllers/admin/instances_controller.rb index 6f8eaf65c..431ce6f4d 100644 --- a/app/controllers/admin/instances_controller.rb +++ b/app/controllers/admin/instances_controller.rb @@ -4,14 +4,21 @@ module Admin class InstancesController < BaseController def index authorize :instance, :index? + @instances = ordered_instances end - def resubscribe - authorize :instance, :resubscribe? - params.require(:by_domain) - Pubsubhubbub::SubscribeWorker.push_bulk(subscribeable_accounts.pluck(:id)) - redirect_to admin_instances_path + def show + authorize :instance, :show? + + @instance = Instance.new(Account.by_domain_accounts.find_by(domain: params[:id]) || DomainBlock.find_by!(domain: params[:id])) + @following_count = Follow.where(account: Account.where(domain: params[:id])).count + @followers_count = Follow.where(target_account: Account.where(domain: params[:id])).count + @reports_count = Report.where(target_account: Account.where(domain: params[:id])).count + @blocks_count = Block.where(target_account: Account.where(domain: params[:id])).count + @available = DeliveryFailureTracker.available?(Account.select(:shared_inbox_url).where(domain: params[:id]).first&.shared_inbox_url) + @media_storage = MediaAttachment.where(account: Account.where(domain: params[:id])).sum(:file_file_size) + @domain_block = DomainBlock.find_by(domain: params[:id]) end private @@ -27,17 +34,11 @@ module Admin helper_method :paginated_instances def ordered_instances - paginated_instances.map { |account| Instance.new(account) } - end - - def subscribeable_accounts - Account.remote.where(protocol: :ostatus).where(domain: params[:by_domain]) + paginated_instances.map { |resource| Instance.new(resource) } end def filter_params - params.permit( - :domain_name - ) + params.permit(:limited) end end end diff --git a/app/controllers/admin/statuses_controller.rb b/app/controllers/admin/statuses_controller.rb index 62f49806c..650195034 100644 --- a/app/controllers/admin/statuses_controller.rb +++ b/app/controllers/admin/statuses_controller.rb @@ -26,7 +26,7 @@ module Admin authorize :status, :index? @statuses = @account.statuses.where(id: params[:id]) - authorize @statuses[0], :show? + authorize @statuses.first, :show? @form = Form::StatusBatch.new end |