Update question controller block handling to account for users not being logged in

This commit is contained in:
Karina Kwiatek 2022-06-12 09:28:40 +02:00 committed by Karina Kwiatek
parent c6c3c32260
commit ea3bbcef17

View file

@ -57,9 +57,6 @@ class Ajax::QuestionController < AjaxController
else
target_user = User.find_by(id: params[:rcpt])
raise Errors::AskingOtherBlockedSelf if target_user.blocking?(current_user)
raise Errors::AskingSelfBlockedOther if current_user.blocking?(target_user)
if target_user.nil?
@response[:status] = :not_found
@response[:message] = I18n.t('messages.question.create.not_found')
@ -67,6 +64,9 @@ class Ajax::QuestionController < AjaxController
return
end
raise Errors::AskingOtherBlockedSelf if target_user.blocking?(current_user)
raise Errors::AskingSelfBlockedOther if current_user&.blocking?(target_user)
if !target_user.privacy_allow_anonymous_questions && question.author_is_anonymous
question.delete
return