From 620d0d80293bef80753ecfcec1c4c5226e67cd6d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 19 May 2017 01:14:30 +0200 Subject: Account domain blocks (#2381) * Add tag to Atom input/output Only uses ref attribute (not href) because href would be the alternate link that's always included also. Creates new conversation for every non-reply status. Carries over conversation for every reply. Keeps remote URIs verbatim, generates local URIs on the fly like the rest of them. * Conversation muting - prevents notifications that reference a conversation (including replies, favourites, reblogs) from being created. API endpoints /api/v1/statuses/:id/mute and /api/v1/statuses/:id/unmute Currently no way to tell when a status/conversation is muted, so the web UI only has a "disable notifications" button, doesn't work as a toggle * Display "Dismiss notifications" on all statuses in notifications column, not just own * Add "muted" as a boolean attribute on statuses JSON For now always false on contained reblogs, since it's only relevant for statuses returned from the notifications endpoint, which are not nested Remove "Disable notifications" from detailed status view, since it's only relevant in the notifications column * Up max class length * Remove pending test for conversation mute * Add tests, clean up * Rename to "mute conversation" and "unmute conversation" * Raise validation error when trying to mute/unmute status without conversation * Adding account domain blocks that filter notifications and public timelines * Add tests for domain blocks in notifications, public timelines Filter reblogs of blocked domains from home * Add API for listing and creating account domain blocks * API for creating/deleting domain blocks, tests for Status#ancestors and Status#descendants, filter domain blocks from them * Filter domains in streaming API * Update account_domain_block_spec.rb --- app/controllers/api/v1/domain_blocks_controller.rb | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/controllers/api/v1/domain_blocks_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/api/v1/domain_blocks_controller.rb b/app/controllers/api/v1/domain_blocks_controller.rb new file mode 100644 index 000000000..e14547911 --- /dev/null +++ b/app/controllers/api/v1/domain_blocks_controller.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class Api::V1::DomainBlocksController < ApiController + before_action -> { doorkeeper_authorize! :follow } + before_action :require_user! + + respond_to :json + + def show + @blocks = AccountDomainBlock.where(account: current_account).paginate_by_max_id(limit_param(100), params[:max_id], params[:since_id]) + + next_path = api_v1_domain_blocks_url(pagination_params(max_id: @blocks.last.id)) if @blocks.size == limit_param(100) + prev_path = api_v1_domain_blocks_url(pagination_params(since_id: @blocks.first.id)) unless @blocks.empty? + + set_pagination_headers(next_path, prev_path) + render json: @blocks.map(&:domain) + end + + def create + current_account.block_domain!(domain_block_params[:domain]) + render_empty + end + + def destroy + current_account.unblock_domain!(domain_block_params[:domain]) + render_empty + end + + private + + def pagination_params(core_params) + params.permit(:limit).merge(core_params) + end + + def domain_block_params + params.permit(:domain) + end +end -- cgit