Skip to content

Connect sanbase with discord#4895

Open
tspenov wants to merge 3 commits intomasterfrom
connect-sanbase-discord
Open

Connect sanbase with discord#4895
tspenov wants to merge 3 commits intomasterfrom
connect-sanbase-discord

Conversation

@tspenov
Copy link
Collaborator

@tspenov tspenov commented Oct 20, 2025

Changes

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

Note

Introduce Discord verification codes generated on subscription, a /verify command that assigns PRO role, and supporting config, DB, admin, and tests.

  • Discord Integration:
    • Context & API: Add Sanbase.Discord with discord_invite_url/0 and get_verification_info/1.
    • Verification Codes: New schema Sanbase.Discord.VerificationCode with generate/verify/retrieve/cleanup functions and configurable expiry.
  • Billing Events:
    • On :create_subscription, generate Discord verification code for active paid plans; map plan to tier.
  • Discord Bot:
    • Add /verify command handling: validate code, assign PRO role, send welcome message; helper methods for role/channel IDs and ephemeral interaction ack.
  • Config:
    • New Sanbase.Discord settings: invite_url, verification_code_expiry_days.
  • Database:
    • Migration creating discord_verification_codes table (+ indexes/FK); structure.sql updated.
  • Admin:
    • Generic admin resource for DiscordVerificationCode (show-only, labels for Discord fields).
  • Tests & Seeds:
    • Comprehensive tests for verification code lifecycle.
    • Test seed fallback to load products/plans from DB when ETS missing.

Written by Cursor Bugbot for commit 80e60ac. This will update automatically on new commits. Configure here.

@tspenov
Copy link
Collaborator Author

tspenov commented Oct 20, 2025

@cursor review

cursor[bot]

This comment was marked as outdated.

product_api: product_api,
product_sanbase: product_sanbase
}
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing Plan Keys in Seeded Data

The seed_products_and_plans_from_db/0 fallback function returns an incomplete data structure. It includes only product keys, missing the various plan keys present in the original seeded data. This causes tests expecting those plan keys to fail or raise KeyError exceptions.

Fix in Cursor Fix in Web

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

Comments