diff options
Diffstat (limited to 'users/app/models/user.rb')
-rw-r--r-- | users/app/models/user.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/users/app/models/user.rb b/users/app/models/user.rb index 720f5a9..fe3a127 100644 --- a/users/app/models/user.rb +++ b/users/app/models/user.rb @@ -72,6 +72,18 @@ class User < CouchRest::Model::Base Ticket.for_user(self).limit(count).all #defaults to having most recent updated first end + def messages(unseen = true) + + user_messages = unseen ? UserMessage.by_user_id_and_seen(:key => [self.id, false]).all : UserMessage.by_user_id(:key => self.id).all + + messages = [] + user_messages.each do |um| + messages << Message.find(um.message.id) + end + messages + + end + # DEPRECATED # # Please set the key on the identity directly |