From 72906ca549f427036616672eda6022b4230d1fe7 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Mon, 24 Jan 2022 22:46:11 +0100 Subject: [PATCH] Fix lint errors --- app/controllers/ajax/question_controller.rb | 12 ++++++------ app/controllers/ajax_controller.rb | 2 +- app/workers/question_worker.rb | 6 +++--- lib/use_case/question/create.rb | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/ajax/question_controller.rb b/app/controllers/ajax/question_controller.rb index 48c8d389..e2963804 100644 --- a/app/controllers/ajax/question_controller.rb +++ b/app/controllers/ajax/question_controller.rb @@ -43,18 +43,18 @@ class Ajax::QuestionController < AjaxController if user_signed_in? && params[:rcpt] == "followers" UseCase::Question::CreateFollowers.call( - source_user_id: current_user.id, - content: params[:question], + source_user_id: current_user.id, + content: params[:question], author_identifier: AnonymousBlock.get_identifier(request.ip) ) return end UseCase::Question::Create.call( - source_user_id: user_signed_in? ? current_user.id : nil, - target_user_id: params[:rcpt], - content: params[:question], - anonymous: params[:anonymousQuestion], + source_user_id: user_signed_in? ? current_user.id : nil, + target_user_id: params[:rcpt], + content: params[:question], + anonymous: params[:anonymousQuestion], author_identifier: AnonymousBlock.get_identifier(request.ip) ) end diff --git a/app/controllers/ajax_controller.rb b/app/controllers/ajax_controller.rb index 5085ba00..f6718de0 100644 --- a/app/controllers/ajax_controller.rb +++ b/app/controllers/ajax_controller.rb @@ -26,7 +26,7 @@ class AjaxController < ApplicationController @response = { success: false, message: e.message, - status: e.code + status: e.code } return_response diff --git a/app/workers/question_worker.rb b/app/workers/question_worker.rb index cb13edf6..0416244a 100644 --- a/app/workers/question_worker.rb +++ b/app/workers/question_worker.rb @@ -12,9 +12,9 @@ class QuestionWorker question = Question.find(question_id) user.followers.each do |f| - if MuteRule.where(user: f).none? { |rule| rule.applies_to? question } - Inbox.create(user_id: f.id, question_id: question_id, new: true) - end + next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question } + + Inbox.create(user_id: f.id, question_id: question_id, new: true) end rescue StandardError => e logger.info "failed to ask question: #{e.message}" diff --git a/lib/use_case/question/create.rb b/lib/use_case/question/create.rb index 8a120865..1cf6b5d9 100644 --- a/lib/use_case/question/create.rb +++ b/lib/use_case/question/create.rb @@ -48,10 +48,10 @@ module UseCase end def check_blocks - if source_user_id.present? - raise Errors::AskingOtherBlockedSelf if target_user.blocking?(source_user) - raise Errors::AskingSelfBlockedOther if source_user.blocking?(target_user) - end + return if source_user_id.blank? + + raise Errors::AskingOtherBlockedSelf if target_user.blocking?(source_user) + raise Errors::AskingSelfBlockedOther if source_user.blocking?(target_user) end def increment_asked_count