mautrix / whatsapp

A Matrix-WhatsApp puppeting bridge
https://maunium.net/go/mautrix-whatsapp
GNU Affero General Public License v3.0
1.29k stars 175 forks source link

Avatars are not redownloaded if mediaapi database is purged and the media files are deleted #644

Closed Xinayder closed 1 year ago

Xinayder commented 1 year ago

I'm using Dendrite and self-host some Mautrix bridges. One day I decided to delete the media files from the homeserver media storage and all bridged profile avatars were gone (as expected, since they were pointing to non-existent files). A few months later, I tried to purge the mediaapi database, thinking it would download the avatars again, but it didn't work either.

I have tried using the sync groups --avatars command, however, this doesn't work either. The avatars are still blank, and the only way to redownload them for groups is to completely delete the portal room and create it again. Unfortunately, doing the same doesn't work for normal contacts.

I'm not really sure if this is a homeserver problem or the bridge problem (maybe both?), but there could be a commad for Mautrix bridges to redownload the avatar files, or it could automatically try to download them again if the file is not found on the mediaapi repository.

This happens on both Go and Python bridges, as I am hosting mautrix-whatsapp, mautrix-facebook and mautrix-instagram.

I've created an issue on the Dendrite repository as well: https://github.com/matrix-org/dendrite/issues/3179

tulir commented 1 year ago

You just need to manually clear the urls in the puppet and portal tables

Xinayder commented 1 year ago

Okay, that seems like a workaround. Couldn't this be kept open as an improvement proposal? Would you be willing to accept a PR that adds a command that can purge the avatar URLs?

EDIT: I have manually deleted the MXC urls in the puppet and portal tables, what else do I need to do to make the bridges download the avatars again?

EDIT2: managed to fix it for WhatsApp, in case anyone needs it:

update puppet set avatar_url = null, avatar_set = false;
update portal set avatar_url = null, avatar_set = false;

for Python-based bridges:

update puppet set photo_mxc = null, avatar_set = false;
update portal set avatar_url = null, avatar_set = false;