Class: EmailsOnPushWorker
- Inherits:
-
Object
- Object
- EmailsOnPushWorker
- Includes:
- ApplicationWorker
- Defined in:
- app/workers/emails_on_push_worker.rb
Overview
rubocop:disable Scalability/IdempotentWorker
Constant Summary
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#skip_premailer ⇒ Object
readonly
Returns the value of attribute skip_premailer.
Instance Method Summary collapse
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
10 11 12 |
# File 'app/workers/emails_on_push_worker.rb', line 10 def email @email end |
#skip_premailer ⇒ Object (readonly)
Returns the value of attribute skip_premailer.
10 11 12 |
# File 'app/workers/emails_on_push_worker.rb', line 10 def skip_premailer @skip_premailer end |
Instance Method Details
#perform(project_id, recipients, push_data, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/workers/emails_on_push_worker.rb', line 17 def perform(project_id, recipients, push_data, = {}) .symbolize_keys! .reverse_merge!( send_from_committer_email: false, disable_diffs: false ) send_from_committer_email = [:send_from_committer_email] disable_diffs = [:disable_diffs] project = Project.find(project_id) before_sha = push_data["before"] after_sha = push_data["after"] ref = push_data["ref"] = push_data["user_id"] action = if Gitlab::Git.blank_ref?(before_sha) :create elsif Gitlab::Git.blank_ref?(after_sha) :delete else :push end diff_refs = nil compare = nil reverse_compare = false if action == :push compare = CompareService.new(project, after_sha) .execute(project, before_sha) diff_refs = compare.diff_refs return false if compare.same if compare.commits.empty? compare = CompareService.new(project, before_sha) .execute(project, after_sha) diff_refs = compare.diff_refs reverse_compare = true return false if compare.commits.empty? end end Integrations::EmailsOnPush.valid_recipients(recipients).each do |recipient| send_email( recipient, project_id, author_id: , ref: ref, action: action, compare: compare, reverse_compare: reverse_compare, diff_refs: diff_refs, send_from_committer_email: send_from_committer_email, disable_diffs: disable_diffs ) # These are input errors and won't be corrected even if Sidekiq retries rescue Net::SMTPFatalError, Net::SMTPSyntaxError => e logger.info("Failed to send e-mail for project '#{project.full_name}' to #{recipient}: #{e}") end ensure @email = nil compare = nil GC.start end |