From 229867c4e5a08cac2703afe53dce906a1060872c Mon Sep 17 00:00:00 2001 From: InfinityPacer Date: Mon, 31 Aug 2026 07:42:29 +0800 Subject: [PATCH] fix(notification): preserve architecture and locale contracts --- app/api/endpoints/notification.py | 22 ++++++++++------------ app/locales/en-US.json | 3 +++ app/locales/zh-TW.json | 3 +++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/api/endpoints/notification.py b/app/api/endpoints/notification.py index 32cf1345d..99175b619 100644 --- a/app/api/endpoints/notification.py +++ b/app/api/endpoints/notification.py @@ -6,7 +6,6 @@ from app.api.dependencies.auth import get_current_active_superuser from app.api.response import ResponseAPIRouter from app.application.configuration import get_configured_system_config from app.chain.notification import NotificationChain -from app.modules.wechatclawbot.wechatclawbot import WechatClawBot from app.schemas.common import ManageRequest as _SchemaManageRequest from app.schemas.response import Response as _SchemaResponse from app.schemas.system import NotificationConf @@ -58,19 +57,18 @@ async def save_config( saved = await get_configured_system_config().async_set(SystemConfigKey.Notifications, current) if saved is False: return _SchemaResponse(success=False, message="通知配置保存失败") - try: - # 配置写入成功后再同步 ClawBot 缓存,避免持久化失败留下半完成的登录状态。 - result = WechatClawBot.reconcile_cached_states(previous_data, current) - except Exception as error: + # 配置写入成功后再同步 ClawBot 缓存,避免持久化失败留下半完成的登录状态。 + result = NotificationChain().manage_channel( + channel="WechatClawBot", + action="reconcile_config", + previous=previous_data, + current=current, + ) + # ClawBot 模块未加载时无需阻断其它通知渠道的配置保存;模块加载后由链路完成缓存同步。 + if result and not result.get("success") and result.get("message") != "该通知渠道未启用或不支持此管理动作": return _SchemaResponse( success=False, - message=f"通知配置已保存,但缓存同步失败,请重试:{error}", - data={"value": current}, - ) - if not result.get("success"): - return _SchemaResponse( - success=False, - message=f"通知配置已保存,但缓存同步失败,请重试:{result.get('message')}", + message="通知配置已保存,但缓存同步失败,请重试", data={"value": current}, ) return _SchemaResponse(success=True, message="通知配置保存成功", data={"value": current}) diff --git a/app/locales/en-US.json b/app/locales/en-US.json index 6982b794c..58d7da671 100644 --- a/app/locales/en-US.json +++ b/app/locales/en-US.json @@ -112,6 +112,9 @@ "TMDB请求失败": "TMDB request failed", "媒体服务器请求失败": "Media server request failed", "附件保存失败": "Failed to save attachment", + "通知配置保存成功": "Notification configuration saved successfully", + "通知配置保存失败": "Failed to save notification configuration", + "通知配置已保存,但缓存同步失败,请重试": "Notification configuration was saved, but cache synchronization failed. Please try again", "该选择已失效,请重新发起选择": "This selection has expired. Please start the selection again", "会话不存在或无权访问": "The conversation does not exist or you do not have access", "会话保存失败": "Failed to save conversation", diff --git a/app/locales/zh-TW.json b/app/locales/zh-TW.json index 9ac8b3670..01d15d5d2 100644 --- a/app/locales/zh-TW.json +++ b/app/locales/zh-TW.json @@ -108,6 +108,9 @@ "TMDB请求失败": "TMDB 請求失敗", "媒体服务器请求失败": "媒體伺服器請求失敗", "附件保存失败": "附件儲存失敗", + "通知配置保存成功": "通知設定儲存成功", + "通知配置保存失败": "通知設定儲存失敗", + "通知配置已保存,但缓存同步失败,请重试": "通知設定已儲存,但快取同步失敗,請重試", "该选择已失效,请重新发起选择": "此選擇已失效,請重新發起選擇", "会话不存在或无权访问": "會話不存在或無權存取", "会话保存失败": "會話儲存失敗",