From 56799f60c75fc8c57f646257254c2c6ad97bb8a4 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Thu, 9 Jun 2022 19:55:56 +0200 Subject: [PATCH] Disallow adding blocked users to lists --- app/controllers/ajax/list_controller.rb | 3 +++ lib/errors.rb | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/app/controllers/ajax/list_controller.rb b/app/controllers/ajax/list_controller.rb index e934f497..c952cb59 100644 --- a/app/controllers/ajax/list_controller.rb +++ b/app/controllers/ajax/list_controller.rb @@ -95,6 +95,9 @@ class Ajax::ListController < AjaxController target_user = User.find_by_screen_name!(params[:user]) + raise Errors::ListingSelfBlockedOther if current_user.blocking?(target_user) + raise Errors::ListingOtherBlockedSelf if target_user.blocking?(current_user) + if add list.add_member target_user if list.members.find_by_user_id(target_user.id).nil? @response[:checked] = true diff --git a/lib/errors.rb b/lib/errors.rb index b577491e..10cb15cd 100644 --- a/lib/errors.rb +++ b/lib/errors.rb @@ -85,5 +85,11 @@ module Errors class ReactingOtherBlockedSelf < OtherBlockedSelf end + + class ListingSelfBlockedOther < SelfBlockedOther + end + + class ListingOtherBlockedSelf < OtherBlockedSelf + end # endregion end