wordpress-activitypub icon indicating copy to clipboard operation
wordpress-activitypub copied to clipboard

Add timestamp to icon url of class-user.php

Open andrigamerita opened this issue 2 years ago • 1 comments

As complained in #211, when a user updates their Gravatar profile picture, the change fails to be reflected on many ActivityPub instances that already know the user. This is usually because, when changing the Gravatar image, since the URL remains the same, instances won't try to redownload the data, and thus their media cache isn't updated. From my testing, simply adding a changing dummy parameter to the URL hash returned in the user's JSON is a change that is noticed by other instances, that will try to redownload the image from Gravatar (my experience is minutes for Misskey, and ~1 day for Mastodon).

Proposed changes:

A decent solution to this problem is thus to add the current day string to the URL hash ($icon as returned by get_icon() as 'url'), in the format Ymd, which will result in the URL changing every day, which should be enough for any user, while at the same time avoiding overloading instances which try to do frequent refreshes. (See https://github.com/Automattic/wordpress-activitypub/issues/211#issuecomment-1848997738)

Testing instructions:

  • Change your profile picture on Gravatar without this change in the code
  • And notice how even after days your image change shouldn't be reflected on any instance
  • Now change the code as in this PR, and notice how in some time the change will get reflected

andrigamerita avatar Dec 11 '23 14:12 andrigamerita

Is this really working? I think the Avatar is cached and would not be requested at all, until there will be a profile update call.

pfefferle avatar Dec 21 '23 09:12 pfefferle