Sha256: 1d87911c7d5914e2e365a3f743d30dd5585183a5be0a91747460d35dafc4a409

Contents?: true

Size: 458 Bytes

Versions: 2

Compression:

Stored size: 458 Bytes

Contents

module WithNotifications
  extend ActiveSupport::Concern

  def unread_messages
    messages.where read: false
  end

  def unread_notifications
    # TODO: message and discussion should trigger a notification instead of being one
    all = notifications.where(read: false) + unread_messages + unread_discussions
    all.sort_by(&:created_at).reverse
  end

  def read_notification!(target)
    notifications.find_by(target: target)&.mark_as_read!
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mumuki-domain-8.6.1 app/models/concerns/with_notifications.rb
mumuki-domain-8.6.0 app/models/concerns/with_notifications.rb