From b5700e0931c458367033c8c89c3239430f0748be Mon Sep 17 00:00:00 2001 From: jingrow Date: Tue, 1 Jul 2025 17:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=99=E7=82=B9=E5=88=B0?= =?UTF-8?q?=E6=9C=9F=E9=80=9A=E7=9F=A5=E6=97=A0=E6=B3=95=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/api/aliyun_sms.py | 19 +++++++++---------- jcloud/jcloud/pagetype/site/site.py | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/jcloud/api/aliyun_sms.py b/jcloud/api/aliyun_sms.py index 437f478..9105c3e 100644 --- a/jcloud/api/aliyun_sms.py +++ b/jcloud/api/aliyun_sms.py @@ -30,9 +30,9 @@ class AliyunSMSClient: def initialize(self): """初始化配置信息""" try: - # 检查 Jcloud Settings 是否存在 - if jingrow.exists("Jcloud Settings"): - settings = jingrow.get_single("Jcloud Settings") + # 直接尝试获取 Jcloud Settings + settings = jingrow.get_single("Jcloud Settings") + if settings: self.access_key_id = settings.get("aliyun_access_key_id") self.access_secret = settings.get_password("aliyun_access_secret") if settings.get("aliyun_access_secret") else None else: @@ -40,7 +40,6 @@ class AliyunSMSClient: self.access_key_id = None self.access_secret = None jingrow.log_error("阿里云SMS客户端: Jcloud Settings 尚未配置,请在设置中完成配置") - except Exception as e: jingrow.log_error(f"阿里云SMS客户端初始化: {str(e)}") self.access_key_id = None @@ -143,8 +142,11 @@ def get_sms_client(): return sms_client def send_custom_sms(phone_numbers, message_content, sign_name, template_code): + client = get_sms_client() - return client.send_sms(phone_numbers, template_code, message_content, sign_name) + result = client.send_sms(phone_numbers, template_code, message_content, sign_name) + + return result def generate_verification_code(length=4): """生成指定长度的随机数字验证码""" @@ -169,13 +171,10 @@ def verify_code(mobile_no, verification_code, template_code): return False def send_renew_sms(phone_numbers, days_remaining, site_end_date): - """发送网站续费通知短信""" - template_code = "SMS_481605243" # 网站续费通知短信模板编码 + + template_code = "SMS_489640674" # 网站续费通知短信模板编码 sign_name = "向日葵网络" # 短信签名名称 - message_content = { - "day": str(days_remaining), "site_end_date": str(site_end_date) } - return send_custom_sms(phone_numbers, message_content, sign_name, template_code) \ No newline at end of file diff --git a/jcloud/jcloud/pagetype/site/site.py b/jcloud/jcloud/pagetype/site/site.py index 9d08df5..81b2830 100644 --- a/jcloud/jcloud/pagetype/site/site.py +++ b/jcloud/jcloud/pagetype/site/site.py @@ -3763,7 +3763,7 @@ def create_site_status_update_webhook_event(site: str): return create_webhook_event("Site Status Update", record, record.team) - +@jingrow.whitelist() def send_renew_notification(): """ 发送站点续费通知给用户: @@ -3886,7 +3886,7 @@ def send_renew_notification(): except Exception as e: jingrow.log_error(f"站点 {site.name} 发送续费通知失败: {str(e)}", "Renewal Notification Error") -@jingrow.whitelist(allow_guest=True) +@jingrow.whitelist() def deactivate_expired_sites(): """ 自动将已到期的站点(site_end_date<=今天,且状态为Active或Suspended)设为Inactive。