diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js index e705770ccb..b38a7a0d3f 100644 --- a/frontend_tests/node_tests/people.js +++ b/frontend_tests/node_tests/people.js @@ -84,30 +84,6 @@ var _ = global._; assert.equal(person.full_name, 'Original'); }()); -(function test_reify() { - var full_person = { - email: 'foo@example.com', - full_name: 'Foo Barson' - }; - - // If we don't have a skeleton object, this should quietly succeed. - people.reify(full_person); - - var skeleton = { - email: 'foo@example.com', - full_name: 'foo@example.com', - skeleton: true - }; - people.add(skeleton); - - people.reify(full_person); - var person = people.get_by_email('foo@example.com'); - assert.equal(person.full_name, 'Foo Barson'); - - // Our follow-up reify() call should also quietly succeed. - people.reify(full_person); -}()); - (function test_get_rest_of_realm() { var myself = { email: 'myself@example.com', diff --git a/static/js/echo.js b/static/js/echo.js index 5071ed65ca..3e70b1afd8 100644 --- a/static/js/echo.js +++ b/static/js/echo.js @@ -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); diff --git a/static/js/message_store.js b/static/js/message_store.js index 90f43eb0a9..202d5d1816 100644 --- a/static/js/message_store.js +++ b/static/js/message_store.js @@ -128,19 +128,15 @@ function add_message_metadata(message) { // Add new people involved in this message to the people list _.each(involved_people, function (person) { - // Do the hasOwnProperty() call via the prototype to avoid problems - // with keys like "hasOwnProperty" - if (! people.get_by_email(person.email)) { - people.add(person); - } + if (!person.unknown_local_echo_user) { + if (! people.get_by_email(person.email)) { + people.add(person); + } - if (people.get_by_email(person.email).full_name !== person.full_name) { - people.reify(person); - } - - if (message.type === 'private' && message.sent_by_me) { - // Track the number of PMs we've sent to this person to improve autocomplete - people.incr_recipient_count(person.email); + if (message.type === 'private' && message.sent_by_me) { + // Track the number of PMs we've sent to this person to improve autocomplete + people.incr_recipient_count(person.email); + } } }); diff --git a/static/js/people.js b/static/js/people.js index a43a7119f8..af15823e70 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -129,35 +129,6 @@ exports.remove = function remove(person) { realm_people_dict.del(person.email); }; -exports.reify = function reify(person) { - // If a locally sent message is a PM to - // an out-of-realm recipient, a people_dict - // entry is created with simply an email address - // Once we've received the full person object, replace - // it - if (! people_dict.has(person.email)) { - return; - } - - var old_person = people_dict.get(person.email); - - // Only overwrite skeleton objects here. If the object - // had already been reified, exit early. - if (!old_person.skeleton) { - return; - } - - var new_person = _.extend({}, old_person, person); - new_person.skeleton = false; - - people_dict.set(person.email, person); - people_by_name_dict.set(person.full_name, person); - - if (people_by_name_dict.has(person.email)) { - people_by_name_dict.del(person.email); - } -}; - exports.update = function update(person) { if (! people_dict.has(person.email)) { blueslip.error("Got update_person event for unexpected user",