incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r948359 - /incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala
Date Wed, 26 May 2010 07:51:47 GMT
Author: rhirsch
Date: Wed May 26 07:51:47 2010
New Revision: 948359

URL: http://svn.apache.org/viewvc?rev=948359&view=rev
Log:
[ESME-213] Twitter API is out-of-date and API calls don't always return the correct info

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=948359&r1=948358&r2=948359&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 Wed May
26 07:51:47 2010
@@ -87,8 +87,8 @@ abstract class TwitterAPI {
     case Req(ApiPath ::> "statuses" ::> "friends_timeline", this.method, GetRequest)
=> friendsTimeline
     case Req(ApiPath ::> "statuses" ::> "user_timeline", this.method, GetRequest) =>
userTimeline
     case Req(ApiPath ::> "statuses" ::> "user_timeline" ::> last, this.method, GetRequest)
=> () => userTimeline(last)
-    case Req(ApiPath ::> "statuses" ::> "home_timeline", this.method, GetRequest) =>
userTimeline
-    case Req(ApiPath ::> "statuses" ::> "home_timeline" ::> last, this.method, GetRequest)
=> () => userTimeline(last)
+    case Req(ApiPath ::> "statuses" ::> "home_timeline", this.method, GetRequest) =>
homeTimeline
+    case Req(ApiPath ::> "statuses" ::> "home_timeline" ::> last, this.method, GetRequest)
=> () => homeTimeline(last)
     case Req(ApiPath ::> "statuses" ::> "show" ::> last, this.method, GetRequest)
=> () => showStatus(last)
     case Req(ApiPath ::> "statuses" ::> "update", this.method, PostRequest) => update
 
@@ -215,6 +215,31 @@ abstract class TwitterAPI {
     calcUser map (userTimeline)
   }
   
+  def homeTimeline(user: User): TwitterResponse = {
+   val count: String = S.param("count") openOr "20"
+   val since_id: String = S.param("since_id") openOr "1"
+   
+   /*     val statusList = 
+      Mailbox.mostRecentMessagesFor(user.id, count.toInt);*/
+      
+    val statusList = 
+      Message.findAll(By(Message.author, user),
+                      By(Message.pool, Empty),
+                      MaxRows(count.toInt),
+                      OrderBy(Message.id, Descending)).
+        map(msgData _)
+    Right(Map("statuses" -> ("status", statusList) ))
+  }
+        
+  
+  def homeTimeline(userName: String): Box[TwitterResponse] = {
+    User.findFromWeb(userName).map(homeTimeline) ?~ S.?("base_twitter_api_err_user_not_found")
+  }
+  
+  def homeTimeline(): Box[TwitterResponse] = {
+    calcUser map (homeTimeline)
+  }
+  
   def replies(user: User): TwitterResponse = {
     val statusList = 
       Message.findAll(In(Message.replyTo, Message.id, By(Message.author, user)),



Mime
View raw message