Add endpoint for removing anon blocks
This commit is contained in:
parent
f379845615
commit
7e98f427c6
|
@ -13,12 +13,23 @@ class Ajax::AnonymousBlockController < AjaxController
|
||||||
question.inboxes.first.destroy
|
question.inboxes.first.destroy
|
||||||
|
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:message] = I18n.t('messages.block.create.okay')
|
@response[:message] = I18n.t("messages.block.create.okay")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
|
end
|
||||||
|
|
||||||
rescue Errors::Base => e
|
def destroy
|
||||||
@response[:status] = e.code
|
params.require :id
|
||||||
@response[:message] = I18n.t(e.locale_tag)
|
|
||||||
@response[:success] = false
|
block = AnonymousBlock.find(params[:id])
|
||||||
|
if current_user != block.user
|
||||||
|
@response[:status] = :nopriv
|
||||||
|
@response[:message] = I18n.t("messages.block.destroy.nopriv")
|
||||||
|
end
|
||||||
|
|
||||||
|
block.destroy!
|
||||||
|
|
||||||
|
@response[:status] = :okay
|
||||||
|
@response[:message] = I18n.t("messages.block.create.okay")
|
||||||
|
@response[:success] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,6 +86,7 @@ en:
|
||||||
destroy:
|
destroy:
|
||||||
fail: "You are not blocking that user."
|
fail: "You are not blocking that user."
|
||||||
okay: "Successfully unblocked user."
|
okay: "Successfully unblocked user."
|
||||||
|
nopriv: "Cannot remove a block belonging to someone else."
|
||||||
list:
|
list:
|
||||||
create:
|
create:
|
||||||
noname: "Please give that list a name."
|
noname: "Please give that list a name."
|
||||||
|
|
|
@ -119,6 +119,7 @@ Rails.application.routes.draw do
|
||||||
match '/mute/:id', to: 'mute_rule#update', via: :post, as: :update_mute_rule
|
match '/mute/:id', to: 'mute_rule#update', via: :post, as: :update_mute_rule
|
||||||
match '/mute/:id', to: 'mute_rule#destroy', via: :delete, as: :delete_mute_rule
|
match '/mute/:id', to: 'mute_rule#destroy', via: :delete, as: :delete_mute_rule
|
||||||
match '/block_anon', to: 'anonymous_block#create', via: :post, as: :block_anon
|
match '/block_anon', to: 'anonymous_block#create', via: :post, as: :block_anon
|
||||||
|
match '/block_anon/:id', to: 'anonymous_block#destroy', via: :delete, as: :unblock_anon
|
||||||
end
|
end
|
||||||
|
|
||||||
match '/discover', to: 'discover#index', via: :get, as: :discover
|
match '/discover', to: 'discover#index', via: :get, as: :discover
|
||||||
|
|
Loading…
Reference in New Issue