Class: Members::ExpiringEmailNotificationWorker
- Inherits:
-
Object
- Object
- Members::ExpiringEmailNotificationWorker
- Includes:
- ApplicationWorker, CronjobChildWorker
- Defined in:
- app/workers/members/expiring_email_notification_worker.rb
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_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Attribute Summary collapse
-
#member ⇒ Object
readonly
Returns the value of attribute member.
Instance Method Summary collapse
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Attribute Details
#member ⇒ Object (readonly)
Returns the value of attribute member.
13 14 15 |
# File 'app/workers/members/expiring_email_notification_worker.rb', line 13 def member @member end |
Instance Method Details
#perform(member_id) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/workers/members/expiring_email_notification_worker.rb', line 15 def perform(member_id) member = ::Member.including_user.including_source.find_by_id(member_id) return unless valid_for_notification?(member) with_context(user: member.user) do Members::AboutToExpireMailer.with(member: member).email.deliver_later # rubocop:disable CodeReuse/ActiveRecord -- false positive Gitlab::AppLogger.info(message: "Notifying user about expiring membership", member_id: member.id) member.update(expiry_notified_at: Time.current) end end |
#valid_for_notification?(member) ⇒ Boolean
28 29 30 31 32 33 |
# File 'app/workers/members/expiring_email_notification_worker.rb', line 28 def valid_for_notification?(member) member.expiry_notified_at.blank? && member&.user.present? && member.user.active? && member.user.human? end |