Bug/discord integration purchase deactivation #2236
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.
This PR fixes https://github.com/antiwork/gumroad-private/issues/5
Problem
Discord access lived on the giftee purchase, but
DeactivateIntegrationsWorkeronly ran the integration tear-down on the gifter purchase whose charge failed. When the gifter’s renewal declined, the worker never touched the giftee purchase, so the Discord membership stayed active. This change makes the worker gather every purchase tied to the subscription (including giftees) before calling the Circle/Discord deactivation services, ensuring Discord roles are removed as soon as the parent subscription exits good standing.Solution
Added logic to DeactivateIntegrationsWorker so it walks every purchase on a subscription (not just the failing one) when disabling integrations. This ensures we also hit gift receiver purchases (the ones that actually hold the Discord membership)so Discord/Circle access is revoked when the gifter’s renewal fails. Updated the Sidekiq spec to cover the gifted subscription scenario and proved both Circle and Discord services receive deactivate for the gifter and giftee purchases.
AI Disclosure
AI was used to double check the investigation's findings and provide the appropriate fix, as well as generating comprehensive specs to prevent regressions from happening. Code was reviewed manually.