Send emails via sidekiq worker

parent 71f7675c
module Emails
module AdminNotification
def send_admin_notification(user_id, subject, body)
@body = body
mail to: recipient(user_id), subject: subject
end
end
end
\ No newline at end of file
class Notify < ActionMailer::Base
include ActionDispatch::Routing::PolymorphicRoutes
include Emails::AdminNotification
include Emails::Issues
include Emails::MergeRequests
include Emails::Notes
......
= simple_format @body
\ No newline at end of file
= h @body
\ No newline at end of file
class AdminEmailsWorker
include Sidekiq::Worker
def perform(recipient_id, subject, body)
recipient_list(recipient_id).pluck(:id).each do |user_id|
Notify.send_admin_notification(user_id, subject, body).deliver
end
end
private
def recipient_list(recipient_id)
case recipient_id
when 'all'
User.where(nil)
when /group-(\d+)\z/
Group.find($1).users
when /project-(\d+)\z/
Project.find($1).users
end
end
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment