@@ -1041,6 +1041,9 @@ def _config_health_locked(self) -> tuple[list[str], list[str]]:
10411041 cloudmail_admin_password = str (cfg .get ("cloudmail_admin_password" ) or "" ).strip ()
10421042 mail_curl_api_base = str (cfg .get ("mail_curl_api_base" ) or "" ).strip ()
10431043 mail_curl_key = str (cfg .get ("mail_curl_key" ) or "" ).strip ()
1044+ luckyous_api_base = str (cfg .get ("luckyous_api_base" ) or "" ).strip ()
1045+ luckyous_api_key = str (cfg .get ("luckyous_api_key" ) or "" ).strip ()
1046+ luckyous_project_code = str (cfg .get ("luckyous_project_code" ) or "" ).strip ()
10441047 graph_file = str (cfg .get ("graph_accounts_file" ) or "" ).strip ()
10451048 gmail_user = str (cfg .get ("gmail_imap_user" ) or "" ).strip ()
10461049 gmail_pass = str (cfg .get ("gmail_imap_pass" ) or "" ).strip ()
@@ -1080,6 +1083,13 @@ def _config_health_locked(self) -> tuple[list[str], list[str]]:
10801083 blockers .append ("Mail-Curl API 地址未填写(mail_curl_api_base)" )
10811084 if not mail_curl_key :
10821085 blockers .append ("Mail-Curl Key 未填写(mail_curl_key)" )
1086+ elif provider == "luckyous" :
1087+ if not luckyous_api_base :
1088+ blockers .append ("Luckyous API 地址未填写(luckyous_api_base)" )
1089+ if not luckyous_api_key :
1090+ blockers .append ("Luckyous API Key 未填写(luckyous_api_key)" )
1091+ if not luckyous_project_code :
1092+ blockers .append ("Luckyous 项目编码未填写(luckyous_project_code)" )
10831093 elif provider == "gmail" :
10841094 if not gmail_user :
10851095 blockers .append ("Gmail IMAP 账号未填写(gmail_imap_user)" )
@@ -1454,6 +1464,13 @@ def update_config(self, data: dict[str, Any], emit_log: bool = True) -> dict[str
14541464 "cloudmail_admin_password" ,
14551465 "mail_curl_api_base" ,
14561466 "mail_curl_key" ,
1467+ "luckyous_api_base" ,
1468+ "luckyous_api_key" ,
1469+ "luckyous_project_code" ,
1470+ "luckyous_email_type" ,
1471+ "luckyous_domain" ,
1472+ "luckyous_variant_mode" ,
1473+ "luckyous_specified_email" ,
14571474 "graph_accounts_file" ,
14581475 "graph_tenant" ,
14591476 "graph_fetch_mode" ,
@@ -1604,6 +1621,16 @@ def update_config(self, data: dict[str, Any], emit_log: bool = True) -> dict[str
16041621 str (cfg .get ("cf_worker_mail_domain_binding" ) or "MAIL_DOMAIN" ).strip () or "MAIL_DOMAIN"
16051622 )
16061623 cfg ["cf_dns_target_domain" ] = str (cfg .get ("cf_dns_target_domain" ) or "" ).strip ().lower ()
1624+ cfg ["luckyous_api_base" ] = (
1625+ str (cfg .get ("luckyous_api_base" ) or "https://mails.luckyous.com" ).strip ()
1626+ or "https://mails.luckyous.com"
1627+ )
1628+ cfg ["luckyous_api_key" ] = str (cfg .get ("luckyous_api_key" ) or "" ).strip ()
1629+ cfg ["luckyous_project_code" ] = str (cfg .get ("luckyous_project_code" ) or "" ).strip ()
1630+ cfg ["luckyous_email_type" ] = str (cfg .get ("luckyous_email_type" ) or "ms_graph" ).strip ().lower ()
1631+ cfg ["luckyous_domain" ] = str (cfg .get ("luckyous_domain" ) or "" ).strip ().lower ()
1632+ cfg ["luckyous_variant_mode" ] = str (cfg .get ("luckyous_variant_mode" ) or "" ).strip ().lower ()
1633+ cfg ["luckyous_specified_email" ] = str (cfg .get ("luckyous_specified_email" ) or "" ).strip ().lower ()
16071634 graph_mode = str (cfg .get ("graph_fetch_mode" ) or "graph_api" ).strip ().lower ()
16081635 if graph_mode not in {"graph_api" , "imap_xoauth2" }:
16091636 graph_mode = "graph_api"
@@ -1715,6 +1742,17 @@ def _apply_to_env(self) -> None:
17151742 os .environ ["CLOUDMAIL_ADMIN_PASSWORD" ] = str (self .cfg .get ("cloudmail_admin_password" ) or "" )
17161743 os .environ ["MAIL_CURL_API_BASE" ] = str (self .cfg .get ("mail_curl_api_base" ) or "" ).strip ()
17171744 os .environ ["MAIL_CURL_KEY" ] = str (self .cfg .get ("mail_curl_key" ) or "" )
1745+ os .environ ["LUCKYOUS_API_BASE" ] = str (
1746+ self .cfg .get ("luckyous_api_base" ) or "https://mails.luckyous.com"
1747+ ).strip ()
1748+ os .environ ["LUCKYOUS_API_KEY" ] = str (self .cfg .get ("luckyous_api_key" ) or "" ).strip ()
1749+ os .environ ["LUCKYOUS_PROJECT_CODE" ] = str (self .cfg .get ("luckyous_project_code" ) or "" ).strip ()
1750+ os .environ ["LUCKYOUS_EMAIL_TYPE" ] = str (self .cfg .get ("luckyous_email_type" ) or "ms_graph" ).strip ().lower ()
1751+ os .environ ["LUCKYOUS_DOMAIN" ] = str (self .cfg .get ("luckyous_domain" ) or "" ).strip ().lower ()
1752+ os .environ ["LUCKYOUS_VARIANT_MODE" ] = str (self .cfg .get ("luckyous_variant_mode" ) or "" ).strip ().lower ()
1753+ os .environ ["LUCKYOUS_SPECIFIED_EMAIL" ] = str (
1754+ self .cfg .get ("luckyous_specified_email" ) or ""
1755+ ).strip ().lower ()
17181756 os .environ ["MAIL_SERVICE_PROVIDER" ] = normalize_mail_provider (
17191757 self .cfg .get ("mail_service_provider" ) or "mailfree"
17201758 )
@@ -2543,6 +2581,12 @@ def _worker(self) -> None:
25432581 domain = cf_domain
25442582 if cf_domains_raw :
25452583 mail_domains_raw = cf_domains_raw
2584+ elif mail_provider == "luckyous" :
2585+ lucky_base = str (
2586+ self .cfg .get ("luckyous_api_base" ) or "https://mails.luckyous.com"
2587+ ).strip ()
2588+ if lucky_base :
2589+ domain = lucky_base
25462590 if domain and not domain .startswith ("http" ):
25472591 domain = f"https://{ domain } "
25482592
@@ -2623,6 +2667,26 @@ def _worker(self) -> None:
26232667 "配置 -> "
26242668 f"mail={ mail_provider } , api={ mc_api } , key={ mc_mask } "
26252669 )
2670+ elif mail_provider == "luckyous" :
2671+ lucky_api = str (
2672+ self .cfg .get ("luckyous_api_base" ) or "https://mails.luckyous.com"
2673+ ).strip ()
2674+ lucky_key = str (self .cfg .get ("luckyous_api_key" ) or "" )
2675+ lucky_key_mask = (
2676+ lucky_key [:4 ] + "***"
2677+ if len (lucky_key ) >= 4
2678+ else ("***" if lucky_key else "" )
2679+ )
2680+ lucky_project = str (self .cfg .get ("luckyous_project_code" ) or "" ).strip ()
2681+ lucky_type = str (self .cfg .get ("luckyous_email_type" ) or "ms_graph" ).strip ().lower ()
2682+ lucky_domain = str (self .cfg .get ("luckyous_domain" ) or "" ).strip ().lower ()
2683+ lucky_mode = str (self .cfg .get ("luckyous_variant_mode" ) or "" ).strip ().lower ()
2684+ self .log (
2685+ "配置 -> "
2686+ f"mail={ mail_provider } , api={ lucky_api } , key={ lucky_key_mask } , "
2687+ f"project={ lucky_project or '-' } , type={ lucky_type or '-' } , "
2688+ f"domain={ lucky_domain or '-' } , variant={ lucky_mode or '-' } "
2689+ )
26262690 else :
26272691 gmail_user = str (self .cfg .get ("gmail_imap_user" ) or "" ).strip ().lower ()
26282692 gmail_server = (
0 commit comments