2022-06-14 14:16:55 -07:00
|
|
|
class Ajax::AnonymousBlockController < AjaxController
|
|
|
|
def create
|
|
|
|
params.require :question
|
|
|
|
|
|
|
|
question = Question.find(params[:question])
|
|
|
|
|
|
|
|
AnonymousBlock.create!(
|
|
|
|
user: current_user,
|
|
|
|
identifier: AnonymousBlock.get_identifier(question.author_identifier),
|
|
|
|
question: question,
|
|
|
|
)
|
|
|
|
|
|
|
|
question.inboxes.first.destroy
|
|
|
|
|
|
|
|
@response[:status] = :okay
|
2022-06-14 14:30:27 -07:00
|
|
|
@response[:message] = I18n.t("messages.block.create.okay")
|
2022-06-14 14:16:55 -07:00
|
|
|
@response[:success] = true
|
2022-06-14 14:30:27 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
params.require :id
|
|
|
|
|
|
|
|
block = AnonymousBlock.find(params[:id])
|
|
|
|
if current_user != block.user
|
|
|
|
@response[:status] = :nopriv
|
|
|
|
@response[:message] = I18n.t("messages.block.destroy.nopriv")
|
|
|
|
end
|
2022-06-14 14:16:55 -07:00
|
|
|
|
2022-06-14 14:30:27 -07:00
|
|
|
block.destroy!
|
|
|
|
|
|
|
|
@response[:status] = :okay
|
|
|
|
@response[:message] = I18n.t("messages.block.create.okay")
|
|
|
|
@response[:success] = true
|
2022-06-14 14:16:55 -07:00
|
|
|
end
|
|
|
|
end
|