Skip to content

AO3-7536 Expire creator comment caches when creatorships of anonymous work change#5943

Open
hab-bang wants to merge 1 commit into
otwcode:masterfrom
hab-bang:AO3-7536-creator-comment-cache-not-expired-creatorships-of-anon-change
Open

AO3-7536 Expire creator comment caches when creatorships of anonymous work change#5943
hab-bang wants to merge 1 commit into
otwcode:masterfrom
hab-bang:AO3-7536-creator-comment-cache-not-expired-creatorships-of-anon-change

Conversation

@hab-bang

Copy link
Copy Markdown

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7536

Purpose

Expiring the cached comment bylines when the creatorships of an anonymous work (a work in an anonymous collection) change, so comments by the affected user start or stop displaying as "Anonymous Creator" correctly.

As described in the Jira ticket, AO3-3712 (#1289) added cache busting for creator comments when a work is added to or removed from an anonymous collection, but there was no such thing for creatorship changes on a work that stays anonymous. So when a creator removed themselves via "Remove Me As Co-Creator" (or was re-added and accepted), their comments kept showing the wrong byline until the 1-week fragment cache expired.

This PR adds a Creatorship callback that enqueues a new Work#poke_cached_creator_comments_for_user, touching the affected user's comments on the work so their bylines re-render. The existing Work#poke_cached_creator_comments could not be reused here: it looks up the work's current creators, and a removed creator has already left that list by the time the background job runs so that their comments would be the ones skipped. Passing the user's id captured at the moment the creatorship changes covers both removal and re-adding.

The added feature scenario fails without the Creatorship and Work changes, and passes with them.

Testing Instructions

Follow the reproduction steps on the Jira issue (post a work with a co-creator into an anonymous collection, comment as a creator, then remove yourself via Edit => "Remove Me As Co-Creator"):

  • Before this change: the comment still shows "Anonymous Creator" after the removal (until the weekly cache expiry).
  • After this change: refreshing shows the commenter's username once the background job has run.
  • Afterwards, re-inviting the removed user and the user accepting the co-creator request re-anonymizes their comments to "Anonymous Creator".

Reproducing locally requires fragment caching to be enabled (rails dev:cache) and a Resque worker running.

You can also see the testing instructions are also on the Jira ticket.

References

AO3-3712 (https://otwarchive.atlassian.net/browse/AO3-3712, #1289) introduced the equivalent cache busting for collection-anonymity changes; this PR follows the same pattern for creatorship changes and reuses its touch-based invalidation approach.

Credit

Name: hayoung
Pronouns: she/her

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant