Skip to content

fix: keep cached contact photo when carddav re-encodes it - #9

Merged
GraysonCAdams merged 3 commits into
mainfrom
fix/contact-photo-churn
Nov 27, 2026
Merged

GraysonCAdams merged 3 commits into
mainfrom
fix/contact-photo-churn

Conversation

@GraysonCAdams

Copy link
Copy Markdown
Contributor

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.

storeContacts now 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 after
  • Full connector suite and go vet
  • Running on a live bridge against Google CardDAV

Grayson Adams 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.
@GraysonCAdams
GraysonCAdams merged commit eef2b70 into main Nov 27, 2026
4 checks passed
@GraysonCAdams
GraysonCAdams deleted the fix/contact-photo-churn branch November 27, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant