Class: SpreeCmCommissioner::NotificationReader
- Inherits:
-
BaseInteractor
- Object
- BaseInteractor
- SpreeCmCommissioner::NotificationReader
- Defined in:
- app/interactors/spree_cm_commissioner/notification_reader.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
5 6 7 8 |
# File 'app/interactors/spree_cm_commissioner/notification_reader.rb', line 5 def call read_specific_notification if id.present? read_all_user_unread_notifications if user.present? end |
#read_all_user_unread_notifications ⇒ Object
17 18 19 20 21 |
# File 'app/interactors/spree_cm_commissioner/notification_reader.rb', line 17 def read_all_user_unread_notifications # mark all unread notifications accept type 'guest_dynamic_field_notification' # due to it requires user to fill info before mark as read user.notifications.markable_notifications.mark_as_read! end |
#read_specific_notification ⇒ Object
10 11 12 13 14 15 |
# File 'app/interactors/spree_cm_commissioner/notification_reader.rb', line 10 def read_specific_notification notification = SpreeCmCommissioner::Notification.find_by(id: id) return context.fail!(error_message: 'Notification not found') if notification.nil? notification.mark_as_read! if notification.unread? end |