Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodically check for invalidated licenses #6

Open
zkxs opened this issue Jan 4, 2025 · 0 comments
Open

Periodically check for invalidated licenses #6

zkxs opened this issue Jan 4, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@zkxs
Copy link
Owner

zkxs commented Jan 4, 2025

There are a few cases (such as when a product is refunded) where licenses can be removed from the Jinxxy API. It is likely that in the future there will be other cases where licenses can be revoked. Currently Jinx is completely unaware of this and has no way to deal with it.

This feature is not an incredibly high priority, as the creator should already be receiving email notice from Jinxxy that a license revocation has occurred, but it may be desirable to creators to be explicitly notified when a license has been revoked for a user who has been granted a Discord role via Jinx, as Jinxxy currently does not make it easy to look up license id from an order id.

Each of the unique license_id values cached in the license_activation table will be periodically checked to see if it still exists. For each ID that no longer exists a log will be emitted to the guild's configured log channel. As this is the ONLY action that will be performed, there is no reason to scan activations in guilds without logging configured. It is going to be mildly expensive to hit the Jinxxy API for every known license, so this will need to be ratelimited:

  • there will be a global ratelimit for how frequently the background job is allowed to fire request. I'll arbitrarily start this at once ever 60s.
  • A license can be checked at most once every 15 minutes, to avoid a bunch of redundant API traffic to Jinxxy.
  • requests will be prioritized according to a heuristic estimating how likely it is the license has been revoked. The idea is that revocation is more likely to occur soon after some event, such as the initial purchase or refunding any other purchase. This heuristic will therefore include:
    • penalty for total number of revoked licenses (a user that has revoked more licenses has a higher risk of future revocations)
    • penalty based on time since last revocation (recent revocation activity indicates higher risk of future revocations)
    • penalty for total revoked-license-hours (a user who sits on licenses for a long time before revoking is unpredictable)
    • reward for unrevoked-license-hours across all other known licenses. (a user with many old licenses is less likely to revoke)
    • reward for unrevoked-license-hours for this license. (the other the license is the less likely it will be revoked)
    • penalty for how long since the last check. This is just to prevent high-risk users from monopolizing the work queue forever.
@zkxs zkxs added the enhancement New feature or request label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant