mirror of https://github.com/zulip/zulip.git
reactions: Only warn for unknown user ids.
If we get reactions for deactivated users, or otherwise missing users, we only issue a blueslip warning now. The function get_message_reactions() was indirectly causing blueslip errors before this fix, but we can downgrade to warnings now that this function has better unit tests around it. We eventually want to track deactivated users on the client. Fixes #4289
This commit is contained in:
parent
3da047e10e
commit
cf6545a71f
|
@ -14,6 +14,10 @@ set_global('emoji', {
|
|||
realm_emojis: {},
|
||||
});
|
||||
|
||||
set_global('blueslip', {
|
||||
warn: function () {},
|
||||
});
|
||||
|
||||
set_global('page_params', {user_id: 1});
|
||||
|
||||
(function make_people() {
|
||||
|
@ -44,6 +48,10 @@ set_global('page_params', {user_id: 1});
|
|||
{emoji_name: 'smile', user: {id: 5}},
|
||||
{emoji_name: 'smile', user: {id: 6}},
|
||||
{emoji_name: 'frown', user: {id: 7}},
|
||||
|
||||
// add some bogus user_ids
|
||||
{emoji_name: 'octopus', user: {id: 8888}},
|
||||
{emoji_name: 'frown', user: {id: 9999}},
|
||||
],
|
||||
};
|
||||
|
||||
|
|
|
@ -222,8 +222,15 @@ exports.get_emojis_used_by_user_for_message_id = function (message_id) {
|
|||
exports.get_message_reactions = function (message) {
|
||||
var message_reactions = new Dict();
|
||||
_.each(message.reactions, function (reaction) {
|
||||
var user_id = reaction.user.id;
|
||||
if (!people.is_known_user_id(user_id)) {
|
||||
blueslip.warn('Unknown user_id ' + user_id +
|
||||
'in reaction for message ' + message.id);
|
||||
return;
|
||||
}
|
||||
|
||||
var user_list = message_reactions.setdefault(reaction.emoji_name, []);
|
||||
user_list.push(reaction.user.id);
|
||||
user_list.push(user_id);
|
||||
});
|
||||
var reactions = message_reactions.items().map(function (item) {
|
||||
var emoji_name = item[0];
|
||||
|
|
Loading…
Reference in New Issue