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/07/18 15:29:14 UTC

svn commit: r795363 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/MsgParser.scala model/Action.scala

Author: vdichev
Date: Sat Jul 18 13:29:14 2009
New Revision: 795363

URL: http://svn.apache.org/viewvc?rev=795363&view=rev
Log:
ESME-79 Action filters for resent messages

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala?rev=795363&r1=795362&r2=795363&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala Sat Jul 18 13:29:14 2009
@@ -47,13 +47,13 @@
 
   lazy val url: Parser[URL] = httpUrl ^^ {url => URL(UrlStore.make(url))}
 
-  lazy val atNameStr: Parser[String] = alpha ~ rep(alpha | digit | '_') ^^ {
+  lazy val userNameStr: Parser[String] = alpha ~ rep(alpha | digit | '_') ^^ {
     case first ~ more => first + more.mkString
   }
   
-  lazy val poolNameStr = atNameStr
+  lazy val poolNameStr = userNameStr
   
-  lazy val atName: Parser[MsgInfo] = '@' ~> atNameStr ~ rep('.' ~> atNameStr) ^^ {
+  lazy val atName: Parser[MsgInfo] = '@' ~> userNameStr ~ rep('.' ~> userNameStr) ^^ {
     case name ~ domainlist => 
       val nickName: String = name
       val wholeName: String = (name :: domainlist).mkString(".")
@@ -71,6 +71,14 @@
       }
   }
   
+  lazy val resenderName: Parser[MsgInfo] = acceptCI("resent:") ~> userNameStr ^^ {
+    case name => 
+      User.find(By(User.nickname, name)) match {
+        case Full(u) => ResenderName(u)
+        case _ => MsgText("resent:"+name)
+      }
+  }
+  
   // def ip_schemepart = (accept("//") ~> login) ~> opt( '/' ~> urlpath)
 
   lazy val login: Parser[String] = userPass ^^ {
@@ -245,6 +253,7 @@
   lazy val testFactor: Parser[TestAction] = (notTest |
   testAt | testRegex | testString |
   testTag | testPool |
+  testResent |
   testParen | testPercent |
   testDates | testLogin |
   testFollowed | testUnfollowed |
@@ -328,6 +337,14 @@
   (poolName ^^ {
       case PoolName(pool) => PoolAction(pool.id)
     })
+    
+  lazy val testResent: Parser[TestAction] = 
+  (whiteSpace ~ acceptCI("resent:") ~> rep1(digit) <~ whiteSpace ^^ {case id => ResentAction(id.mkString.toLong)}) |
+  (resenderName ^^ {
+      case ResenderName(user) => ResentAction(user.id)
+    }) |
+  (whiteSpace ~ acceptCI("resent") ~ whiteSpace ^^^ ResentAction)
+    
   
   lazy val testAt: Parser[AtUserAction] =
   (whiteSpace ~ '@' ~> rep1(digit) <~ whiteSpace ^^ {case dig => AtUserAction(dig.mkString.toLong)}) |
@@ -381,6 +398,7 @@
 sealed trait MsgInfo
 case class MsgText(text: String) extends MsgInfo
 case class AtName(user: User) extends MsgInfo
+case class ResenderName(user: User) extends MsgInfo
 case class HashTag(tag: Tag) extends MsgInfo
 case class URL(url: UrlStore) extends MsgInfo
 case class PoolName(pool: AccessPool) extends MsgInfo

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala?rev=795363&r1=795362&r2=795363&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala Sat Jul 18 13:29:14 2009
@@ -95,6 +95,15 @@
         
     case PoolAction(poolId) =>
       (m, u, c, r) => m.pool.is == poolId
+      
+    case ResentAction(userId) =>
+      (m, u, c, r) => r match {
+        case ResendReason(`userId`) => true
+        case _ => false
+      }
+        
+    case ResentAction =>
+      (m, u, c, r) => r.isInstanceOf[ResendReason]
         
     case SentToMeAction =>
       SentToMe
@@ -301,6 +310,14 @@
   def toStr = "pool:" + poolId
 }
 
+case object ResentAction extends TestAction {
+  def toStr = "resent"
+}
+
+case class ResentAction(userId: Long) extends TestAction {
+  def toStr = "resent:" + userId
+}
+
 case class RegexAction(re: String) extends TestAction {
   def toStr = "/"+fix+"/"
   



Re: svn commit: r795363 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/MsgParser.scala model/Action.scala

Posted by Vassil Dichev <vd...@apache.org>.
> Does the ESME REST API also include resending. I don't remember any
> commits involving the REST API?

No, there haven't been any commits regarding resending via the RESTful
API. This particular commit is for action filters- you could, for
instance, decide to filter any resent messages from your timeline, or
further resend messages resent from a particular user.

Fwd: svn commit: r795363 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/MsgParser.scala model/Action.scala

Posted by Richard Hirsch <hi...@gmail.com>.
Does the ESME REST API also include resending. I don't remember any
commits involving the REST API?

D.


---------- Forwarded message ----------
From:  <vd...@apache.org>
Date: Sat, Jul 18, 2009 at 3:29 PM
Subject: svn commit: r795363 - in
/incubator/esme/trunk/server/src/main/scala/org/apache/esme:
lib/MsgParser.scala model/Action.scala
To: esme-commits@incubator.apache.org


Author: vdichev
Date: Sat Jul 18 13:29:14 2009
New Revision: 795363

URL: http://svn.apache.org/viewvc?rev=795363&view=rev
Log:
ESME-79 Action filters for resent messages

Modified:
   incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
   incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala?rev=795363&r1=795362&r2=795363&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
(original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/MsgParser.scala
Sat Jul 18 13:29:14 2009
@@ -47,13 +47,13 @@

  lazy val url: Parser[URL] = httpUrl ^^ {url => URL(UrlStore.make(url))}

-  lazy val atNameStr: Parser[String] = alpha ~ rep(alpha | digit | '_') ^^ {
+  lazy val userNameStr: Parser[String] = alpha ~ rep(alpha | digit | '_') ^^ {
    case first ~ more => first + more.mkString
  }

-  lazy val poolNameStr = atNameStr
+  lazy val poolNameStr = userNameStr

-  lazy val atName: Parser[MsgInfo] = '@' ~> atNameStr ~ rep('.' ~>
atNameStr) ^^ {
+  lazy val atName: Parser[MsgInfo] = '@' ~> userNameStr ~ rep('.' ~>
userNameStr) ^^ {
    case name ~ domainlist =>
      val nickName: String = name
      val wholeName: String = (name :: domainlist).mkString(".")
@@ -71,6 +71,14 @@
      }
  }

+  lazy val resenderName: Parser[MsgInfo] = acceptCI("resent:") ~>
userNameStr ^^ {
+    case name =>
+      User.find(By(User.nickname, name)) match {
+        case Full(u) => ResenderName(u)
+        case _ => MsgText("resent:"+name)
+      }
+  }
+
  // def ip_schemepart = (accept("//") ~> login) ~> opt( '/' ~> urlpath)

  lazy val login: Parser[String] = userPass ^^ {
@@ -245,6 +253,7 @@
  lazy val testFactor: Parser[TestAction] = (notTest |
  testAt | testRegex | testString |
  testTag | testPool |
+  testResent |
  testParen | testPercent |
  testDates | testLogin |
  testFollowed | testUnfollowed |
@@ -328,6 +337,14 @@
  (poolName ^^ {
      case PoolName(pool) => PoolAction(pool.id)
    })
+
+  lazy val testResent: Parser[TestAction] =
+  (whiteSpace ~ acceptCI("resent:") ~> rep1(digit) <~ whiteSpace ^^
{case id => ResentAction(id.mkString.toLong)}) |
+  (resenderName ^^ {
+      case ResenderName(user) => ResentAction(user.id)
+    }) |
+  (whiteSpace ~ acceptCI("resent") ~ whiteSpace ^^^ ResentAction)
+

  lazy val testAt: Parser[AtUserAction] =
  (whiteSpace ~ '@' ~> rep1(digit) <~ whiteSpace ^^ {case dig =>
AtUserAction(dig.mkString.toLong)}) |
@@ -381,6 +398,7 @@
 sealed trait MsgInfo
 case class MsgText(text: String) extends MsgInfo
 case class AtName(user: User) extends MsgInfo
+case class ResenderName(user: User) extends MsgInfo
 case class HashTag(tag: Tag) extends MsgInfo
 case class URL(url: UrlStore) extends MsgInfo
 case class PoolName(pool: AccessPool) extends MsgInfo

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala?rev=795363&r1=795362&r2=795363&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
(original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
Sat Jul 18 13:29:14 2009
@@ -95,6 +95,15 @@

    case PoolAction(poolId) =>
      (m, u, c, r) => m.pool.is == poolId
+
+    case ResentAction(userId) =>
+      (m, u, c, r) => r match {
+        case ResendReason(`userId`) => true
+        case _ => false
+      }
+
+    case ResentAction =>
+      (m, u, c, r) => r.isInstanceOf[ResendReason]

    case SentToMeAction =>
      SentToMe
@@ -301,6 +310,14 @@
  def toStr = "pool:" + poolId
 }

+case object ResentAction extends TestAction {
+  def toStr = "resent"
+}
+
+case class ResentAction(userId: Long) extends TestAction {
+  def toStr = "resent:" + userId
+}
+
 case class RegexAction(re: String) extends TestAction {
  def toStr = "/"+fix+"/"