@@ -470,69 +470,6 @@ async def daily_pot_draw(
470470 conn .close ()
471471
472472
473- # ── TEMPORARY: preauth migration for existing auto-enter users ──────────
474- # Remove this function and its call in lucky_pot.py once all existing
475- # auto-enter users have been sent preauth requests.
476-
477-
478- async def backfill_preauths_for_auto_enter_users () -> None :
479- """Request preauths for existing auto-enter users who don't have one yet.
480-
481- TEMPORARY — safe to remove after rollout once preauths have been sent.
482- """
483- conn = db .get_connection ()
484- try :
485- all_users = db .get_all_auto_enter_users (conn )
486- finally :
487- conn .close ()
488-
489- if not all_users :
490- logger .info ("Preauth backfill: no auto-enter users found" )
491- return
492-
493- # Deduplicate by discord_id (a user may be auto-entered in multiple guilds,
494- # but preauths are per-user not per-guild)
495- seen : set [str ] = set ()
496- unique_users : list [str ] = []
497- for entry in all_users :
498- if entry ["discord_id" ] not in seen :
499- seen .add (entry ["discord_id" ])
500- unique_users .append (entry ["discord_id" ])
501-
502- logger .info (f"Preauth backfill: checking { len (unique_users )} auto-enter user(s)" )
503- requested = 0
504-
505- for discord_id in unique_users :
506- try :
507- stk_user = await stk .get_user_by_discord_id (discord_id )
508- if stk_user is None :
509- continue
510-
511- preauths = await stk .get_preauths (user_id = stk_user ["id" ])
512- has_active_or_pending = any (
513- p .get ("status" ) in ("active" , "pending" ) for p in preauths
514- )
515- if has_active_or_pending :
516- continue
517-
518- result = await stk .create_preauth (
519- user_id = stk_user ["id" ],
520- max_amount = 10 ,
521- window_hours = 24 ,
522- )
523- if result :
524- requested += 1
525- logger .info (
526- f"Preauth backfill: requested preauth for discord_id={ discord_id } (user { stk_user ['id' ]} )"
527- )
528- except Exception :
529- logger .exception (
530- f"Preauth backfill: failed for discord_id={ discord_id } "
531- )
532-
533- logger .info (f"Preauth backfill: done, requested { requested } new preauth(s)" )
534-
535-
536473async def on_request_accepted (
537474 event_data : RequestAcceptedData , announce : RawAnnounceFn = None
538475):
0 commit comments