Class: Decidim::Messaging::Receipt
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Messaging::Receipt
- Defined in:
- app/models/decidim/messaging/receipt.rb
Overview
Represents the reception of a message by a user. This model is supposed to hold any information about a message that is specific to each user, for example, the read/unread status, the deleted/undeleted status, and so on.
Class Method Summary collapse
-
.mark_as_read(user) ⇒ Object
rubocop:disable Rails/SkipsModelValidations.
-
.unread_count(user) ⇒ Integer
The number of messages unread by a user.
Class Method Details
.mark_as_read(user) ⇒ Object
rubocop:disable Rails/SkipsModelValidations
21 22 23 |
# File 'app/models/decidim/messaging/receipt.rb', line 21 def self.mark_as_read(user) recipient(user).update_all(read_at: Time.current) end |
.unread_count(user) ⇒ Integer
The number of messages unread by a user
30 31 32 |
# File 'app/models/decidim/messaging/receipt.rb', line 30 def self.unread_count(user) unread_by(user).count end |