Seperate extract PM recipients as function.

This commit is contained in:
Vishnu Ks 2016-06-10 23:45:08 +05:30 committed by Tim Abbott
parent f44b227b85
commit a717c7df18
3 changed files with 7 additions and 8 deletions

View File

@ -330,7 +330,7 @@ function create_message_object() {
if (message.type === "private") {
// TODO: this should be collapsed with the code in composebox_typeahead.js
message.to = compose.recipient().split(/\s*[,;]\s*/);
message.to = util.extract_pm_recipients(compose.recipient());
message.reply_to = compose.recipient();
} else {
message.to = compose.stream_name();

View File

@ -13,15 +13,10 @@ var composebox_typeahead = (function () {
var exports = {};
function get_pm_recipients(query_string) {
// Assumes email addresses don't have commas or semicolons in them
return query_string.split(/\s*[,;]\s*/);
}
// Returns an array of private message recipients, removing empty elements.
// For example, "a,,b, " => ["a", "b"]
exports.get_cleaned_pm_recipients = function (query_string) {
var recipients = get_pm_recipients(query_string);
var recipients = util.extract_pm_recipients(query_string);
recipients = _.filter(recipients, function (elem) {
return elem.match(/\S/);
});
@ -55,7 +50,7 @@ exports.topics_seen_for = function (stream) {
};
function get_last_recipient_in_pm(query_string) {
var recipients = get_pm_recipients(query_string);
var recipients = util.extract_pm_recipients(query_string);
return recipients[recipients.length-1];
}

View File

@ -69,6 +69,10 @@ exports.is_pm_recipient = function (email, message) {
return recipients.indexOf(email.toLowerCase()) !== -1;
};
exports.extract_pm_recipients = function (recipients) {
return recipients.split(/\s*[,;]\s*/);
};
exports.same_major_recipient = function (a, b) {
// Same behavior as same_recipient, except that it returns true for messages
// on different topics but the same stream.