summaryrefslogtreecommitdiff
path: root/users/app/models/user.rb
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-12-30 15:23:52 -0800
committerjessib <jessib@riseup.net>2013-12-30 15:23:52 -0800
commit396165d867f2009be1b1071d3c001009adf628ee (patch)
tree8afb8d7be89d93d1fccf9d872bff5b8105d32fdc /users/app/models/user.rb
parentc3fadeb8da6eb4400a3ceb2fecee83173eceeaf2 (diff)
parent16b28882aa7659fb89e1661ed8af0c0db72642c8 (diff)
Merge branch 'feature/messages_api' into feature/messages_cron
Diffstat (limited to 'users/app/models/user.rb')
-rw-r--r--users/app/models/user.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index bf48185..d9b03ec 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -13,6 +13,9 @@ class User < CouchRest::Model::Base
property :desired_service_level_code, Integer, :accessible => true
property :effective_service_level_code, Integer, :accessible => true
+ property :message_ids_to_see, [String]
+ property :message_ids_seen, [String]
+
before_save :update_effective_service_level
validates :login, :password_salt, :password_verifier,
@@ -74,6 +77,7 @@ class User < CouchRest::Model::Base
def messages(unseen = true)
+=begin
user_messages = unseen ? UserMessage.by_user_id_and_seen(:key => [self.id, false]).all : UserMessage.by_user_id(:key => self.id).all
messages = []
@@ -81,6 +85,15 @@ class User < CouchRest::Model::Base
messages << Message.find(um.message.id)
end
messages
+=end
+
+ message_ids = unseen ? self.message_ids_to_see : self.message_ids_to_see + self.message_ids_seen # TODO check unique?
+
+ messages = []
+ message_ids.each do |message_id|
+ messages << Message.find(message_id)
+ end
+ messages
end