avatar: Stop adding &s=50 to Gravatar and Zulip avatar requests.

This parameter is unused for Zulip avatars, and results in a smaller
(pixel-wise) Gravatar than we use for Zulip "small" avatars.  Omitting
the `s=50` parameter results in a 80x80 image, which is closer to the
100x100 image that Zulip thumbnails avatars to.  Ironically, using the
default (larger) Gravatar dimensions also results in _smaller_
responses (in bytes) from Gravatar.
This commit is contained in:
Alex Vandiver
2024-08-02 18:00:55 +00:00
committed by Tim Abbott
parent 87a0fa0c8c
commit b89d47a147
7 changed files with 23 additions and 37 deletions

View File

@@ -718,12 +718,6 @@ export function exclude_me_from_string(user_ids_string: string): string {
return user_ids.join(",");
}
export function format_small_avatar_url(raw_url: string): string {
const url = new URL(raw_url, window.location.origin);
url.search += (url.search ? "&" : "") + "s=50";
return url.href;
}
export function sender_is_bot(message: Message): boolean {
if (message.sender_id) {
const person = get_by_user_id(message.sender_id);
@@ -790,21 +784,19 @@ export function user_can_direct_message(recipient_ids_string: string): boolean {
function gravatar_url_for_email(email: string): string {
const hash = md5(email.toLowerCase());
const avatar_url = "https://secure.gravatar.com/avatar/" + hash + "?d=identicon";
const small_avatar_url = format_small_avatar_url(avatar_url);
return small_avatar_url;
return "https://secure.gravatar.com/avatar/" + hash + "?d=identicon";
}
export function small_avatar_url_for_person(person: User): string {
if (person.avatar_url) {
return format_small_avatar_url(person.avatar_url);
return person.avatar_url;
}
if (person.avatar_url === null) {
return gravatar_url_for_email(person.email);
}
return format_small_avatar_url(`/avatar/${person.user_id}`);
return `/avatar/${person.user_id}`;
}
function medium_gravatar_url_for_email(email: string): string {
@@ -876,7 +868,7 @@ export function small_avatar_url(message: Message): string {
// or if the avatar was missing. We do this verbosely to avoid false
// positives on line coverage (we don't do branch checking).
if (message.avatar_url) {
return format_small_avatar_url(message.avatar_url);
return message.avatar_url;
}
if (person && person.avatar_url === undefined) {
@@ -885,7 +877,7 @@ export function small_avatar_url(message: Message): string {
// required to take advantage of the user_avatar_url_field_optional
// optimization, which saves a huge amount of network traffic on
// servers with 10,000s of user accounts.
return format_small_avatar_url(`/avatar/${person.user_id}`);
return `/avatar/${person.user_id}`;
}
// For computing the user's email, we first trust the person