diff --git a/zephyr/static/js/message_list.js b/zephyr/static/js/message_list.js index 9bb6e9a12d..ee69f6266d 100644 --- a/zephyr/static/js/message_list.js +++ b/zephyr/static/js/message_list.js @@ -327,9 +327,7 @@ MessageList.prototype = { message.dom_id = table_name + message.id; - if (message.sender_email === page_params.email) { - message.stamp = ui.get_gravatar_stamp(); - } + message.small_avatar_url = ui.small_avatar_url(message); if (message.is_stream) { message.background_color = subs.get_color(message.stream); diff --git a/zephyr/static/js/notifications.js b/zephyr/static/js/notifications.js index 2aa88fcf68..c0317b73a1 100644 --- a/zephyr/static/js/notifications.js +++ b/zephyr/static/js/notifications.js @@ -107,11 +107,6 @@ exports.window_has_focus = function () { return window_has_focus; }; -function gravatar_url(message) { - return "https://secure.gravatar.com/avatar/" + message.gravatar_hash + - "?d=identicon&s=30?stamp=" + ui.get_gravatar_stamp(); -} - function process_desktop_notification(message) { var i, notification_object, key; var title = message.sender_full_name; @@ -166,9 +161,10 @@ function process_desktop_notification(message) { } if (window.bridge === undefined) { + var icon_url = ui.small_avatar_url(message); notice_memory[key] = { obj: window.webkitNotifications.createNotification( - gravatar_url(message), title, content), + icon_url, title, content), msg_count: msg_count }; notification_object = notice_memory[key].obj; diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index f6dfa16247..15c230b12f 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -607,8 +607,21 @@ function poll_for_gravatar_update(start_time, url) { } -exports.get_gravatar_stamp = function () { - return gravatar_stamp; +exports.small_avatar_url = function (message) { + // Try to call this function in all places where we need size-30 + // quality gravatar images, so that the browser can help + // us avoid unnecessary network trips. (For user-uploaded avatars, + // the s=30 parameter is essentially ignored, but it's harmless.) + // + if (message.avatar_url) { + var url = message.avatar_url + "&s=30"; + if (message.sender_email === page_params.email) { + url += "&stamp=" + gravatar_stamp; + } + return url; + } else { + return ""; + } }; exports.wait_for_gravatar = function () { diff --git a/zephyr/static/templates/message.handlebars b/zephyr/static/templates/message.handlebars index 932eb05563..4922015930 100644 --- a/zephyr/static/templates/message.handlebars +++ b/zephyr/static/templates/message.handlebars @@ -58,8 +58,9 @@