summaryrefslogtreecommitdiff
path: root/users/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'users/app/models')
-rw-r--r--users/app/models/message.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/app/models/message.rb b/users/app/models/message.rb
index d9ccee8..424f094 100644
--- a/users/app/models/message.rb
+++ b/users/app/models/message.rb
@@ -13,4 +13,17 @@ class Message < CouchRest::Model::Base
load_views(own_path.join('..', 'designs', 'message'))
end
+ def mark_as_read_by(user)
+ user_ids_to_show.delete(user.id)
+ # is it necessary to keep track of what users have already seen it?
+ user_ids_have_shown << user.id unless read_by?(user)
+ end
+
+ def read_by?(user)
+ user_ids_have_shown.include?(user.id)
+ end
+
+ def unread_by?(user)
+ user_ids_to_show.include?(user.id)
+ end
end