mirror of
https://github.com/zulip/zulip.git
synced 2026-06-15 21:01:31 +08:00
Seperate extract PM recipients as function.
This commit is contained in:
parent
f44b227b85
commit
a717c7df18
@ -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();
|
||||
|
||||
@ -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];
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user