mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 02:17:46 +08:00
feat: 重要通知模块、Server 酱独立配置与额度提醒
- 新增重要通知统一模块(邮件 + Server 酱)作为后台任务通知出口
- 拆出独立的 Server 酱 配置页(SendKey + Markdown 模板,支持 {title}/{body} 变量替换),通过仪表盘内置工具入口进入
- 新增提供商额度提醒后台 worker:余额低于阈值时通过重要通知推送,提供商配置页加入额度提醒开关与阈值
- 重要通知页加入配置可用性守卫:未配置任一通道时禁用总开关,未配置邮件/SendKey 时禁用对应通道开关
- 测试通知端点支持 channel 过滤(all/email/server_chan),并绕过总开关与通道开关,便于配置阶段先验证通道
- 修复:测试通知路由未在 buffered-body 白名单导致 channel 参数丢失、测试时邮件分支被误触发
- 修复:sub2api 验证响应中 username 为 null 时正确回退到 email,避免误报"验证响应缺少: 用户信息"
Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
d51b44d642
commit
6c16f399d4
@@ -797,22 +797,13 @@ pub fn admin_provider_ops_sub2api_verify_payload(
|
||||
}
|
||||
}
|
||||
|
||||
let username_or_email = admin_provider_ops_sub2api_non_empty_string(user_data, "username")
|
||||
.or_else(|| admin_provider_ops_sub2api_non_empty_string(user_data, "email"));
|
||||
admin_provider_ops_verify_success(
|
||||
admin_provider_ops_verify_user_payload(
|
||||
user_data
|
||||
.get("username")
|
||||
.or_else(|| user_data.get("email"))
|
||||
.and_then(Value::as_str)
|
||||
.map(ToOwned::to_owned),
|
||||
user_data
|
||||
.get("username")
|
||||
.or_else(|| user_data.get("email"))
|
||||
.and_then(Value::as_str)
|
||||
.map(ToOwned::to_owned),
|
||||
user_data
|
||||
.get("email")
|
||||
.and_then(Value::as_str)
|
||||
.map(ToOwned::to_owned),
|
||||
username_or_email.clone(),
|
||||
username_or_email,
|
||||
admin_provider_ops_sub2api_non_empty_string(user_data, "email"),
|
||||
Some(balance + points),
|
||||
Some(extra),
|
||||
),
|
||||
@@ -820,6 +811,17 @@ pub fn admin_provider_ops_sub2api_verify_payload(
|
||||
)
|
||||
}
|
||||
|
||||
fn admin_provider_ops_sub2api_non_empty_string(
|
||||
map: &Map<String, Value>,
|
||||
key: &str,
|
||||
) -> Option<String> {
|
||||
map.get(key)
|
||||
.and_then(Value::as_str)
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(ToOwned::to_owned)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
@@ -913,6 +915,28 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sub2api_verify_payload_falls_back_to_email_when_username_is_null() {
|
||||
let payload = admin_provider_ops_sub2api_verify_payload(
|
||||
StatusCode::OK,
|
||||
&json!({
|
||||
"code": 0,
|
||||
"data": {
|
||||
"username": null,
|
||||
"email": "[email protected]",
|
||||
"balance": 2.0,
|
||||
"points": 0.0
|
||||
}
|
||||
}),
|
||||
None,
|
||||
);
|
||||
|
||||
assert_eq!(payload["success"], json!(true));
|
||||
assert_eq!(payload["data"]["username"], json!("[email protected]"));
|
||||
assert_eq!(payload["data"]["display_name"], json!("[email protected]"));
|
||||
assert_eq!(payload["data"]["email"], json!("[email protected]"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn anyrouter_verify_payload_uses_cookie_auth_messages_and_usage_fields() {
|
||||
let payload = admin_provider_ops_anyrouter_verify_payload(
|
||||
|
||||
Reference in New Issue
Block a user