From 440a1ce6ff8c7dfea18651413d44c47d4cdd4379 Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Mon, 1 Feb 2021 03:43:56 -0500 Subject: [PATCH] Minor changes to workers. --- app/workers/introduce_account_pro_worker.rb | 1 + app/workers/local_notification_worker.rb | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/workers/introduce_account_pro_worker.rb b/app/workers/introduce_account_pro_worker.rb index 520faa0b..3dc55f9c 100644 --- a/app/workers/introduce_account_pro_worker.rb +++ b/app/workers/introduce_account_pro_worker.rb @@ -15,6 +15,7 @@ class IntroduceAccountProWorker private def deliver_email(date_range) + return if @acct.nil? or @acct.user.nil? UserMailer.introduce_pro(@acct.user, date_range).deliver_now! @acct.user.touch(:last_emailed_at) end diff --git a/app/workers/local_notification_worker.rb b/app/workers/local_notification_worker.rb index 48635e49..9a4cbe21 100644 --- a/app/workers/local_notification_worker.rb +++ b/app/workers/local_notification_worker.rb @@ -4,13 +4,10 @@ class LocalNotificationWorker include Sidekiq::Worker def perform(receiver_account_id, activity_id = nil, activity_class_name = nil) - if activity_id.nil? && activity_class_name.nil? - activity = Mention.find(receiver_account_id) - receiver = activity.account - else - receiver = Account.find(receiver_account_id) - activity = activity_class_name.constantize.find(activity_id) - end + return true if activity_id.nil? or activity_class_name.nil? + + receiver = Account.find(receiver_account_id) + activity = activity_class_name.constantize.find(activity_id) NotifyService.new.call(receiver, activity) rescue ActiveRecord::RecordNotFound