fix(backend): cache-bust served avatars with an uploaded_at version

Avatar objects live at a deterministic key (avatars/<id>.png) served with a
300s cache, so after a re-upload the <img> kept pointing at the same URL and
the browser showed the stale crop until reload. Append ?v=<uploaded_at epoch>
to every avatar_url (me, public profile, and showcase/grpc batch) so the URL
changes whenever the avatar changes.
This commit is contained in:
loki5512344 2026-09-29 10:42:49 +02:00
parent eb854c32da
commit 8a758754dd
Signed by: boba
GPG key ID: 253067914055423B
3 changed files with 26 additions and 16 deletions

View file

@ -74,12 +74,13 @@ impl AccountsInternal for AccountsGrpc {
})?;
let profiles = rows
.into_iter()
.map(|(id, nick, key)| PublicProfile {
.map(|(id, nick, key, version)| PublicProfile {
account_id: id.to_string(),
display_nick: nick,
avatar_url: key
.map(|k| format!("{}/{k}", self.avatar_base_url))
.unwrap_or_default(),
avatar_url: match (key, version) {
(Some(k), Some(v)) => format!("{}/{k}?v={v}", self.avatar_base_url),
_ => String::new(),
},
})
.collect();
Ok(Response::new(GetPublicProfilesReply { profiles }))