[tor-commits] [pups/master] Sends token & comment when the chat session starts

lunar at torproject.org lunar at torproject.org
Sat Oct 11 09:48:58 UTC 2014


commit 93196c65a5619adbb29477c882d0e60756f2681e
Author: Sherief Alaa <sheriefalaa.w at gmail.com>
Date:   Thu Sep 4 09:34:35 2014 +0300

    Sends token & comment when the chat session starts
    
    Sends token and comment of the related ticket to the support assistant
    at the start of the chat session without sending them to the user's web
    UI.
---
 static/js/prodromus.js           |   17 ++++++++++++-----
 webchat/templates/prodromus.html |    4 +++-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/static/js/prodromus.js b/static/js/prodromus.js
index 916df2c..ee9f7c7 100644
--- a/static/js/prodromus.js
+++ b/static/js/prodromus.js
@@ -129,7 +129,7 @@ Prodromus.Util = {
 	
 }
 
-Prodromus.buildAndSendMessage = function( message, type ) {
+Prodromus.buildAndSendMessage = function( message, type, toAssistant) {
 
     var msg = $msg({from: Prodromus.connection.jid, to: Prodromus.config.RECEIVER, type: type})
         .c("body").t(message).up()
@@ -139,7 +139,11 @@ Prodromus.buildAndSendMessage = function( message, type ) {
 
     Prodromus.connection.send( msg );
 
-    Prodromus.UI.log( message, "msgOut" );
+    // Display the message on the web UI if the user was meant to see it.
+    // Mainly used to hide the comment the assistant writes.
+    if(!toAssistant){
+        Prodromus.UI.log( message, "msgOut" );
+    }
 }
 
 Prodromus.actionhandler = {
@@ -222,9 +226,13 @@ Prodromus.actionhandler = {
                 Prodromus.connection.send( $pres() );
 
                 Prodromus.buildAndSendMessage(
-                    Prodromus.Util.htmlspecialchars( Prodromus.config.SENDERNAME ) + Prodromus.i18n.t9n( 'msg-hello' ) + Prodromus.i18n.t9n( 'token' )
+                    Prodromus.Util.htmlspecialchars( Prodromus.config.SENDERNAME ) + Prodromus.i18n.t9n( 'msg-hello' )
                   , 'chat' 
                 );
+
+                Prodromus.buildAndSendMessage("Token: " + Prodromus.config.TOKEN, 'chat', true);
+                Prodromus.buildAndSendMessage("Comment: " + Prodromus.config.COMMENT, 'chat', true);
+
                 break;
         }
     },
@@ -346,8 +354,7 @@ Prodromus.t9n = {
         'send': 'Send',
         'failed-to-connect': 'Failed to connect to the server!',
         'msg-hello': ' joins the chat.',
-        'msg-goodbye': ' leaves the chat. ',
-        'token': " Token: " + Prodromus.config.TOKEN
+        'msg-goodbye': ' leaves the chat. '
     }
 
 }
diff --git a/webchat/templates/prodromus.html b/webchat/templates/prodromus.html
index 9a97f40..8acaf9c 100644
--- a/webchat/templates/prodromus.html
+++ b/webchat/templates/prodromus.html
@@ -56,7 +56,9 @@
             'LANGUAGE': 'en',
             
             // stores the token of this session
-            'TOKEN': '{{token}}'
+            'TOKEN': '{{token}}',
+
+            'COMMENT': '{{comment}}'
         }
 
     </script>





More information about the tor-commits mailing list