Sha256: cf4de16706149da002016401fd7fda99d0d97efbc3271fe16f0b9c197aaed277

Contents?: true

Size: 527 Bytes

Versions: 1

Compression:

Stored size: 527 Bytes

Contents

module WithNotifications
  extend ActiveSupport::Concern

  def unread_messages
    messages_in_organization.where read: false
  end

  def unread_notifications
    # TODO: message and discussion should trigger a notification instead of being one
    # include message notifications once they are properly implemented
    all = notifications.where(read: false) + 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

1 entries across 1 versions & 1 rubygems

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