diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index 84eb0b0bf4..766526ee14 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -38,6 +38,14 @@ global.current_msg_list = current_msg_list; var home_msg_list = {}; global.home_msg_list = home_msg_list; +var me = { + email: 'me@example.com', + user_id: 30, + full_name: 'Me Myself', +}; +people.add(me); +people.initialize_current_user(me.user_id); + var zero_counts = { private_message_count: 0, home_unread_messages: 0, @@ -276,12 +284,6 @@ var zero_counts = { var counts = unread.get_counts(); assert.equal(counts.private_message_count, 0); - var message = { - id: 15, - type: 'private', - reply_to: 'anybody@example.com', - }; - var anybody = { email: 'anybody@example.com', user_id: 999, @@ -289,6 +291,15 @@ var zero_counts = { }; people.add_in_realm(anybody); + var message = { + id: 15, + type: 'private', + display_recipient: [ + {user_id: anybody.user_id}, + {id: me.user_id}, + ], + }; + unread.process_loaded_messages([message]); counts = unread.get_counts(); @@ -320,7 +331,7 @@ var zero_counts = { var message = { id: 15, - reply_to: 'alice@example.com', + display_recipient: [{id: alice.user_id}], type: 'private', }; @@ -406,7 +417,7 @@ var zero_counts = { var message = { id: 9, type: 'private', - reply_to: 'unknown@zulip.com', + display_recipient: [{id: 9999}], }; unread.process_read_message(message); diff --git a/static/js/people.js b/static/js/people.js index a53a576753..09fde26cdc 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -188,6 +188,16 @@ exports.get_recipients = function (user_ids_string) { return names.join(', '); }; +exports.pm_reply_user_string = function (message) { + var user_ids = people.pm_with_user_ids(message); + + if (!user_ids) { + return; + } + + return user_ids.join(','); +}; + exports.pm_reply_to = function (message) { var user_ids = people.pm_with_user_ids(message); diff --git a/static/js/unread.js b/static/js/unread.js index becd0d839a..ccb7bb7a82 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -151,7 +151,7 @@ exports.process_loaded_messages = function (messages) { } if (message.type === 'private') { - var user_ids_string = people.emails_strings_to_user_ids_string(message.reply_to); + var user_ids_string = people.pm_reply_user_string(message); if (user_ids_string) { unread_privates.setdefault(user_ids_string, new Dict()); unread_privates.get(user_ids_string).set(message.id, true); @@ -175,7 +175,7 @@ exports.process_loaded_messages = function (messages) { exports.process_read_message = function (message) { if (message.type === 'private') { - var user_ids_string = people.emails_strings_to_user_ids_string(message.reply_to); + var user_ids_string = people.pm_reply_user_string(message); if (user_ids_string) { var dict = unread_privates.get(user_ids_string); if (dict) {