Skip to content

Draft: Implement VCard avatars, along with Avatar Store

This MR is a replacement for !248 (closed), I cherry-picked what I could but it needed a bit of work post-refactor; the rebasing kept failing, so here's a fresh MR on a fresh branch.

It branches off !264 (merged) as well; that'll probably need merging before we do this one.

This MR is currently a draft; it's here to get some feedback on the initial version of this, since there is a decent chance there are fundamental disagreements about what I'm doing here.

Moreover, this implements the AvatarStore; this is a bit of a change for how Agent usually works: it introduces state to Agent, and has it automatically detect avatar changes and retrieve the avatars from the server. The AvatarRetrieved is emitted to the user only after this whole process succeeds, making it so the user never has to worry about updates, hash verification, etc...

The AvatarStore provides a AvatarStoreBackend trait to allow the user to provide an implementation of how to store data; the keys returned in AvatarRetrieved are also specified by the implementor of this trait. For instance, the user is free to choose whether to store files and get file paths, or store things as blobs in a database and get DB keys.

Parts of this MR are drawn from Dergchat.

I left a few TODO's in the code that ought t be resolved.

Mainly:

  • This code temporarily breaks the PEP-based avatars; I figured those could be migrated to AvatarStore as well and benefit from some of the underlying logic, though I mostly just wanted to get this working.
  • This also needs unit tests.
  • This code requires an integration test, though similar functionality has worked well enough in Dergchat so far.
  • How about fetching the user's own avatar? Where do we implement that?
  • I didn't do much in terms of feature-flagging; not enabling the store should already stop avatars-related functionality, but let's discuss the best way of doing this.
Edited by Werner Kroneman

Merge request reports