mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
Make compose replies for PMs more robust.
We now use user_ids from the message to generate the reply_to more dynamically.
This commit is contained in:
@@ -636,11 +636,15 @@ exports.respond_to_message = function (opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pm_recipient = message.reply_to;
|
var pm_recipient = message.reply_to;
|
||||||
if (opts.reply_type === "personal" && message.type === "private") {
|
if (message.type === "private") {
|
||||||
// reply_to for private messages is everyone involved, so for
|
if (opts.reply_type === "personal") {
|
||||||
// personals replies we need to set the private message
|
// reply_to for private messages is everyone involved, so for
|
||||||
// recipient to just the sender
|
// personals replies we need to set the private message
|
||||||
pm_recipient = message.sender_email;
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (opts.reply_type === 'personal' || message.type === 'private') {
|
if (opts.reply_type === 'personal' || message.type === 'private') {
|
||||||
msg_type = 'private';
|
msg_type = 'private';
|
||||||
|
|||||||
@@ -188,6 +188,46 @@ exports.get_recipients = function (user_ids_string) {
|
|||||||
return names.join(', ');
|
return names.join(', ');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.pm_reply_to = function (message) {
|
||||||
|
if (message.type !== 'private') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.display_recipient.length === 0) {
|
||||||
|
blueslip.error('Empty recipient list in message');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var user_ids = _.map(message.display_recipient, function (elem) {
|
||||||
|
return elem.user_id || elem.id;
|
||||||
|
});
|
||||||
|
|
||||||
|
var other_user_ids = _.filter(user_ids, function (user_id) {
|
||||||
|
return !people.is_my_user_id(user_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (other_user_ids.length >= 1) {
|
||||||
|
user_ids = other_user_ids;
|
||||||
|
} else {
|
||||||
|
user_ids = [my_user_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
var emails = _.map(user_ids, function (user_id) {
|
||||||
|
var person = people_by_user_id_dict.get(user_id);
|
||||||
|
if (!person) {
|
||||||
|
blueslip.error('Unknown user id in message: ' + user_id);
|
||||||
|
return '?';
|
||||||
|
}
|
||||||
|
return person.email;
|
||||||
|
});
|
||||||
|
|
||||||
|
emails.sort();
|
||||||
|
|
||||||
|
var reply_to = emails.join(',');
|
||||||
|
|
||||||
|
return reply_to;
|
||||||
|
};
|
||||||
|
|
||||||
exports.pm_with_user_ids = function (message) {
|
exports.pm_with_user_ids = function (message) {
|
||||||
if (message.type !== 'private') {
|
if (message.type !== 'private') {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user