Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update profile avatar paths & hashes properly #472

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AndrewFerr
Copy link
Contributor

This is a leftover commit from #449 that may still be relevant.

When running the bridge without this change, avatar updates weren't getting saved to the store when I expected them to & new avatars wouldn't appear in Matrix until a bridge restart.

- Store updates to profile avatar hashes in signalmeow_contacts
- Have puppets use the stored contact avatar hash rather than
  recomputing it
- Have puppets update their avatar path when the profile avatar path
  changed but the hash did not
- Have puppets clear their avatar path when using a contact avatar
  instead of a profile avatar
puppet.go Outdated Show resolved Hide resolved
This call was meant to save changes to the Contact's avatar hash, but
the hash is no longer stored there, making this call obsolete.
@AndrewFerr
Copy link
Contributor Author

As explained here, the problem this PR was thought to fix is no longer present. So that makes this PR just an optional performance change.

Other than avoiding an unneeded hash calculation, it also ensures that changes to a puppet's avatar path are saved to the DB when the puppet's profile metadata comes from a Signal profile (not a contact) and the profile avatar path changed but the hash did not.

@@ -354,19 +354,19 @@ func (puppet *Puppet) updateAvatar(ctx context.Context, source *User, info *type
return true
}
avatarContentType = http.DetectContentType(avatarData)
puppet.AvatarPath = info.Profile.AvatarPath
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to before the return true so that an path change will end up getting saved to the store even when the hash didn't change.

@AndrewFerr AndrewFerr force-pushed the af/profile-avatar-update-fixes branch from aeb485e to f96ad70 Compare March 12, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants