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/03 22:56:09 UTC

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

Author: vdichev
Date: Tue Mar  3 21:56:09 2009
New Revision: 749781

URL: http://svn.apache.org/viewvc?rev=749781&view=rev
Log:
ESME-44 Twitter API to get follow status.

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=749781&r1=749780&r2=749781&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 Mar  3 21:56:09 2009
@@ -88,7 +88,7 @@
 
     case Req(l: List[String], this.method, PostRequest) if l == ApiPath ::: "friendships" :: "create" :: l.last :: Nil => () => createFriendship(l last)
     case Req(l: List[String], this.method, PostRequest) if l == ApiPath ::: "friendships" :: "destroy" :: l.last :: Nil => () => destroyFriendship(l last)
-    // case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "friendships" :: "exists" :: Nil => existsFriendship
+    case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "friendships" :: "exists" :: Nil => existsFriendship
 
     case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "account" :: "verify_credentials" :: Nil => verifyCredentials
     // case Req(l: List[String], this.method, GetRequest) if l == ApiPath ::: "account" :: "end_session" :: Nil => endSession
@@ -260,6 +260,15 @@
     }
   }
   
+  def existsFriendship(): Box[TwitterResponse] = {
+    for (req <- S.request;
+         param_a <- req.param("user_a") ?~ "User A not specified";
+         param_b <- req.param("user_b") ?~ "User B not specified";
+         user_a <- User.findFromWeb(param_a) ?~ "User A not found";
+         user_b <- User.findFromWeb(param_b) ?~ "User B not found")
+    yield Right(Map("friends" -> user_a.following_?(user_b)))
+  }
+  
   private def calcUser(): Box[User] = 
     LiftRules.authentication match {
       case basicAuth: HttpBasicAuthentication =>