修复站点到期通知无法发送短信的问题
This commit is contained in:
parent
df195a049c
commit
b5700e0931
@ -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)
|
||||
@ -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。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user