Store the user avatar thumbnail in the session database

Add a `userAvatarData` column to the session database, containing the base64 encoded
thumbnail of the user avatar. It will allow rendering the avatar of an account without
having to use its Matrix client, for instance on the signed out screen, or for other
accounts when the homeservers are not federated.

The thumbnail is downloaded when the user profile is retrieved or updated, and only if
the avatar URL has changed. The profile is now also persisted when received from the
own profile subscription.

Part of #5571

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benoit Marty
2026-09-28 11:00:42 +02:00
parent 35d8d1197f
commit db23023eda
24 changed files with 255 additions and 61 deletions
@@ -46,4 +46,6 @@ data class SessionData(
val userDisplayName: String?,
/** The optional avatar URL of the user. */
val userAvatarUrl: String?,
/** The optional thumbnail of the avatar of the user ([userAvatarUrl]), base64 encoded. */
val userAvatarData: String?,
)
@@ -51,8 +51,9 @@ interface SessionStore {
* @param sessionId the session to update.
* @param displayName the new display name, or `null` when the user has none.
* @param avatarUrl the new avatar, or `null` when the user has none.
* @param avatarData the thumbnail of the new avatar, base64 encoded, or `null` when the user has none or when it could not be loaded.
*/
suspend fun updateUserProfile(sessionId: String, displayName: String?, avatarUrl: String?)
suspend fun updateUserProfile(sessionId: String, displayName: String?, avatarUrl: String?, avatarData: String?)
/**
* Get the session data matching the userId, or null if not found.