You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by vd...@apache.org on 2009/03/05 21:52:42 UTC

svn commit: r750581 - /incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala

Author: vdichev
Date: Thu Mar  5 20:52:41 2009
New Revision: 750581

URL: http://svn.apache.org/viewvc?rev=750581&view=rev
Log:
Twitter API: get user timeline of specific user.

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala?rev=750581&r1=750580&r2=750581&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala Thu Mar  5 20:52:41 2009
@@ -79,6 +79,7 @@
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "direct_messages" :: Nil => directMessages
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "statuses" :: "friends_timeline" :: Nil => friendsTimeline
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "statuses" :: "user_timeline" :: Nil => userTimeline
+    case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "statuses" :: "user_timeline" :: l.last :: Nil => () => userTimeline(l last)
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "statuses" :: "show" :: l.last :: Nil => () => showStatus(l last)
     case Req(l: List[String], this.method, PostRequest) if l == ApiPath ::: "statuses" :: "update" :: Nil => update
 
@@ -174,15 +175,21 @@
     }
   }
   
+  def userTimeline(user: User): TwitterResponse = {
+    val statusList = 
+      Message.findAll(By(Message.author, user),
+                      MaxRows(20),
+                      OrderBy(Message.id, Descending)).
+        map(msgData _)
+    Right(Map("statuses" -> ("status", statusList) ))
+  }
+  
+  def userTimeline(userName: String): Box[TwitterResponse] = {
+    User.findFromWeb(userName) map (userTimeline(_))
+  }
+  
   def userTimeline(): Box[TwitterResponse] = {
-    calcUser map { user => 
-      val statusList = 
-        Message.findAll(By(Message.author, user),
-                        MaxRows(20),
-                        OrderBy(Message.id, Descending)).
-          map(msgData _)
-      Right(Map("statuses" -> ("status", statusList) ))
-    }
+    calcUser map (userTimeline(_))
   }
   
   def replies(): Box[TwitterResponse] = {