Class: Activity::VoicemailReadHandler
- Inherits:
-
Object
- Object
- Activity::VoicemailReadHandler
- Defined in:
- app/subscribers/activity/voicemail_read_handler.rb
Overview
Marks the linked call record voicemail as read when a voicemail activity is
completed. Only fires when the activity has a linked call_record_id and the
activity_result_type_id just changed (i.e. the activity was closed/completed).
Subscribes to: Events::ActivityUpdated
Instance Method Summary collapse
Instance Method Details
#call(event) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/subscribers/activity/voicemail_read_handler.rb', line 9 def call(event) return unless event.data[:activity_result_type_id_changed] return if event.data[:activity_result_type_id].nil? activity = Activity.find_by(id: event.data[:activity_id]) return unless activity&.call_record_id.present? call_record = activity.call_record return unless call_record&.unread? call_record.mark_as_read! Rails.logger.info "[VoicemailReadHandler] Marked CallRecord #{call_record.id} as read after Activity #{activity.id} completed" rescue StandardError => e ErrorReporting.error(e, activity_id: event.data[:activity_id]) raise end |