incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r794077 - in /incubator/esme/trunk/server/src/main: scala/org/apache/esme/actor/Distributor.scala scala/org/apache/esme/actor/UserActor.scala scala/org/apache/esme/snippet/UserSnip.scala webapp/templates-hidden/message.html
Date Tue, 14 Jul 2009 21:34:39 GMT
Author: vdichev
Date: Tue Jul 14 21:34:39 2009
New Revision: 794077

URL: http://svn.apache.org/viewvc?rev=794077&view=rev
Log:
ESME-76 Resending messages explicitly

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
    incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala?rev=794077&r1=794076&r2=794077&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/Distributor.scala Tue
Jul 14 21:34:39 2009
@@ -93,6 +93,9 @@
         
       case AllowUserInPool(userId, poolId) =>
         findOrCreateUser(userId) ! UserActor.AllowPool(poolId)
+        
+      case ResendMessage(userId, msgId) =>
+        findOrCreateUser(userId) ! UserActor.Resend(msgId)
 
       case _ =>
     }
@@ -116,6 +119,7 @@
   case class PublicTimelineListeners(who: Actor)
   case class PublicTimelineUnlisteners(who: Actor)
   case class AllowUserInPool(userId: Long, poolId: Long)
+  case class ResendMessage(userId: Long, msgId: Long)
   sealed trait TrackingType
   case object PerformTrackingType extends TrackingType
   case object TrackTrackingType extends TrackingType

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala?rev=794077&r1=794076&r2=794077&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/actor/UserActor.scala Tue Jul
14 21:34:39 2009
@@ -51,6 +51,7 @@
   private[actor] case class TestForTracking(msg: Message)
   private[actor] case class UpdateTracking(ttype: Distributor.TrackingType)
   private[actor] case class AllowPool(poolId: Long)
+  private[actor] case class Resend(msgId: Long)
   
   case class MessageReceived(msg: Message, reason: MailboxReason)
   
@@ -189,6 +190,13 @@
         reply(_mailbox.take(cnt).toList)
       
       case AllowPool(poolId) => pools += poolId
+      
+      case Resend(msgId) =>
+        for (msg <- Message.find(msgId);
+             id <- followers)
+               Distributor !
+               Distributor.AddMessageToMailbox(id, msg, ResendReason(userId))
+
     }
   }
 

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala?rev=794077&r1=794076&r2=794077&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala Tue
Jul 14 21:34:39 2009
@@ -66,6 +66,18 @@
   }
 )
 
+object JsonResender extends SessionVar(S.buildJsonFunc{
+    case JsonCmd("resend", _, map: Map[String, Any], _) =>
+      for (msgId <- map.get("msg_id").map(toLong);
+           user  <- User.currentUser)
+             Distributor ! Distributor.ResendMessage(user.id, msgId)
+    
+      Noop
+
+    case _ => Noop
+  }
+)
+
 class UserSnip extends DispatchSnippet {
   def dispatch: DispatchIt = 
   Map("name" -> userName _,
@@ -74,7 +86,8 @@
       "following" -> following _,
       "loginForm" -> loginForm _,
       "loggedIn" -> loggedInFilter _,
-      "accessPools" -> accessPools _)
+      "accessPools" -> accessPools _,
+      "resendScript" -> resendScript _)
 
   def loggedInFilter(in: NodeSeq): NodeSeq = {
     val lookFor = if (User.loggedIn_?) "in" else "out"
@@ -141,4 +154,15 @@
         ))
     }
   </xml:group>
+  
+  def resendScript(in: NodeSeq): NodeSeq = 
+  <xml:group>
+    {Script(JsonResender.is._2)}
+    {Script(Function("resend_msg", List("msg_id"),
+                     JsonResender.is._1("resend",
+                                        JsObj("msg_id" -> JsVar("msg_id")))
+        ))
+    }
+  </xml:group>
+  
 }

Modified: incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html?rev=794077&r1=794076&r2=794077&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/templates-hidden/message.html Tue Jul 14 21:34:39
2009
@@ -82,6 +82,7 @@
             newMsg.find('#source').text(msgSource);
             newMsg.find('#reason').text(msgReason);
             newMsg.find('#when').text(msgDateStr);
+            newMsg.find('#resend').attr('onclick', 'javascript:resend_msg(' + cometMsg.id
+ ');');
             for (var tagIndex=0; tagIndex < msgTags.length; tagIndex++) {
               var newTag = tagTemplate.clone(true).attr('id',msgTags[tagIndex]);
               newTag.find('a')
@@ -159,6 +160,7 @@
                               <td id="source">web</td>
                               <td id="reason">resend</td>
                               <td id="when" class="date">Jan 1, 2009 12:00</td>
+                              <td><button id="resend" class="btn">Resend</button></td>
                             </tr>
                             <tr id="message">
                               <td><img id="avatar" src="http://static.twitter.com/images/default_profile_bigger.png"
alt="Anonymous" width="50px"/><div id="author">anon</div></td>
@@ -175,12 +177,14 @@
                               <td id="source">web</td>
                               <td id="reason"><!-- no reason --></td>
                               <td id="when" class="date">Jan 1, 2009 11:58</td>
+                              <td><button id="resend" class="btn">Resend</button></td>
                             </tr>
                           </tbody>
                         </table>
                       </div>
                     </dd>
                   </dl>
+                  <lift:UserSnip.resendScript/>
 
                   <dl class="tagclouds">
                     <dt class="caption">Public timeline</dt>



Mime
View raw message