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
1 changed files with 3 additions and 3 deletions

View File

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