Skip to content

Conversation

@BhaveshKukreja29
Copy link
Collaborator

Checklist

  • I have created an issue for this change (not mandatory for small changes)
  • My changes are to-the-point
  • Code is styled as the rest of the codebase and linting passes
  • I have tested my changes locally and they work as expected
  • I have updated the documentation (if needed)
  • I have reviewed the code myself once and I don't see any issues

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 16, 2026

Deploying mxtoai-backend with  Cloudflare Pages  Cloudflare Pages

Latest commit: a027d21
Status: ✅  Deploy successful!
Preview URL: https://b149c6bb.mxtoai-backend.pages.dev
Branch Preview URL: https://knowsletter-branding.mxtoai-backend.pages.dev

View logs

logger.info(f"User {user_email} is not whitelisted. Triggering verification.")
try:
await whitelist.trigger_automatic_verification(user_email)
await whitelist.trigger_newsletter_verification(user_email)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we revoking the usage of trigger_automatic_verification we do need that functionality as well, this codebase is shared b/w normal MXGo and Knowsletter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. So we want a way to difference between a request that's coming from the mxgo and one that's coming from knowsletter and trigger the relevant verification?

Comment on lines +274 to +292
if not supabase:
init_supabase()

verification_token = str(uuid.uuid4())
current_time = datetime.now(timezone.utc).isoformat()

existing_response = supabase.table("whitelisted_emails").select("*").eq("email", email).execute()

if hasattr(existing_response, "data") and len(existing_response.data) > 0:
update_response = (
supabase.table("whitelisted_emails")
.update({"verification_token": verification_token, "verified": False, "updated_at": current_time})
.eq("email", email)
.execute()
)
if not (hasattr(update_response, "data") and len(update_response.data) > 0):
logger.error(f"Failed to update verification token for {email}")
return False
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are commonalities in this method with trigger_automatic_verification, we should reuse the code. Let's extract common logic to functions and not duplicate the code.

return False


async def send_newsletter_verification_email(email: str, verification_token: str) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as https://github.com/mxgoai/mxgo-core/pull/147/changes#r2698369388, commonalities with send_verification_email

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also can move these methods to a separate module called knowsletter.py to keep the changes bit isolated

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.

3 participants