fix: prevent account_settings KV.put on empty fromBlockList (#847)

* fix: avoid KV.put when fromBlockList is empty

* docs: update English changelog for account_settings fix
This commit is contained in:
Dream Hunter
2026-03-02 00:27:24 +08:00
committed by GitHub
parent 0df74ee5cc
commit a5e5fceab5
3 changed files with 4 additions and 2 deletions

View File

@@ -14,6 +14,7 @@
### Bug Fixes
- fix: |Admin API| 修复 `/admin/account_settings` 在未配置 KV 且 `fromBlockList` 为空时触发 `Cannot read properties of undefined (reading 'put')` 的问题
- fix: |文档| 修复 User Mail API 文档中错误使用 `x-admin-auth` 的问题,改为正确的 `x-user-token`
- docs: |文档| 新增 Admin 删除邮件、删除邮箱地址、清空收件箱、清空发件箱 API 文档

View File

@@ -14,6 +14,7 @@
### Bug Fixes
- fix: |Admin API| Fix `/admin/account_settings` throwing `Cannot read properties of undefined (reading 'put')` when KV is not configured and `fromBlockList` is empty
- fix: |Docs| Fix User Mail API documentation incorrectly using `x-admin-auth`, changed to correct `x-user-token`
- docs: |Docs| Add Admin API documentation for delete mail, delete address, clear inbox, and clear sent items

View File

@@ -322,8 +322,8 @@ api.post('/admin/account_settings', async (c) => {
if (fromBlockList?.length > 0 && !c.env.KV) {
return c.text(msgs.EnableKVMsg, 400)
}
if (fromBlockList) {
await c.env.KV.put(CONSTANTS.EMAIL_KV_BLACK_LIST, JSON.stringify(fromBlockList || []))
if (fromBlockList?.length > 0 && c.env.KV) {
await c.env.KV.put(CONSTANTS.EMAIL_KV_BLACK_LIST, JSON.stringify(fromBlockList))
}
await saveSetting(
c, CONSTANTS.NO_LIMIT_SEND_ADDRESS_LIST_KEY,