Repository navigation
fix: keep cached contact photo when carddav re-encodes it - #9
Merged
Merged
Conversation
added 3 commits
November 27, 2026 01:08
Google's CardDAV serves some inline contact photos in two encodings that alternate between requests (about 1 in 40 fetches for one contact). They decode to the same picture, differing by at most 2 levels in one 8x8 block, but the ghost avatar ID is a hash of the bytes, so each switch re-uploaded the photo and re-set the avatar in all 15 of that contact's rooms: 66 avatar changes and about 1,000 member events in three days. On each sync, a fresh photo that decodes to the same size and within a small pixel difference of the cached one now keeps the cached bytes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Google's CardDAV serves some inline contact photos in two encodings that alternate between requests. They decode to the same picture, a level or two apart in one 8x8 block, but the ghost avatar ID is a hash of the photo bytes, so each switch re-uploaded the photo and re-set the avatar in every room shared with that contact. One contact here produced about 1,000 member events in three days.
storeContactsnow keeps the cached bytes when the fresh photo decodes to the same size and within a small pixel difference (mean 1, max 24 levels); a real photo change differs by far more. The comparison only runs when the bytes differ.Test plan
go test ./pkg/connector/ -run TestContactPhoto: the re-encode test fails before the fix and passes aftergo vet