Newer
Older
# frozen_string_literal: true
before_action :authenticate_user!
respond_to do |format|
format.json { head :no_content }
format.any { redirect_back fallback_location: root_path }
def destroy
block = current_user.blocks.find_by(id: params[:id])
notice = if block&.delete
ContactRetraction.for(block).defer_dispatch(current_user)
{notice: t("blocks.destroy.success")}
else
{error: t("blocks.destroy.failure")}
end
respond_to do |format|
format.json { head :no_content }
format.any { redirect_back fallback_location: privacy_settings_path, flash: notice }
end
def send_message(block)
contact = current_user.contact_for(block.person)
if contact
current_user.disconnect(contact)
elsif block.person.remote?
Diaspora::Federation::Dispatcher.defer_dispatch(current_user, block)
end
def block_params
params.require(:block).permit(:person_id)
end