diff options
author | jessib <jessib@riseup.net> | 2013-12-24 12:23:04 -0800 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2013-12-24 12:36:42 -0800 |
commit | e4390e2ee5b2df20038f12865db462cf1e208ee6 (patch) | |
tree | 459db7c00d99d4182a4793a22623364cb931b2a6 /users/app/controllers | |
parent | a9ff52501e9c04edacd250dd94ee3f3ad28cd73d (diff) |
Add API tests and some refactoring of messages so we can get a user's messages within the webapp.
Diffstat (limited to 'users/app/controllers')
-rw-r--r-- | users/app/controllers/v1/messages_controller.rb | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/users/app/controllers/v1/messages_controller.rb b/users/app/controllers/v1/messages_controller.rb index a4e9aec..fa98042 100644 --- a/users/app/controllers/v1/messages_controller.rb +++ b/users/app/controllers/v1/messages_controller.rb @@ -6,14 +6,8 @@ module V1 # for now, will not pass unseen, so unseen will always be true def user_messages(unseen = true) - user_messages = unseen ? UserMessage.by_user_id_and_seen(:key => [params[:user_id], false]).all : UserMessage.by_user_id(:key => params[:user_id]).all - - messages = [] - user_messages.each do |um| - messages << Message.find(um.message.id) - end - - render json: messages + user = User.find(params[:user_id]) + render json: (user ? user.messages : [] ) end |