diff options
author | jessib <jessib@riseup.net> | 2014-02-10 11:00:28 -0800 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2014-02-10 11:00:28 -0800 |
commit | a2289579eea138e0b7318f8866a0ed33f269761c (patch) | |
tree | a5fb064123600d53a1b8e93953818316f0d0a968 /users/app/models/message.rb | |
parent | b6ef51277b4e6d65cfda15f0124ae4f222f7f241 (diff) | |
parent | e3577906891f9ab0edd987544e3432f354bc1721 (diff) |
Merge pull request #139 from azul/refactor/tweaks-to-messages
Refactor/tweaks to messages
Diffstat (limited to 'users/app/models/message.rb')
-rw-r--r-- | users/app/models/message.rb | 13 |
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 |