incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r745254 - /incubator/esme/trunk/server/src/main/scala/org/apache/esme/api/TwitterAPI.scala
Date Tue, 17 Feb 2009 20:52:34 GMT
Author: vdichev
Date: Tue Feb 17 20:52:34 2009
New Revision: 745254

URL: http://svn.apache.org/viewvc?rev=745254&view=rev
Log:
ESME-31 posting status updates from Twitter API

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=745254&r1=745253&r2=745254&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 Tue Feb
17 20:52:34 2009
@@ -79,7 +79,7 @@
     case req @ Req(ApiPath :: "statuses" :: "friends_timeline" :: Nil, this.method, GetRequest)
=> () => friendsTimeline(req)
     case req @ Req(ApiPath :: "statuses" :: "user_timeline" :: Nil, this.method, GetRequest)
=> () => userTimeline(req)
     // case Req(ApiPath :: "statuses" :: "show" :: Nil, this.method, GetRequest) => showStatus
-    // case Req(ApiPath :: "statuses" :: "update" :: Nil, this.method, GetRequest) =>
() => update(S)
+    case req @ Req(ApiPath :: "statuses" :: "update" :: Nil, this.method, PostRequest) =>
() => update(S, req)
 
     // case Req(ApiPath :: "statuses" :: "friends" :: Nil, this.method, GetRequest) =>
friends
     // case Req(ApiPath :: "statuses" :: "followers" :: Nil, this.method, GetRequest) =>
followers
@@ -118,7 +118,7 @@
     "favorited" -> false,
     "in_reply_to_status_id" -> None,
     "in_reply_to_user_id" -> None,
-    "in_reply_to_screen_name" -> None,
+    "in_reply_to_screen_name" -> None
     )
   }
   
@@ -176,6 +176,26 @@
     Full(Right(Map("statuses" -> ("status", statusList) )))
   }
   
+  def update(params: HasParams, req: Req): Box[TwitterResponse] = {
+    for (user <- calcUser(req) ?~ "User not found";
+         msg <- req.param("status") ?~ "Message not included")
+    yield {
+      val from: String = req.param("source") openOr "twitterapi"
+
+      Distributor !
+      Distributor.UserCreatedMessage(user.id.is, msg, Nil,
+                                     millis,
+                                     Empty,
+                                     from,
+                                     req.param("replyto").map(toLong))
+      Right(Map("status" ->
+        msgData(Message.create.author(user.id.is).when(millis).
+          source(from).
+          setTextAndTags(msg, Nil, None).get)
+      ))
+    }
+  }
+
   private def calcUser(req: Req): Box[User] = 
     LiftRules.authentication match {
       case basicAuth: HttpBasicAuthentication =>



Mime
View raw message