Restore tutorial's ability to see what you send.

The internal format of 'message' had changed, so prior to this commit,
the tutorial was receiving (a) internally inconsistent, and (b)
not-what-it-expected versions of the message.

(imported from commit 233b934e6b600bd59125d133fdf7443fd8f6bbf8)
This commit is contained in:
Waseem Daher
2013-04-23 17:13:19 -04:00
parent eab43f28f4
commit 5f28cf8e02
2 changed files with 10 additions and 2 deletions

View File

@@ -307,6 +307,9 @@ function send_message() {
exports.snapshot_message(request); exports.snapshot_message(request);
if (tutorial.is_running()) { if (tutorial.is_running()) {
// We want the un-json-encoded version of the request.to, so
// we need to get it before the JSON stringify below messes it
// up.
tutorial.message_was_sent(request); tutorial.message_was_sent(request);
} }

View File

@@ -55,7 +55,7 @@ function stream_to_me(message) {
} }
function pm_to_me(message) { function pm_to_me(message) {
return message.type === 'private' && message.to === 'humbug+tutorial@humbughq.com'; return message.type === 'private' && message.to[0] === 'humbug+tutorial@humbughq.com';
} }
function any_message_to_me(message) { function any_message_to_me(message) {
@@ -63,7 +63,12 @@ function any_message_to_me(message) {
} }
var received_messages = []; var received_messages = [];
exports.message_was_sent = function(message) { exports.message_was_sent = function(request) {
// We copy our version of the message in case someone in compose.js
// modifies it later -- this is important!
// (right after this code is called, the "to" field is JSON stringified,
// which messes up the code below)
var message = $.extend({}, request, {});
// Don't let casing or stray punctuation get in the way. // Don't let casing or stray punctuation get in the way.
var trimmed_content = message.content.substring(0, 4).toLowerCase(); var trimmed_content = message.content.substring(0, 4).toLowerCase();
if (any_message_to_me(message) && if (any_message_to_me(message) &&