2012-10-18 20:29:16 +02:00
|
|
|
var compose = (function () {
|
2012-10-03 22:53:15 +02:00
|
|
|
|
2012-10-18 20:29:16 +02:00
|
|
|
var exports = {};
|
2012-10-19 19:51:19 +02:00
|
|
|
var is_composing_message = false;
|
2016-06-04 04:31:35 +02:00
|
|
|
|
2016-12-02 15:16:33 +01:00
|
|
|
/* Track the state of the @all warning. The user must acknowledge that they are spamming the entire
|
|
|
|
stream before the warning will go away. If they try to send before explicitly dismissing the
|
|
|
|
warning, they will get an error message too.
|
|
|
|
|
|
|
|
undefined: no @all/@everyone in message;
|
|
|
|
false: user typed @all/@everyone;
|
|
|
|
true: user clicked YES */
|
2016-11-09 19:34:07 +01:00
|
|
|
|
2016-06-04 04:31:35 +02:00
|
|
|
var user_acknowledged_all_everyone;
|
|
|
|
|
2016-11-09 19:34:07 +01:00
|
|
|
exports.all_everyone_warn_threshold = 15;
|
|
|
|
|
2013-10-23 16:46:18 +02:00
|
|
|
var uploads_domain = document.location.protocol + '//' + document.location.host;
|
|
|
|
var uploads_path = '/user_uploads';
|
|
|
|
var uploads_re = new RegExp("\\]\\(" + uploads_domain + "(" + uploads_path + "[^\\)]+)\\)", 'g');
|
|
|
|
|
|
|
|
function make_upload_absolute(uri) {
|
|
|
|
if (uri.indexOf(uploads_path) === 0) {
|
|
|
|
// Rewrite the URI to a usable link
|
|
|
|
return uploads_domain + uri;
|
|
|
|
}
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
function make_uploads_relative(content) {
|
|
|
|
// Rewrite uploads in markdown links back to domain-relative form
|
|
|
|
return content.replace(uploads_re, "]($1)");
|
|
|
|
}
|
|
|
|
|
2013-05-08 16:54:01 +02:00
|
|
|
// This function resets an input type="file". Pass in the
|
|
|
|
// jquery object.
|
|
|
|
function clear_out_file_list(jq_file_list) {
|
|
|
|
var clone_for_ie_sake = jq_file_list.clone(true);
|
|
|
|
jq_file_list.replaceWith(clone_for_ie_sake);
|
|
|
|
|
|
|
|
// Hack explanation:
|
|
|
|
// IE won't let you do this (untested, but so says StackOverflow):
|
|
|
|
// $("#file_input").val("");
|
|
|
|
}
|
|
|
|
|
2017-01-04 04:13:15 +01:00
|
|
|
exports.autosize_textarea = function () {
|
2013-09-05 18:55:09 +02:00
|
|
|
$("#new_message_content").trigger("autosize.resize");
|
2017-01-04 04:13:15 +01:00
|
|
|
};
|
2013-09-05 18:55:09 +02:00
|
|
|
|
2013-07-12 23:26:18 +02:00
|
|
|
// Show the compose box.
|
2013-10-25 23:43:58 +02:00
|
|
|
function show_box(tabname, focus_area, opts) {
|
2012-11-26 19:10:05 +01:00
|
|
|
if (tabname === "stream") {
|
|
|
|
$('#private-message').hide();
|
|
|
|
$('#stream-message').show();
|
|
|
|
$("#stream_toggle").addClass("active");
|
|
|
|
$("#private_message_toggle").removeClass("active");
|
|
|
|
} else {
|
|
|
|
$('#private-message').show();
|
|
|
|
$('#stream-message').hide();
|
|
|
|
$("#stream_toggle").removeClass("active");
|
|
|
|
$("#private_message_toggle").addClass("active");
|
|
|
|
}
|
|
|
|
$("#send-status").removeClass(status_classes).hide();
|
|
|
|
$('#compose').css({visibility: "visible"});
|
2013-05-28 16:55:56 +02:00
|
|
|
$(".new_message_textarea").css("min-height", "3em");
|
|
|
|
|
2013-10-25 23:43:58 +02:00
|
|
|
if (focus_area !== undefined &&
|
|
|
|
(window.getSelection().toString() === "" ||
|
|
|
|
opts.trigger !== "message click")) {
|
2013-07-09 23:08:33 +02:00
|
|
|
focus_area.focus().select();
|
|
|
|
}
|
|
|
|
|
2013-05-28 16:55:56 +02:00
|
|
|
// If the compose box is obscuring the currently selected message,
|
|
|
|
// scroll up until the message is no longer occluded.
|
|
|
|
if (current_msg_list.selected_id() === -1) {
|
|
|
|
// If there's no selected message, there's no need to
|
|
|
|
// scroll the compose box to avoid it.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var selected_row = current_msg_list.selected_row();
|
|
|
|
var cover = selected_row.offset().top + selected_row.height()
|
|
|
|
- $("#compose").offset().top;
|
|
|
|
if (cover > 0) {
|
|
|
|
viewport.user_initiated_animate_scroll(cover+5);
|
|
|
|
}
|
|
|
|
|
2012-11-26 19:10:05 +01:00
|
|
|
}
|
|
|
|
|
2016-06-04 04:31:35 +02:00
|
|
|
function show_all_everyone_warnings() {
|
|
|
|
var current_stream = stream_data.get_sub(compose.stream_name());
|
|
|
|
var stream_count = current_stream.subscribers.num_items();
|
|
|
|
|
|
|
|
var all_everyone_template = templates.render("compose_all_everyone", {count: stream_count});
|
|
|
|
var error_area_all_everyone = $("#compose-all-everyone");
|
|
|
|
|
|
|
|
// only show one error for any number of @all or @everyone mentions
|
|
|
|
if (!error_area_all_everyone.is(':visible')) {
|
|
|
|
error_area_all_everyone.append(all_everyone_template);
|
|
|
|
}
|
|
|
|
|
|
|
|
error_area_all_everyone.show();
|
|
|
|
user_acknowledged_all_everyone = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear_all_everyone_warnings() {
|
|
|
|
$("#compose-all-everyone").hide();
|
|
|
|
$("#compose-all-everyone").empty();
|
|
|
|
$("#send-status").hide();
|
|
|
|
}
|
|
|
|
|
2013-09-16 21:13:11 +02:00
|
|
|
function clear_invites() {
|
|
|
|
$("#compose_invite_users").hide();
|
|
|
|
$("#compose_invite_users").empty();
|
|
|
|
}
|
|
|
|
|
2013-07-12 23:26:18 +02:00
|
|
|
function clear_box() {
|
2013-09-16 21:13:11 +02:00
|
|
|
clear_invites();
|
2016-06-04 04:31:35 +02:00
|
|
|
clear_all_everyone_warnings();
|
|
|
|
user_acknowledged_all_everyone = undefined;
|
2013-07-12 23:26:18 +02:00
|
|
|
$("#compose").find('input[type=text], textarea').val('');
|
2017-02-22 02:34:05 +01:00
|
|
|
$("#new_message_content").removeData("draft-id");
|
2017-01-04 04:13:15 +01:00
|
|
|
exports.autosize_textarea();
|
2013-07-12 23:26:18 +02:00
|
|
|
$("#send-status").hide(0);
|
|
|
|
}
|
|
|
|
|
2016-12-05 07:02:18 +01:00
|
|
|
function clear_preview_area() {
|
2016-08-29 22:37:27 +02:00
|
|
|
$("#new_message_content").show();
|
|
|
|
$("#undo_markdown_preview").hide();
|
|
|
|
$("#preview_message_area").hide();
|
2016-09-26 22:03:42 +02:00
|
|
|
$("#preview_content").empty();
|
2016-08-29 22:37:27 +02:00
|
|
|
$("#markdown_preview").show();
|
|
|
|
}
|
|
|
|
|
2013-07-12 23:26:18 +02:00
|
|
|
function hide_box() {
|
|
|
|
$('.message_comp').find('input, textarea, button').blur();
|
|
|
|
$('#stream-message').hide();
|
|
|
|
$('#private-message').hide();
|
|
|
|
$(".new_message_textarea").css("min-height", "");
|
2013-08-12 17:40:55 +02:00
|
|
|
compose_fade.clear_compose();
|
2013-07-12 23:26:18 +02:00
|
|
|
$('.message_comp').hide();
|
|
|
|
$("#compose_controls").show();
|
2016-08-29 22:37:27 +02:00
|
|
|
clear_preview_area();
|
2013-07-12 23:26:18 +02:00
|
|
|
}
|
|
|
|
|
2013-05-02 17:12:58 +02:00
|
|
|
function update_lock_icon_for_stream(stream_name) {
|
|
|
|
var icon = $("#compose-lock-icon");
|
2013-09-04 01:14:29 +02:00
|
|
|
var streamfield = $("#stream");
|
2013-08-15 21:11:07 +02:00
|
|
|
if (stream_data.get_invite_only(stream_name)) {
|
2013-05-02 17:12:58 +02:00
|
|
|
icon.show();
|
2013-09-04 01:14:29 +02:00
|
|
|
streamfield.addClass("lock-padding");
|
2013-05-02 17:12:58 +02:00
|
|
|
} else {
|
|
|
|
icon.hide();
|
2013-09-04 01:14:29 +02:00
|
|
|
streamfield.removeClass("lock-padding");
|
2013-05-02 17:12:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-15 22:19:38 +01:00
|
|
|
// In an attempt to decrease mixing, make the composebox's
|
|
|
|
// stream bar look like what you're replying to.
|
|
|
|
// (In particular, if there's a color associated with it,
|
|
|
|
// have that color be reflected here too.)
|
|
|
|
exports.decorate_stream_bar = function (stream_name) {
|
2013-08-15 21:11:07 +02:00
|
|
|
var color = stream_data.get_color(stream_name);
|
2013-05-02 17:12:58 +02:00
|
|
|
update_lock_icon_for_stream(stream_name);
|
2013-02-19 20:13:50 +01:00
|
|
|
$("#stream-message .message_header_stream")
|
|
|
|
.css('background-color', color)
|
2013-08-07 19:28:06 +02:00
|
|
|
.removeClass(stream_color.color_classes)
|
|
|
|
.addClass(stream_color.get_color_class(color));
|
2013-01-15 22:19:38 +01:00
|
|
|
};
|
|
|
|
|
2016-12-05 07:02:18 +01:00
|
|
|
function update_fade() {
|
2013-08-01 17:47:48 +02:00
|
|
|
if (!is_composing_message) {
|
|
|
|
return;
|
|
|
|
}
|
2013-03-12 21:46:54 +01:00
|
|
|
|
2013-08-11 23:54:50 +02:00
|
|
|
// Legacy strangeness: is_composing_message can be false, "stream", or "private"
|
|
|
|
var msg_type = is_composing_message;
|
|
|
|
compose_fade.set_focused_recipient(msg_type);
|
2013-08-11 21:21:47 +02:00
|
|
|
compose_fade.update_faded_messages();
|
2013-03-12 21:46:54 +01:00
|
|
|
}
|
|
|
|
|
2013-06-17 19:31:38 +02:00
|
|
|
$(function () {
|
|
|
|
$('#stream,#subject,#private_message_recipient').bind({
|
|
|
|
keyup: update_fade,
|
2017-01-12 00:17:43 +01:00
|
|
|
change: update_fade,
|
2013-06-17 19:31:38 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-08-12 19:43:29 +02:00
|
|
|
function fill_in_opts_from_current_narrowed_view(msg_type, opts) {
|
2013-02-27 19:24:56 +01:00
|
|
|
var default_opts = {
|
|
|
|
message_type: msg_type,
|
|
|
|
stream: '',
|
|
|
|
subject: '',
|
2013-05-20 23:35:41 +02:00
|
|
|
private_message_recipient: '',
|
2017-01-12 00:17:43 +01:00
|
|
|
trigger: 'unknown',
|
2013-02-27 19:24:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Set default parameters based on the current narrowed view.
|
|
|
|
narrow.set_compose_defaults(default_opts);
|
2013-07-30 05:11:50 +02:00
|
|
|
opts = _.extend(default_opts, opts);
|
2013-08-12 19:43:29 +02:00
|
|
|
return opts;
|
|
|
|
}
|
|
|
|
|
2013-08-12 20:19:02 +02:00
|
|
|
function same_recipient_as_before(msg_type, opts) {
|
|
|
|
return (compose.composing() === msg_type) &&
|
|
|
|
((msg_type === "stream" &&
|
|
|
|
opts.stream === compose.stream_name() &&
|
|
|
|
opts.subject === compose.subject()) ||
|
|
|
|
(msg_type === "private" &&
|
|
|
|
opts.private_message_recipient === compose.recipient()));
|
|
|
|
}
|
|
|
|
|
2013-08-12 20:27:28 +02:00
|
|
|
function show_box_for_msg_type(msg_type, opts) {
|
|
|
|
var focus_area;
|
|
|
|
|
|
|
|
if (msg_type === 'stream' && opts.stream && ! opts.subject) {
|
|
|
|
focus_area = 'subject';
|
|
|
|
} else if ((msg_type === 'stream' && opts.stream)
|
|
|
|
|| (msg_type === 'private' && opts.private_message_recipient)) {
|
|
|
|
focus_area = 'new_message_content';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg_type === 'stream') {
|
2013-10-25 23:43:58 +02:00
|
|
|
show_box('stream', $("#" + (focus_area || 'stream')), opts);
|
2013-08-12 20:27:28 +02:00
|
|
|
} else {
|
2013-10-25 23:43:58 +02:00
|
|
|
show_box('private', $("#" + (focus_area || 'private_message_recipient')), opts);
|
2013-08-12 20:27:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-12 19:43:29 +02:00
|
|
|
exports.start = function (msg_type, opts) {
|
|
|
|
if (reload.is_in_progress()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-11-13 19:40:02 +01:00
|
|
|
notifications.clear_compose_notifications();
|
2013-08-12 19:43:29 +02:00
|
|
|
$("#compose_close").show();
|
|
|
|
$("#compose_controls").hide();
|
|
|
|
$('.message_comp').show();
|
|
|
|
|
|
|
|
opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
|
2013-11-26 21:46:34 +01:00
|
|
|
// If we are invoked by a compose hotkey (c or C), do not assume that we know
|
|
|
|
// what the message's topic or PM recipient should be.
|
|
|
|
if (opts.trigger === "compose_hotkey") {
|
|
|
|
opts.subject = '';
|
|
|
|
opts.private_message_recipient = '';
|
|
|
|
}
|
2012-10-18 20:16:56 +02:00
|
|
|
|
2013-11-26 23:42:39 +01:00
|
|
|
if (compose.composing() && !same_recipient_as_before(msg_type, opts)) {
|
2013-03-12 20:27:38 +01:00
|
|
|
// Clear the compose box if the existing message is to a different recipient
|
2013-07-12 23:26:18 +02:00
|
|
|
clear_box();
|
2013-03-12 20:27:38 +01:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:00:38 +01:00
|
|
|
compose.stream_name(opts.stream);
|
|
|
|
compose.subject(opts.subject);
|
2013-07-26 00:54:25 +02:00
|
|
|
|
|
|
|
// Set the recipients with a space after each comma, so it looks nice.
|
|
|
|
compose.recipient(opts.private_message_recipient.replace(/,\s*/g, ", "));
|
|
|
|
|
2012-12-05 17:29:56 +01:00
|
|
|
// If the user opens the compose box, types some text, and then clicks on a
|
|
|
|
// different stream/subject, we want to keep the text in the compose box
|
2013-04-17 19:43:02 +02:00
|
|
|
if (opts.content !== undefined) {
|
|
|
|
compose.message_content(opts.content);
|
2012-12-05 17:29:56 +01:00
|
|
|
}
|
2012-10-18 20:16:56 +02:00
|
|
|
|
2012-12-19 21:19:29 +01:00
|
|
|
ui.change_tab_to("#home");
|
2012-10-18 20:16:56 +02:00
|
|
|
|
2013-06-13 23:48:55 +02:00
|
|
|
is_composing_message = msg_type;
|
|
|
|
|
2013-08-12 20:27:28 +02:00
|
|
|
// Show either stream/topic fields or "You and" field.
|
|
|
|
show_box_for_msg_type(msg_type, opts);
|
2012-10-19 22:09:13 +02:00
|
|
|
|
2013-08-12 17:40:55 +02:00
|
|
|
compose_fade.start_compose(msg_type);
|
2013-02-13 21:30:17 +01:00
|
|
|
|
2013-01-15 22:19:38 +01:00
|
|
|
exports.decorate_stream_bar(opts.stream);
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).trigger($.Event('compose_started.zulip', opts));
|
2014-03-13 19:03:31 +01:00
|
|
|
resize.resize_bottom_whitespace();
|
2012-10-18 20:16:56 +02:00
|
|
|
};
|
|
|
|
|
2016-12-05 07:02:18 +01:00
|
|
|
function abort_xhr() {
|
2013-03-27 18:49:28 +01:00
|
|
|
$("#compose-send-button").removeAttr("disabled");
|
|
|
|
var xhr = $("#compose").data("filedrop_xhr");
|
|
|
|
if (xhr !== undefined) {
|
|
|
|
xhr.abort();
|
|
|
|
$("#compose").removeData("filedrop_xhr");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-18 20:16:56 +02:00
|
|
|
exports.cancel = function () {
|
2014-01-14 17:21:41 +01:00
|
|
|
if (page_params.narrow !== undefined) {
|
|
|
|
// Never close the compose box in narrow embedded windows, but
|
|
|
|
// at least clear the subject and unfade.
|
|
|
|
compose_fade.clear_compose();
|
2014-01-17 00:05:35 +01:00
|
|
|
if (page_params.narrow_topic !== undefined) {
|
|
|
|
compose.subject(page_params.narrow_topic);
|
|
|
|
} else {
|
|
|
|
compose.subject("");
|
|
|
|
}
|
2014-01-14 17:21:41 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-11-27 00:14:02 +01:00
|
|
|
hide_box();
|
2013-06-12 23:57:43 +02:00
|
|
|
$("#compose_close").hide();
|
2014-03-13 19:03:31 +01:00
|
|
|
resize.resize_bottom_whitespace();
|
2013-07-12 23:26:18 +02:00
|
|
|
clear_box();
|
2013-11-13 19:40:02 +01:00
|
|
|
notifications.clear_compose_notifications();
|
2013-03-27 18:49:28 +01:00
|
|
|
abort_xhr();
|
2012-10-19 19:51:19 +02:00
|
|
|
is_composing_message = false;
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).trigger($.Event('compose_canceled.zulip'));
|
2012-10-18 20:16:56 +02:00
|
|
|
};
|
|
|
|
|
2016-08-27 04:47:53 +02:00
|
|
|
exports.empty_topic_placeholder = function () {
|
2016-10-30 06:27:53 +01:00
|
|
|
return i18n.t("(no topic)");
|
2013-05-20 22:52:03 +02:00
|
|
|
};
|
|
|
|
|
2013-04-17 19:34:20 +02:00
|
|
|
function create_message_object() {
|
2013-05-20 22:52:03 +02:00
|
|
|
// Subjects are optional, and we provide a placeholder if one isn't given.
|
|
|
|
var subject = compose.subject();
|
|
|
|
if (subject === "") {
|
2016-08-27 04:47:53 +02:00
|
|
|
subject = compose.empty_topic_placeholder();
|
2013-05-20 22:52:03 +02:00
|
|
|
}
|
2013-10-23 16:46:18 +02:00
|
|
|
|
|
|
|
var content = make_uploads_relative(compose.message_content());
|
|
|
|
|
2013-12-19 17:03:08 +01:00
|
|
|
// Changes here must also be kept in sync with echo.try_deliver_locally
|
2017-02-17 22:15:38 +01:00
|
|
|
var message = {
|
|
|
|
type: compose.composing(),
|
|
|
|
content: content,
|
|
|
|
sender_id: page_params.user_id,
|
|
|
|
queue_id: page_params.event_queue_id,
|
2017-02-23 04:08:05 +01:00
|
|
|
stream: '',
|
|
|
|
subject: '',
|
2017-02-17 22:15:38 +01:00
|
|
|
};
|
2013-04-17 19:34:20 +02:00
|
|
|
|
|
|
|
if (message.type === "private") {
|
|
|
|
// TODO: this should be collapsed with the code in composebox_typeahead.js
|
2017-02-24 16:20:25 +01:00
|
|
|
var recipient = compose.recipient();
|
|
|
|
message.to = util.extract_pm_recipients(recipient);
|
|
|
|
message.reply_to = recipient;
|
|
|
|
message.private_message_recipient = recipient;
|
2013-04-17 19:34:20 +02:00
|
|
|
} else {
|
2017-02-23 04:08:05 +01:00
|
|
|
var stream_name = compose.stream_name();
|
|
|
|
message.to = stream_name;
|
|
|
|
message.stream = stream_name;
|
|
|
|
var sub = stream_data.get_sub(stream_name);
|
|
|
|
if (sub) {
|
|
|
|
message.stream_id = sub.stream_id;
|
|
|
|
}
|
|
|
|
message.subject = subject;
|
2013-04-17 19:34:20 +02:00
|
|
|
}
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
exports.snapshot_message = function (message) {
|
2013-04-05 16:44:46 +02:00
|
|
|
if (!exports.composing() || (exports.message_content() === "")) {
|
|
|
|
// If you aren't in the middle of composing the body of a
|
|
|
|
// message, don't try to snapshot.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message !== undefined) {
|
2017-02-22 02:34:05 +01:00
|
|
|
return _.extend({}, message);
|
2016-06-04 04:31:35 +02:00
|
|
|
}
|
2017-02-22 02:34:05 +01:00
|
|
|
// Save what we can.
|
|
|
|
return create_message_object();
|
2013-04-05 16:44:46 +02:00
|
|
|
};
|
|
|
|
|
2013-02-01 17:04:23 +01:00
|
|
|
function compose_error(error_text, bad_input) {
|
|
|
|
$('#send-status').removeClass(status_classes)
|
|
|
|
.addClass('alert-error')
|
|
|
|
.stop(true).fadeTo(0, 1);
|
2013-02-20 17:04:00 +01:00
|
|
|
$('#error-msg').html(error_text);
|
2013-02-01 17:04:23 +01:00
|
|
|
$("#compose-send-button").removeAttr('disabled');
|
2013-03-06 17:40:51 +01:00
|
|
|
$("#sending-indicator").hide();
|
2013-11-21 00:48:03 +01:00
|
|
|
if (bad_input !== undefined) {
|
|
|
|
bad_input.focus().select();
|
|
|
|
}
|
2013-02-01 17:04:23 +01:00
|
|
|
}
|
|
|
|
|
2013-12-19 17:03:08 +01:00
|
|
|
function send_message_ajax(request, success, error) {
|
2013-12-18 19:55:18 +01:00
|
|
|
channel.post({
|
2015-12-01 00:18:33 +01:00
|
|
|
url: '/json/messages',
|
2012-11-07 20:26:24 +01:00
|
|
|
data: request,
|
2013-09-11 20:42:12 +02:00
|
|
|
success: success,
|
2012-10-29 18:06:53 +01:00
|
|
|
error: function (xhr, error_type) {
|
2012-12-11 21:44:04 +01:00
|
|
|
if (error_type !== 'timeout' && reload.is_pending()) {
|
2012-10-29 18:06:53 +01:00
|
|
|
// The error might be due to the server changing
|
2015-11-30 17:47:19 +01:00
|
|
|
reload.initiate({immediate: true,
|
|
|
|
save_pointer: true,
|
|
|
|
save_narrow: true,
|
|
|
|
save_compose: true,
|
|
|
|
send_after_reload: true});
|
2012-10-29 18:06:53 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-12-19 17:03:08 +01:00
|
|
|
|
2014-03-13 15:32:44 +01:00
|
|
|
var response = channel.xhr_error_message("Error sending message", xhr);
|
2013-12-19 17:03:08 +01:00
|
|
|
error(response);
|
2017-01-12 00:17:43 +01:00
|
|
|
},
|
2012-11-07 20:26:24 +01:00
|
|
|
});
|
2013-09-11 20:42:12 +02:00
|
|
|
}
|
|
|
|
|
2014-01-16 21:38:30 +01:00
|
|
|
function report_send_time(send_time, receive_time, display_time, locally_echoed, rendered_changed) {
|
2016-12-03 03:08:47 +01:00
|
|
|
var data = {time: send_time.toString(),
|
|
|
|
received: receive_time.toString(),
|
|
|
|
displayed: display_time.toString(),
|
|
|
|
locally_echoed: locally_echoed};
|
2014-01-16 21:38:30 +01:00
|
|
|
if (locally_echoed) {
|
|
|
|
data.rendered_content_disparity = rendered_changed;
|
|
|
|
}
|
2013-12-18 19:55:18 +01:00
|
|
|
channel.post({
|
2013-11-04 23:58:51 +01:00
|
|
|
url: '/json/report_send_time',
|
2017-01-12 00:17:43 +01:00
|
|
|
data: data,
|
2013-11-04 23:58:51 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:45:12 +01:00
|
|
|
var socket;
|
2016-12-28 18:24:12 +01:00
|
|
|
if (page_params.use_websockets) {
|
2013-11-06 22:45:12 +01:00
|
|
|
socket = new Socket("/sockjs");
|
|
|
|
}
|
2013-10-24 23:08:31 +02:00
|
|
|
// For debugging. The socket will eventually move out of this file anyway.
|
|
|
|
exports._socket = socket;
|
|
|
|
|
2013-12-19 17:03:08 +01:00
|
|
|
function send_message_socket(request, success, error) {
|
2017-02-17 23:59:25 +01:00
|
|
|
request.socket_user_agent = navigator.userAgent;
|
2013-09-11 20:42:12 +02:00
|
|
|
socket.send(request, success, function (type, resp) {
|
|
|
|
var err_msg = "Error sending message";
|
|
|
|
if (type === 'response') {
|
|
|
|
err_msg += ": " + resp.msg;
|
|
|
|
}
|
2013-12-19 17:03:08 +01:00
|
|
|
error(err_msg);
|
2013-09-11 20:42:12 +02:00
|
|
|
});
|
|
|
|
}
|
2012-10-29 18:06:53 +01:00
|
|
|
|
2013-11-06 18:33:24 +01:00
|
|
|
exports.send_times_log = [];
|
2013-11-06 18:57:38 +01:00
|
|
|
exports.send_times_data = {};
|
|
|
|
function maybe_report_send_times(message_id) {
|
|
|
|
var data = exports.send_times_data[message_id];
|
2013-11-07 00:09:40 +01:00
|
|
|
if (data.send_finished === undefined || data.received === undefined ||
|
|
|
|
data.displayed === undefined) {
|
2013-11-06 18:57:38 +01:00
|
|
|
// We report the data once we have both the send and receive times
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
report_send_time(data.send_finished - data.start,
|
2013-11-06 19:05:06 +01:00
|
|
|
data.received - data.start,
|
2014-01-16 21:38:30 +01:00
|
|
|
data.displayed - data.start,
|
|
|
|
data.locally_echoed,
|
|
|
|
data.rendered_content_disparity || false);
|
2013-11-06 18:57:38 +01:00
|
|
|
}
|
|
|
|
|
2014-01-31 22:08:58 +01:00
|
|
|
function mark_end_to_end_receive_time(message_id) {
|
2013-11-06 18:57:38 +01:00
|
|
|
if (exports.send_times_data[message_id] === undefined) {
|
|
|
|
exports.send_times_data[message_id] = {};
|
|
|
|
}
|
|
|
|
exports.send_times_data[message_id].received = new Date();
|
|
|
|
maybe_report_send_times(message_id);
|
2014-01-31 22:08:58 +01:00
|
|
|
}
|
2013-11-06 18:57:38 +01:00
|
|
|
|
2014-01-31 22:08:58 +01:00
|
|
|
function mark_end_to_end_display_time(message_id) {
|
2013-11-06 19:05:06 +01:00
|
|
|
if (exports.send_times_data[message_id] === undefined) {
|
|
|
|
exports.send_times_data[message_id] = {};
|
|
|
|
}
|
|
|
|
exports.send_times_data[message_id].displayed = new Date();
|
|
|
|
maybe_report_send_times(message_id);
|
2014-01-31 22:08:58 +01:00
|
|
|
}
|
2013-11-06 19:05:06 +01:00
|
|
|
|
2014-01-16 21:38:30 +01:00
|
|
|
exports.mark_rendered_content_disparity = function (message_id, changed) {
|
|
|
|
if (exports.send_times_data[message_id] === undefined) {
|
|
|
|
exports.send_times_data[message_id] = {};
|
|
|
|
}
|
|
|
|
exports.send_times_data[message_id].rendered_content_disparity = changed;
|
|
|
|
};
|
|
|
|
|
2014-01-31 22:08:58 +01:00
|
|
|
exports.report_as_received = function report_as_received(message) {
|
|
|
|
if (message.sent_by_me) {
|
|
|
|
mark_end_to_end_receive_time(message.id);
|
|
|
|
setTimeout(function () {
|
|
|
|
mark_end_to_end_display_time(message.id);
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-16 21:38:30 +01:00
|
|
|
function process_send_time(message_id, start_time, locally_echoed) {
|
2013-11-06 18:57:38 +01:00
|
|
|
var send_finished = new Date();
|
|
|
|
var send_time = (send_finished - start_time);
|
|
|
|
if (feature_flags.log_send_times) {
|
|
|
|
blueslip.log("send time: " + send_time);
|
|
|
|
}
|
|
|
|
if (feature_flags.collect_send_times) {
|
|
|
|
exports.send_times_log.push(send_time);
|
|
|
|
}
|
|
|
|
if (exports.send_times_data[message_id] === undefined) {
|
|
|
|
exports.send_times_data[message_id] = {};
|
|
|
|
}
|
|
|
|
exports.send_times_data[message_id].start = start_time;
|
|
|
|
exports.send_times_data[message_id].send_finished = send_finished;
|
2014-01-16 21:38:30 +01:00
|
|
|
exports.send_times_data[message_id].locally_echoed = locally_echoed;
|
2013-11-06 18:57:38 +01:00
|
|
|
maybe_report_send_times(message_id);
|
|
|
|
}
|
|
|
|
|
2013-12-03 20:59:23 +01:00
|
|
|
function clear_compose_box() {
|
|
|
|
$("#new_message_content").val('').focus();
|
2017-02-22 02:34:05 +01:00
|
|
|
drafts.delete_draft_after_send();
|
2017-01-04 04:13:15 +01:00
|
|
|
exports.autosize_textarea();
|
2013-12-03 20:59:23 +01:00
|
|
|
$("#send-status").hide(0);
|
|
|
|
$("#compose-send-button").removeAttr('disabled');
|
|
|
|
$("#sending-indicator").hide();
|
2014-03-13 19:03:31 +01:00
|
|
|
resize.resize_bottom_whitespace();
|
2013-12-03 20:59:23 +01:00
|
|
|
}
|
|
|
|
|
2014-01-16 21:38:30 +01:00
|
|
|
exports.send_message_success = function (local_id, message_id, start_time, locally_echoed) {
|
2014-01-24 17:03:33 +01:00
|
|
|
if (! feature_flags.local_echo || !locally_echoed) {
|
2013-12-19 17:03:08 +01:00
|
|
|
clear_compose_box();
|
|
|
|
}
|
|
|
|
|
2014-01-16 21:38:30 +01:00
|
|
|
process_send_time(message_id, start_time, locally_echoed);
|
2013-12-19 17:03:08 +01:00
|
|
|
|
|
|
|
if (feature_flags.local_echo) {
|
|
|
|
echo.reify_message_id(local_id, message_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
if (exports.send_times_data[message_id].received === undefined) {
|
2014-03-06 19:39:11 +01:00
|
|
|
blueslip.log("Restarting get_events due to delayed receipt of sent message " + message_id);
|
2014-01-30 20:29:00 +01:00
|
|
|
server_events.restart_get_events();
|
2013-12-19 17:03:08 +01:00
|
|
|
}
|
|
|
|
}, 5000);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.transmit_message = function (request, success, error) {
|
2014-01-16 21:38:30 +01:00
|
|
|
delete exports.send_times_data[request.id];
|
2016-12-28 18:24:12 +01:00
|
|
|
if (page_params.use_websockets) {
|
2013-12-19 17:03:08 +01:00
|
|
|
send_message_socket(request, success, error);
|
|
|
|
} else {
|
|
|
|
send_message_ajax(request, success, error);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-23 17:39:05 +02:00
|
|
|
function send_message(request) {
|
|
|
|
if (request === undefined) {
|
|
|
|
request = create_message_object();
|
|
|
|
}
|
2013-09-11 20:42:12 +02:00
|
|
|
|
|
|
|
if (request.type === "private") {
|
|
|
|
request.to = JSON.stringify(request.to);
|
|
|
|
} else {
|
|
|
|
request.to = JSON.stringify([request.to]);
|
|
|
|
}
|
|
|
|
|
2013-10-21 22:29:33 +02:00
|
|
|
var start_time = new Date();
|
2013-12-19 17:03:08 +01:00
|
|
|
var local_id;
|
|
|
|
if (feature_flags.local_echo) {
|
|
|
|
local_id = echo.try_deliver_locally(request);
|
|
|
|
if (local_id !== undefined) {
|
|
|
|
// We delivered this message locally
|
|
|
|
request.local_id = local_id;
|
|
|
|
}
|
|
|
|
}
|
2014-01-24 17:03:33 +01:00
|
|
|
var locally_echoed = local_id !== undefined;
|
2013-12-19 17:03:08 +01:00
|
|
|
|
2013-11-06 18:57:38 +01:00
|
|
|
function success(data) {
|
2014-01-24 17:03:33 +01:00
|
|
|
exports.send_message_success(local_id, data.id, start_time, locally_echoed);
|
2013-12-19 17:03:08 +01:00
|
|
|
}
|
2013-11-04 23:58:51 +01:00
|
|
|
|
2013-12-19 17:03:08 +01:00
|
|
|
function error(response) {
|
|
|
|
// If we're not local echo'ing messages, or if this message was not
|
|
|
|
// locally echoed, show error in compose box
|
|
|
|
if (!feature_flags.local_echo || request.local_id === undefined) {
|
|
|
|
compose_error(response, $('#new_message_content'));
|
|
|
|
return;
|
2013-12-03 20:59:23 +01:00
|
|
|
}
|
2013-10-31 15:56:30 +01:00
|
|
|
|
2014-01-02 17:34:16 +01:00
|
|
|
echo.message_send_error(local_id, response);
|
2013-09-11 20:42:12 +02:00
|
|
|
}
|
|
|
|
|
2013-12-19 17:03:08 +01:00
|
|
|
exports.transmit_message(request, success, error);
|
2014-01-30 20:29:00 +01:00
|
|
|
server_events.assert_get_events_running("Restarting get_events because it was not running during send");
|
2013-12-03 20:59:23 +01:00
|
|
|
|
2014-01-24 17:03:33 +01:00
|
|
|
if (feature_flags.local_echo && locally_echoed) {
|
2013-12-03 20:59:23 +01:00
|
|
|
clear_compose_box();
|
|
|
|
}
|
2012-11-07 20:26:24 +01:00
|
|
|
}
|
2012-10-29 18:06:53 +01:00
|
|
|
|
2017-02-19 07:43:02 +01:00
|
|
|
exports.enter_with_preview_open = function () {
|
|
|
|
clear_preview_area();
|
|
|
|
if (page_params.enter_sends) {
|
|
|
|
// If enter_sends is enabled, we just send the message
|
|
|
|
send_message();
|
|
|
|
} else {
|
|
|
|
// Otherwise, we return to the compose box and focus it
|
|
|
|
$("#new_message_content").focus();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-29 00:27:50 +02:00
|
|
|
exports.respond_to_message = function (opts) {
|
2016-12-02 17:09:31 +01:00
|
|
|
var message;
|
|
|
|
var msg_type;
|
2016-06-29 00:27:50 +02:00
|
|
|
// Before initiating a reply to a message, if there's an
|
|
|
|
// in-progress composition, snapshot it.
|
2017-02-22 02:34:05 +01:00
|
|
|
drafts.update_draft();
|
2016-06-29 00:27:50 +02:00
|
|
|
|
|
|
|
message = current_msg_list.selected_message();
|
|
|
|
|
|
|
|
if (message === undefined) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-11 09:55:18 +01:00
|
|
|
unread_ui.mark_message_as_read(message);
|
2016-06-29 00:27:50 +02:00
|
|
|
|
|
|
|
var stream = '';
|
|
|
|
var subject = '';
|
|
|
|
if (message.type === "stream") {
|
|
|
|
stream = message.stream;
|
|
|
|
subject = message.subject;
|
|
|
|
}
|
|
|
|
|
|
|
|
var pm_recipient = message.reply_to;
|
2017-02-09 03:18:40 +01:00
|
|
|
if (message.type === "private") {
|
|
|
|
if (opts.reply_type === "personal") {
|
|
|
|
// reply_to for private messages is everyone involved, so for
|
|
|
|
// personals replies we need to set the private message
|
|
|
|
// recipient to just the sender
|
|
|
|
pm_recipient = people.get_person_from_user_id(message.sender_id).email;
|
|
|
|
} else {
|
|
|
|
pm_recipient = people.pm_reply_to(message);
|
|
|
|
}
|
2016-06-29 00:27:50 +02:00
|
|
|
}
|
|
|
|
if (opts.reply_type === 'personal' || message.type === 'private') {
|
|
|
|
msg_type = 'private';
|
|
|
|
} else {
|
|
|
|
msg_type = message.type;
|
|
|
|
}
|
2016-12-03 03:08:47 +01:00
|
|
|
compose.start(msg_type, {stream: stream, subject: subject,
|
|
|
|
private_message_recipient: pm_recipient,
|
|
|
|
replying_to_message: message,
|
|
|
|
trigger: opts.trigger});
|
2016-06-29 00:27:50 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-10-23 17:39:05 +02:00
|
|
|
// This function is for debugging / data collection only. Arguably it
|
|
|
|
// should live in debug.js, but then it wouldn't be able to call
|
|
|
|
// send_message() directly below.
|
|
|
|
exports.test_send_many_messages = function (stream, subject, count) {
|
|
|
|
var num_sent = 0;
|
|
|
|
|
2016-12-05 07:02:18 +01:00
|
|
|
function do_send_one() {
|
2013-10-23 17:39:05 +02:00
|
|
|
var message = {};
|
|
|
|
num_sent += 1;
|
|
|
|
|
|
|
|
message.type = "stream";
|
|
|
|
message.to = stream;
|
|
|
|
message.subject = subject;
|
|
|
|
message.content = num_sent.toString();
|
|
|
|
|
|
|
|
send_message(message);
|
|
|
|
|
|
|
|
if (num_sent === count) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(do_send_one, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
do_send_one();
|
|
|
|
};
|
|
|
|
|
2012-10-18 20:16:56 +02:00
|
|
|
exports.finish = function () {
|
2013-09-16 21:13:11 +02:00
|
|
|
clear_invites();
|
|
|
|
|
2012-10-29 22:37:34 +01:00
|
|
|
if (! compose.validate()) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-07 20:26:24 +01:00
|
|
|
send_message();
|
2016-08-29 22:37:27 +02:00
|
|
|
clear_preview_area();
|
2012-11-07 19:59:35 +01:00
|
|
|
// TODO: Do we want to fire the event even if the send failed due
|
|
|
|
// to a server-side error?
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).trigger($.Event('compose_finished.zulip'));
|
2012-10-29 22:37:34 +01:00
|
|
|
return true;
|
2012-10-18 20:16:56 +02:00
|
|
|
};
|
|
|
|
|
2012-10-29 18:06:53 +01:00
|
|
|
$(function () {
|
|
|
|
$("#compose form").on("submit", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
compose.finish();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-10-18 20:29:16 +02:00
|
|
|
exports.composing = function () {
|
2012-10-19 19:51:19 +02:00
|
|
|
return is_composing_message;
|
2012-10-18 20:29:16 +02:00
|
|
|
};
|
2012-10-11 20:30:34 +02:00
|
|
|
|
2017-02-12 04:30:55 +01:00
|
|
|
function get_or_set(fieldname, keep_leading_whitespace) {
|
2012-10-31 22:12:45 +01:00
|
|
|
// We can't hoist the assignment of 'elem' out of this lambda,
|
|
|
|
// because the DOM element might not exist yet when get_or_set
|
|
|
|
// is called.
|
|
|
|
return function (newval) {
|
|
|
|
var elem = $('#'+fieldname);
|
2013-01-29 00:28:56 +01:00
|
|
|
var oldval = elem.val();
|
2012-10-31 22:12:45 +01:00
|
|
|
if (newval !== undefined) {
|
|
|
|
elem.val(newval);
|
|
|
|
}
|
2017-02-12 04:30:55 +01:00
|
|
|
return keep_leading_whitespace ? util.rtrim(oldval) : $.trim(oldval);
|
2012-10-31 22:12:45 +01:00
|
|
|
};
|
|
|
|
}
|
2012-10-03 20:49:58 +02:00
|
|
|
|
2012-10-31 22:12:45 +01:00
|
|
|
exports.stream_name = get_or_set('stream');
|
|
|
|
exports.subject = get_or_set('subject');
|
2017-02-12 04:30:55 +01:00
|
|
|
// We can't trim leading whitespace in `new_message_content` because
|
|
|
|
// of the indented syntax for multi-line code blocks.
|
2013-01-29 00:28:56 +01:00
|
|
|
exports.message_content = get_or_set('new_message_content', true);
|
2012-11-08 00:38:21 +01:00
|
|
|
exports.recipient = get_or_set('private_message_recipient');
|
2012-10-03 20:49:58 +02:00
|
|
|
|
2013-10-10 16:43:49 +02:00
|
|
|
exports.has_message_content = function () {
|
|
|
|
return exports.message_content() !== "";
|
|
|
|
};
|
|
|
|
|
2017-02-10 20:03:23 +01:00
|
|
|
exports.update_email = function (user_id, new_email) {
|
|
|
|
var reply_to = exports.recipient();
|
|
|
|
|
|
|
|
if (!reply_to) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
reply_to = people.update_email_in_reply_to(reply_to, user_id, new_email);
|
|
|
|
|
|
|
|
exports.recipient(reply_to);
|
|
|
|
};
|
2013-10-10 16:43:49 +02:00
|
|
|
|
2012-10-10 23:37:14 +02:00
|
|
|
// *Synchronously* check if a stream exists.
|
2013-12-13 20:20:28 +01:00
|
|
|
exports.check_stream_existence = function (stream_name, autosubscribe) {
|
2012-11-15 19:13:33 +01:00
|
|
|
var result = "error";
|
2016-12-03 03:08:47 +01:00
|
|
|
var request = {stream: stream_name};
|
2013-12-13 20:20:28 +01:00
|
|
|
if (autosubscribe) {
|
|
|
|
request.autosubscribe = true;
|
|
|
|
}
|
2013-12-18 19:55:18 +01:00
|
|
|
channel.post({
|
2012-10-17 20:05:17 +02:00
|
|
|
url: "/json/subscriptions/exists",
|
2013-12-13 20:20:28 +01:00
|
|
|
data: request,
|
2012-10-03 22:53:15 +02:00
|
|
|
async: false,
|
|
|
|
success: function (data) {
|
2013-03-21 19:58:30 +01:00
|
|
|
if (data.subscribed) {
|
2012-11-15 19:13:33 +01:00
|
|
|
result = "subscribed";
|
|
|
|
} else {
|
|
|
|
result = "not-subscribed";
|
2012-10-03 22:53:15 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function (xhr) {
|
2013-03-21 19:58:30 +01:00
|
|
|
if (xhr.status === 404) {
|
|
|
|
result = "does-not-exist";
|
|
|
|
} else {
|
|
|
|
result = "error";
|
|
|
|
}
|
2017-01-12 00:17:43 +01:00
|
|
|
},
|
2012-10-03 22:53:15 +02:00
|
|
|
});
|
2013-03-11 23:13:37 +01:00
|
|
|
return result;
|
2013-01-31 21:03:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Checks if a stream exists. If not, displays an error and returns
|
|
|
|
// false.
|
2013-12-13 20:20:28 +01:00
|
|
|
function check_stream_for_send(stream_name, autosubscribe) {
|
|
|
|
var result = exports.check_stream_existence(stream_name, autosubscribe);
|
2013-01-31 21:03:45 +01:00
|
|
|
|
|
|
|
if (result === "error") {
|
2016-06-13 08:40:35 +02:00
|
|
|
compose_error(i18n.t("Error checking subscription"), $("#stream"));
|
2013-01-31 21:03:45 +01:00
|
|
|
$("#compose-send-button").removeAttr('disabled');
|
2013-03-06 17:40:51 +01:00
|
|
|
$("#sending-indicator").hide();
|
2013-01-31 21:03:45 +01:00
|
|
|
}
|
|
|
|
|
2012-11-15 19:13:33 +01:00
|
|
|
return result;
|
2012-10-03 22:53:15 +02:00
|
|
|
}
|
|
|
|
|
2017-01-05 12:05:51 +01:00
|
|
|
function validate_stream_message_mentions(stream_name) {
|
2016-11-09 19:34:07 +01:00
|
|
|
var current_stream = stream_data.get_sub(stream_name);
|
|
|
|
var stream_count = current_stream.subscribers.num_items();
|
|
|
|
|
2016-06-04 04:31:35 +02:00
|
|
|
// check if @all or @everyone is in the message
|
2016-11-09 19:34:07 +01:00
|
|
|
if (util.is_all_or_everyone_mentioned(exports.message_content()) &&
|
|
|
|
stream_count > compose.all_everyone_warn_threshold) {
|
2016-06-04 04:31:35 +02:00
|
|
|
if (user_acknowledged_all_everyone === undefined ||
|
|
|
|
user_acknowledged_all_everyone === false) {
|
|
|
|
// user has not seen a warning message yet if undefined
|
|
|
|
show_all_everyone_warnings();
|
2016-11-09 19:34:07 +01:00
|
|
|
|
|
|
|
$("#compose-send-button").removeAttr('disabled');
|
|
|
|
$("#sending-indicator").hide();
|
2016-06-04 04:31:35 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// the message no longer contains @all or @everyone
|
|
|
|
clear_all_everyone_warnings();
|
|
|
|
}
|
|
|
|
// at this point, the user has either acknowledged the warning or removed @all / @everyone
|
|
|
|
user_acknowledged_all_everyone = undefined;
|
|
|
|
|
2017-01-05 12:05:51 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate_stream_message_address_info(stream_name) {
|
2013-02-01 17:04:23 +01:00
|
|
|
var response;
|
|
|
|
|
2013-08-15 21:11:07 +02:00
|
|
|
if (!stream_data.is_subscribed(stream_name)) {
|
2016-12-01 20:02:56 +01:00
|
|
|
switch (check_stream_for_send(stream_name, page_params.narrow_stream !== undefined)) {
|
2012-11-15 19:13:33 +01:00
|
|
|
case "does-not-exist":
|
2013-02-20 17:04:00 +01:00
|
|
|
response = "<p>The stream <b>" +
|
|
|
|
Handlebars.Utils.escapeExpression(stream_name) + "</b> does not exist.</p>" +
|
|
|
|
"<p>Manage your subscriptions <a href='#subscriptions'>on your Streams page</a>.</p>";
|
2013-02-01 17:04:23 +01:00
|
|
|
compose_error(response, $('#stream'));
|
|
|
|
return false;
|
2017-01-05 12:05:51 +01:00
|
|
|
case "error":
|
|
|
|
return false;
|
2012-11-15 19:13:33 +01:00
|
|
|
case "not-subscribed":
|
2013-02-20 17:04:00 +01:00
|
|
|
response = "<p>You're not subscribed to the stream <b>" +
|
|
|
|
Handlebars.Utils.escapeExpression(stream_name) + "</b>.</p>" +
|
|
|
|
"<p>Manage your subscriptions <a href='#subscriptions'>on your Streams page</a>.</p>";
|
2013-02-01 17:04:23 +01:00
|
|
|
compose_error(response, $('#stream'));
|
2012-10-18 19:26:39 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-10-03 23:13:38 +02:00
|
|
|
}
|
|
|
|
|
2012-10-03 22:39:05 +02:00
|
|
|
return true;
|
|
|
|
}
|
2017-01-05 12:05:51 +01:00
|
|
|
|
|
|
|
function validate_stream_message() {
|
|
|
|
var stream_name = exports.stream_name();
|
|
|
|
if (stream_name === "") {
|
|
|
|
compose_error(i18n.t("Please specify a stream"), $("#stream"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page_params.mandatory_topics) {
|
|
|
|
var topic = exports.subject();
|
|
|
|
if (topic === "") {
|
|
|
|
compose_error(i18n.t("Please specify a topic"), $("#subject"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-05 12:10:47 +01:00
|
|
|
if (!validate_stream_message_address_info(stream_name) ||
|
|
|
|
!validate_stream_message_mentions(stream_name)) {
|
2017-01-05 12:05:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-02 15:16:33 +01:00
|
|
|
// The function checks whether the recipients are users of the realm or cross realm users (bots
|
|
|
|
// for now)
|
2012-11-08 00:38:21 +01:00
|
|
|
function validate_private_message() {
|
2012-10-18 20:29:16 +02:00
|
|
|
if (exports.recipient() === "") {
|
2016-06-13 08:40:35 +02:00
|
|
|
compose_error(i18n.t("Please specify at least one recipient"), $("#private_message_recipient"));
|
2012-10-03 22:39:05 +02:00
|
|
|
return false;
|
2016-08-11 00:35:52 +02:00
|
|
|
} else if (page_params.is_zephyr_mirror_realm) {
|
|
|
|
// For Zephyr mirroring realms, the frontend doesn't know which users exist
|
|
|
|
return true;
|
2016-12-02 21:34:35 +01:00
|
|
|
}
|
|
|
|
var private_recipients = util.extract_pm_recipients(compose.recipient());
|
|
|
|
var invalid_recipients = [];
|
|
|
|
var context = {};
|
|
|
|
_.each(private_recipients, function (email) {
|
|
|
|
// This case occurs when exports.recipient() ends with ','
|
|
|
|
if (email === "") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (people.realm_get(email) !== undefined) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (people.is_cross_realm_email(email)) {
|
|
|
|
return;
|
2016-06-10 19:46:53 +02:00
|
|
|
}
|
2016-12-02 21:34:35 +01:00
|
|
|
invalid_recipients.push(email);
|
|
|
|
});
|
|
|
|
if (invalid_recipients.length === 1) {
|
2016-12-03 03:08:47 +01:00
|
|
|
context = {recipient: invalid_recipients.join()};
|
2016-12-02 21:34:35 +01:00
|
|
|
compose_error(i18n.t("The recipient __recipient__ is not valid ", context), $("#private_message_recipient"));
|
|
|
|
return false;
|
|
|
|
} else if (invalid_recipients.length > 1) {
|
2016-12-03 03:08:47 +01:00
|
|
|
context = {recipients: invalid_recipients.join()};
|
2016-12-02 21:34:35 +01:00
|
|
|
compose_error(i18n.t("The recipients __recipients__ are not valid ", context), $("#private_message_recipient"));
|
|
|
|
return false;
|
2016-06-10 19:46:53 +02:00
|
|
|
}
|
2016-12-02 21:34:35 +01:00
|
|
|
return true;
|
2012-10-03 22:39:05 +02:00
|
|
|
}
|
2012-10-03 23:13:38 +02:00
|
|
|
|
2012-10-18 20:29:16 +02:00
|
|
|
exports.validate = function () {
|
2012-10-31 21:17:07 +01:00
|
|
|
$("#compose-send-button").attr('disabled', 'disabled').blur();
|
2013-03-06 17:40:51 +01:00
|
|
|
$("#sending-indicator").show();
|
2012-10-03 23:13:38 +02:00
|
|
|
|
2013-08-16 23:34:25 +02:00
|
|
|
if (/^\s*$/.test(exports.message_content())) {
|
2016-06-13 08:40:35 +02:00
|
|
|
compose_error(i18n.t("You have nothing to send!"), $("#new_message_content"));
|
2012-10-31 22:18:48 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-21 00:48:03 +01:00
|
|
|
if ($("#zephyr-mirror-error").is(":visible")) {
|
2016-06-13 08:40:35 +02:00
|
|
|
compose_error(i18n.t("You need to be running Zephyr mirroring in order to send messages!"));
|
2013-11-21 00:48:03 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-08 00:38:21 +01:00
|
|
|
if (exports.composing() === 'private') {
|
|
|
|
return validate_private_message();
|
2012-10-03 23:13:38 +02:00
|
|
|
}
|
2016-12-02 21:34:35 +01:00
|
|
|
return validate_stream_message();
|
2012-10-18 20:29:16 +02:00
|
|
|
};
|
|
|
|
|
2012-10-24 04:02:39 +02:00
|
|
|
$(function () {
|
|
|
|
$("#new_message_content").autosize();
|
2013-05-03 22:16:52 +02:00
|
|
|
|
2013-08-11 19:57:44 +02:00
|
|
|
// Run a feature test and decide whether to display
|
|
|
|
// the "Attach files" button
|
|
|
|
if (window.XMLHttpRequest && (new XMLHttpRequest()).upload) {
|
|
|
|
$("#compose #attach_files").removeClass("notdisplayed");
|
|
|
|
}
|
2013-08-26 19:00:38 +02:00
|
|
|
|
|
|
|
// Lazy load the Dropbox script, since it can slow our page load
|
|
|
|
// otherwise, and isn't enabled for all users. Also, this Dropbox
|
|
|
|
// script isn't under an open source license, so we can't (for legal
|
|
|
|
// reasons) minify it with our own code.
|
|
|
|
if (feature_flags.dropbox_integration) {
|
|
|
|
LazyLoad.js('https://www.dropbox.com/static/api/1/dropins.js', function () {
|
|
|
|
// Successful load. We should now have window.Dropbox.
|
|
|
|
if (! _.has(window, 'Dropbox')) {
|
|
|
|
blueslip.error('Dropbox script reports loading but window.Dropbox undefined');
|
|
|
|
} else if (Dropbox.isBrowserSupported()) {
|
|
|
|
Dropbox.init({appKey: window.dropboxAppKey});
|
|
|
|
$("#compose #attach_dropbox_files").removeClass("notdisplayed");
|
|
|
|
}
|
|
|
|
});
|
2013-08-11 19:57:44 +02:00
|
|
|
}
|
|
|
|
|
2013-09-16 21:13:11 +02:00
|
|
|
// Show a warning if a user @-mentions someone who will not receive this message
|
|
|
|
$(document).on('usermention_completed.zulip', function (event, data) {
|
|
|
|
// Legacy strangeness: is_composing_message can be false, "stream", or "private"
|
2016-07-27 01:45:29 +02:00
|
|
|
// Disable for Zephyr mirroring realms, since we never have subscriber lists there
|
|
|
|
if (is_composing_message !== "stream" || page_params.is_zephyr_mirror_realm) {
|
2013-09-16 21:13:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data !== undefined && data.mentioned !== undefined) {
|
|
|
|
var email = data.mentioned.email;
|
2016-06-04 04:31:35 +02:00
|
|
|
|
|
|
|
// warn if @all or @everyone is mentioned
|
|
|
|
if (data.mentioned.full_name === 'all' || data.mentioned.full_name === 'everyone') {
|
|
|
|
return; // don't check if @all or @everyone is subscribed to a stream
|
|
|
|
}
|
|
|
|
|
2013-10-18 16:51:26 +02:00
|
|
|
if (compose_fade.would_receive_message(email) === false) {
|
2016-12-02 15:16:33 +01:00
|
|
|
var new_row = templates.render("compose-invite-users",
|
|
|
|
{email: email, name: data.mentioned.full_name});
|
2013-09-16 21:13:11 +02:00
|
|
|
var error_area = $("#compose_invite_users");
|
|
|
|
|
|
|
|
var existing_invites = _.map($(".compose_invite_user", error_area), function (user_row) {
|
|
|
|
return $(user_row).data('useremail');
|
|
|
|
});
|
|
|
|
|
|
|
|
if (existing_invites.indexOf(email) === -1) {
|
|
|
|
error_area.append(new_row);
|
|
|
|
}
|
|
|
|
|
|
|
|
error_area.show();
|
|
|
|
}
|
|
|
|
}
|
2016-06-04 04:31:35 +02:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#compose-all-everyone").on('click', '.compose-all-everyone-confirm', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
$(event.target).parents('.compose-all-everyone').remove();
|
|
|
|
user_acknowledged_all_everyone = true;
|
|
|
|
clear_all_everyone_warnings();
|
2016-11-09 19:34:07 +01:00
|
|
|
compose.finish();
|
2013-09-16 21:13:11 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#compose_invite_users").on('click', '.compose_invite_link', function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
var invite_row = $(event.target).parents('.compose_invite_user');
|
|
|
|
|
|
|
|
var email = $(invite_row).data('useremail');
|
|
|
|
if (email !== undefined) {
|
|
|
|
subs.invite_user_to_stream(email, compose.stream_name(), function () {
|
|
|
|
var all_invites = $("#compose_invite_users");
|
|
|
|
invite_row.remove();
|
|
|
|
|
|
|
|
if (all_invites.children().length === 0) {
|
|
|
|
all_invites.hide();
|
|
|
|
}
|
|
|
|
}, function () {
|
|
|
|
var error_msg = invite_row.find('.compose_invite_user_error');
|
|
|
|
error_msg.show();
|
|
|
|
|
|
|
|
$(event.target).attr('disabled', true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#compose_invite_users").on('click', '.compose_invite_close', function (event) {
|
|
|
|
var invite_row = $(event.target).parents('.compose_invite_user');
|
|
|
|
var all_invites = $("#compose_invite_users");
|
|
|
|
|
|
|
|
invite_row.remove();
|
|
|
|
|
|
|
|
if (all_invites.children().length === 0) {
|
|
|
|
all_invites.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-08-11 19:57:44 +02:00
|
|
|
// Click event binding for "Attach files" button
|
|
|
|
// Triggers a click on a hidden file input field
|
|
|
|
|
|
|
|
$("#compose").on("click", "#attach_files", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$("#compose #file_input").trigger("click");
|
|
|
|
} );
|
|
|
|
|
2016-08-29 22:37:27 +02:00
|
|
|
|
|
|
|
$("#compose").on("click", "#markdown_preview", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var message = $("#new_message_content").val();
|
|
|
|
$("#new_message_content").hide();
|
|
|
|
$("#markdown_preview").hide();
|
|
|
|
$("#undo_markdown_preview").show();
|
|
|
|
$("#preview_message_area").show();
|
|
|
|
|
|
|
|
if (message.length === 0) {
|
2016-09-26 22:03:42 +02:00
|
|
|
$("#preview_content").html(i18n.t("Nothing to preview"));
|
2016-08-29 22:37:27 +02:00
|
|
|
} else {
|
2016-09-24 12:16:42 +02:00
|
|
|
if (echo.contains_bugdown(message)) {
|
2016-09-26 22:03:42 +02:00
|
|
|
var spinner = $("#markdown_preview_spinner").expectOne();
|
|
|
|
loading.make_indicator(spinner);
|
2016-09-24 12:16:42 +02:00
|
|
|
} else {
|
|
|
|
// For messages that don't appear to contain
|
|
|
|
// bugdown-specific syntax not present in our
|
|
|
|
// marked.js frontend processor, we render using the
|
|
|
|
// frontend markdown processor message (but still
|
|
|
|
// render server-side to ensure the preview is
|
|
|
|
// accurate; if the `echo.contains_bugdown` logic is
|
|
|
|
// incorrect wrong, users will see a brief flicker).
|
2016-09-26 22:03:42 +02:00
|
|
|
$("#preview_content").html(echo.apply_markdown(message));
|
2016-09-24 12:16:42 +02:00
|
|
|
}
|
2017-01-13 01:10:19 +01:00
|
|
|
channel.post({
|
2016-09-24 12:16:42 +02:00
|
|
|
url: '/json/messages/render',
|
|
|
|
idempotent: true,
|
|
|
|
data: {content: message},
|
|
|
|
success: function (response_data) {
|
2016-09-26 22:03:42 +02:00
|
|
|
if (echo.contains_bugdown(message)) {
|
|
|
|
loading.destroy_indicator($("#markdown_preview_spinner"));
|
|
|
|
}
|
|
|
|
$("#preview_content").html(response_data.rendered);
|
2016-09-24 12:16:42 +02:00
|
|
|
},
|
|
|
|
error: function () {
|
2016-09-26 22:03:42 +02:00
|
|
|
if (echo.contains_bugdown(message)) {
|
|
|
|
loading.destroy_indicator($("#markdown_preview_spinner"));
|
|
|
|
}
|
|
|
|
$("#preview_content").html(i18n.t("Failed to generate preview"));
|
2017-01-12 00:17:43 +01:00
|
|
|
},
|
2016-09-24 12:16:42 +02:00
|
|
|
});
|
2016-08-29 22:37:27 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#compose").on("click", "#undo_markdown_preview", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
clear_preview_area();
|
|
|
|
});
|
|
|
|
|
2013-08-11 19:57:44 +02:00
|
|
|
$("#compose").on("click", "#attach_dropbox_files", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var options = {
|
|
|
|
// Required. Called when a user selects an item in the Chooser.
|
|
|
|
success: function (files) {
|
|
|
|
var textbox = $("#new_message_content");
|
|
|
|
var links = _.map(files, function (file) { return '[' + file.name + '](' + file.link +')'; })
|
|
|
|
.join(' ') + ' ';
|
|
|
|
textbox.val(textbox.val() + links);
|
|
|
|
},
|
|
|
|
// Optional. A value of false (default) limits selection to a single file, while
|
|
|
|
// true enables multiple file selection.
|
2013-08-14 16:31:12 +02:00
|
|
|
multiselect: true,
|
2017-01-12 00:17:43 +01:00
|
|
|
iframe: true,
|
2013-08-11 19:57:44 +02:00
|
|
|
};
|
|
|
|
Dropbox.choose(options);
|
|
|
|
});
|
|
|
|
|
2016-12-15 07:26:09 +01:00
|
|
|
function uploadStarted() {
|
2013-11-15 19:30:57 +01:00
|
|
|
$("#compose-send-button").attr("disabled", "");
|
|
|
|
$("#send-status").addClass("alert-info")
|
|
|
|
.show();
|
|
|
|
$(".send-status-close").one('click', abort_xhr);
|
|
|
|
$("#error-msg").html(
|
|
|
|
$("<p>").text("Uploading…")
|
|
|
|
.after('<div class="progress progress-striped active">' +
|
|
|
|
'<div class="bar" id="upload-bar" style="width: 00%;"></div>' +
|
|
|
|
'</div>'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function progressUpdated(i, file, progress) {
|
|
|
|
$("#upload-bar").width(progress + "%");
|
|
|
|
}
|
|
|
|
|
|
|
|
function uploadError(err, file) {
|
|
|
|
var msg;
|
|
|
|
$("#send-status").addClass("alert-error")
|
|
|
|
.removeClass("alert-info");
|
|
|
|
$("#compose-send-button").removeAttr("disabled");
|
2016-12-01 20:02:56 +01:00
|
|
|
switch (err) {
|
2013-11-15 19:30:57 +01:00
|
|
|
case 'BrowserNotSupported':
|
|
|
|
msg = "File upload is not yet available for your browser.";
|
|
|
|
break;
|
|
|
|
case 'TooManyFiles':
|
|
|
|
msg = "Unable to upload that many files at once.";
|
|
|
|
break;
|
|
|
|
case 'FileTooLarge':
|
|
|
|
// sanitizatio not needed as the file name is not potentially parsed as HTML, etc.
|
|
|
|
msg = "\"" + file.name + "\" was too large; the maximum file size is 25MiB.";
|
|
|
|
break;
|
|
|
|
case 'REQUEST ENTITY TOO LARGE':
|
|
|
|
msg = "Sorry, the file was too large.";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
msg = "An unknown error occured.";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$("#error-msg").text(msg);
|
|
|
|
}
|
|
|
|
|
2016-12-15 07:26:09 +01:00
|
|
|
function uploadFinished(i, file, response) {
|
2013-11-15 19:30:57 +01:00
|
|
|
if (response.uri === undefined) {
|
|
|
|
return;
|
|
|
|
}
|
2016-12-02 17:09:31 +01:00
|
|
|
var textbox = $("#new_message_content");
|
|
|
|
var split_uri = response.uri.split("/");
|
|
|
|
var filename = split_uri[split_uri.length - 1];
|
2013-11-15 19:30:57 +01:00
|
|
|
// Urgh, yet another hack to make sure we're "composing"
|
|
|
|
// when text gets added into the composebox.
|
|
|
|
if (!compose.composing()) {
|
|
|
|
compose.start('stream');
|
|
|
|
}
|
|
|
|
|
|
|
|
var uri = make_upload_absolute(response.uri);
|
|
|
|
|
|
|
|
if (i === -1) {
|
|
|
|
// This is a paste, so there's no filename. Show the image directly
|
|
|
|
textbox.val(textbox.val() + "[pasted image](" + uri + ") ");
|
|
|
|
} else {
|
|
|
|
// This is a dropped file, so make the filename a link to the image
|
|
|
|
textbox.val(textbox.val() + "[" + filename + "](" + uri + ")" + " ");
|
|
|
|
}
|
2017-01-04 04:13:15 +01:00
|
|
|
exports.autosize_textarea();
|
2013-11-15 19:30:57 +01:00
|
|
|
$("#compose-send-button").removeAttr("disabled");
|
|
|
|
$("#send-status").removeClass("alert-info")
|
|
|
|
.hide();
|
|
|
|
|
|
|
|
// In order to upload the same file twice in a row, we need to clear out
|
|
|
|
// the #file_input element, so that the next time we use the file dialog,
|
|
|
|
// an actual change event is fired. This is extracted to a function
|
|
|
|
// to abstract away some IE hacks.
|
|
|
|
clear_out_file_list($("#file_input"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Expose the internal file upload functions to the desktop app,
|
|
|
|
// since the linux/windows QtWebkit based apps upload images
|
|
|
|
// directly to the server
|
|
|
|
if (window.bridge) {
|
|
|
|
exports.uploadStarted = uploadStarted;
|
|
|
|
exports.progressUpdated = progressUpdated;
|
|
|
|
exports.uploadError = uploadError;
|
|
|
|
exports.uploadFinished = uploadFinished;
|
|
|
|
}
|
|
|
|
|
2013-03-14 22:12:25 +01:00
|
|
|
$("#compose").filedrop({
|
2016-06-09 20:56:25 +02:00
|
|
|
url: "/json/upload_file",
|
2013-04-24 00:40:47 +02:00
|
|
|
fallback_id: "file_input",
|
2013-03-14 22:12:25 +01:00
|
|
|
paramname: "file",
|
2015-11-21 04:08:53 +01:00
|
|
|
maxfilesize: page_params.maxfilesize,
|
2013-03-14 22:12:25 +01:00
|
|
|
data: {
|
|
|
|
// the token isn't automatically included in filedrop's post
|
2017-01-12 00:17:43 +01:00
|
|
|
csrfmiddlewaretoken: csrf_token,
|
2013-03-14 22:12:25 +01:00
|
|
|
},
|
2013-04-19 19:02:38 +02:00
|
|
|
raw_droppable: ['text/uri-list', 'text/plain'],
|
2013-11-15 19:30:57 +01:00
|
|
|
drop: uploadStarted,
|
|
|
|
progressUpdated: progressUpdated,
|
|
|
|
error: uploadError,
|
|
|
|
uploadFinished: uploadFinished,
|
2013-04-19 19:02:38 +02:00
|
|
|
rawDrop: function (contents) {
|
|
|
|
var textbox = $("#new_message_content");
|
2013-05-07 21:22:25 +02:00
|
|
|
if (!compose.composing()) {
|
2013-07-12 23:16:07 +02:00
|
|
|
compose.start('stream');
|
2013-05-07 21:22:25 +02:00
|
|
|
}
|
2013-04-19 19:02:38 +02:00
|
|
|
textbox.val(textbox.val() + contents);
|
2017-01-04 04:13:15 +01:00
|
|
|
exports.autosize_textarea();
|
2017-01-12 00:17:43 +01:00
|
|
|
},
|
2013-03-14 22:12:25 +01:00
|
|
|
});
|
2014-01-14 17:21:41 +01:00
|
|
|
|
|
|
|
if (page_params.narrow !== undefined) {
|
2014-01-17 00:05:35 +01:00
|
|
|
if (page_params.narrow_topic !== undefined) {
|
|
|
|
compose.start("stream", {subject: page_params.narrow_topic});
|
|
|
|
} else {
|
|
|
|
compose.start("stream", {});
|
|
|
|
}
|
2014-01-14 17:21:41 +01:00
|
|
|
}
|
2013-12-19 17:03:08 +01:00
|
|
|
|
|
|
|
$(document).on('message_id_changed', function (event) {
|
|
|
|
if (exports.send_times_data[event.old_id] !== undefined) {
|
|
|
|
var value = exports.send_times_data[event.old_id];
|
|
|
|
delete exports.send_times_data[event.old_id];
|
2016-12-02 15:16:33 +01:00
|
|
|
exports.send_times_data[event.new_id] =
|
|
|
|
_.extend({}, exports.send_times_data[event.old_id], value);
|
2013-12-19 17:03:08 +01:00
|
|
|
}
|
|
|
|
});
|
2012-10-24 04:02:39 +02:00
|
|
|
});
|
|
|
|
|
2012-10-18 20:29:16 +02:00
|
|
|
return exports;
|
|
|
|
}());
|
2016-12-29 12:23:07 +01:00
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = compose;
|
|
|
|
}
|