Eliminate people.reify() and mostly ignore unknown users.

If I try to send a message to an unknown user (which is possible
for some types of realms), then I simply ignore them during the
send codepath, so that I don't later need to patch up their attributes.
This commit is contained in:
Steve Howell
2016-11-03 12:12:38 -07:00
committed by Tim Abbott
parent 15d44f8d71
commit 30e01306d9
4 changed files with 14 additions and 83 deletions

View File

@@ -151,10 +151,14 @@ function insert_local_message(message_request, local_id) {
message.display_recipient = _.map(emails, function (email) {
email = email.trim();
var person = people.get_by_email(email);
if (person !== undefined) {
if (person === undefined) {
// For unknown users, we return a skeleton object.
return {email: email, full_name: email,
unknown_local_echo_user: true};
} else {
// NORMAL PATH
return person;
}
return {email: email, full_name: email, skeleton: true};
});
}
@@ -232,22 +236,6 @@ exports.process_from_server = function process_from_server(messages) {
updated = true;
compose.mark_rendered_content_disparity(message.id, true);
}
// If a PM was sent to an out-of-realm address,
// we didn't have the full person object originally,
// so we might have to update the recipient bar and
// internal data structures
if (client_message.type === 'private') {
var reply_to = message_store.get_private_message_recipient(message, 'full_name', 'email');
if (client_message.display_reply_to !== reply_to) {
client_message.display_reply_to = reply_to;
_.each(message.display_recipient, function (person) {
if (people.get_by_email(person.email).full_name !== person.full_name) {
people.reify(person);
}
});
updated = true;
}
}
msgs_to_rerender.push(client_message);
locally_processed_ids.push(client_message.id);
compose.report_as_received(client_message);