docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批:
已推库 16 个文件 + 本批剩余文件)。
校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0);
全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
This commit is contained in:
AskaEth committed 2026-10-03 22:28:25 +08:00
1 parent 91e8d7a029
commit 074ffc4ebf
73 files changed
+2529 -2529

No files matched your search

@@ -16,8 +16,8 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/pkg/plugins/sdk"
)
// stubChannelConfigStore is a ChannelConfigStore backed by an in-memory map and a
// real temp channels.json path, recording Reload calls.
// stubChannelConfigStore 是一个 ChannelConfigStore,后端是内存 map 与
// 真实临时 channels.json 路径,并记录 Reload 调用。
type stubChannelConfigStore struct {
path string
accounts map[string][]config.ChannelAccount
@@ -37,9 +37,9 @@ func (s *stubChannelConfigStore) Reload(platform string) error {
return s.reloadErr
}
// stubNamedChannel is an sdk.Channel with a caller-chosen adapter name, so a test
// can register a multi-account adapter (kook:3fc8) distinct from its bare-platorm
// sibling and observe which entries survive a config change.
// stubNamedChannel 是一个 sdk.Channel,适配器名由调用方选定,
// 使测试能注册一个多账号适配器(kook:3fc8),与它的裸平台
// 兄弟区分开,并观察配置变更后哪些条目存活。
type stubNamedChannel struct {
name string
}
@@ -80,7 +80,7 @@ func TestAdminSaveChannelConfigPersistsAndReloads(t *testing.T) {
t.Fatalf("save res = %+v", res)
}
// The account landed in channels.json with the real token and the black-list.
// 该账号带着真实 token 与黑名单落到了 channels.json。
accounts, warn := runtimeconfig.LoadChannels(path, nil)
if warn != nil {
t.Fatalf("load channels warn = %v", warn)
@@ -96,12 +96,12 @@ func TestAdminSaveChannelConfigPersistsAndReloads(t *testing.T) {
t.Fatalf("groupMsgPerMin = %d, want 3", kook[0].GroupMsgPerMin)
}
// Reload was triggered for the saved platform.
// 已为保存的平台触发了 Reload。
if len(store.reloaded) != 1 || store.reloaded[0] != "kook" {
t.Fatalf("reloaded = %v, want [kook]", store.reloaded)
}
// GET /admin/channels reflects the account and never leaks the raw token.
// GET /admin/channels 反映了该账号,且绝不泄露原始 token。
gResp, gBody := doReq(t, http.MethodGet, ts.URL+"/api/v1/admin/channels", nil, tok)
if gResp.StatusCode != http.StatusOK {
t.Fatalf("get status = %d, want 200 (body=%s)", gResp.StatusCode, gBody)
@@ -124,7 +124,7 @@ func TestAdminSaveChannelConfigRejectsBlank(t *testing.T) {
if resp.StatusCode != http.StatusBadRequest {
t.Fatalf("blank config status = %d, want 400 (body=%s)", resp.StatusCode, body)
}
// No reload should have been triggered.
// 不应触发任何重载。
if len(store.reloaded) != 0 {
t.Fatalf("reloaded = %v, want none", store.reloaded)
}
@@ -132,7 +132,7 @@ func TestAdminSaveChannelConfigRejectsBlank(t *testing.T) {
func TestAdminSaveChannelConfigUnwired500(t *testing.T) {
t.Parallel()
_, ts, jwt := buildEnv(t, cfgDefault(), Deps{}) // no channel config store
_, ts, jwt := buildEnv(t, cfgDefault(), Deps{}) // 无渠道配置存储
tok := signAny(t, jwt, "acct", auth.RoleOwner)
resp, body := doReq(t, http.MethodPut, ts.URL+"/api/v1/admin/channels/kook/config",
map[string]any{"token": "x"}, tok)
@@ -157,7 +157,7 @@ func TestAdminDeleteChannelConfig(t *testing.T) {
if len(store.reloaded) != 1 || store.reloaded[0] != "kook" {
t.Fatalf("reloaded = %v, want [kook]", store.reloaded)
}
// The file is rewritten without the account; the platform key is dropped.
// 文件被重写且不含该账号;平台键被删除。
accounts, warn := runtimeconfig.LoadChannels(path, nil)
if warn == nil {
t.Fatalf("expected a warn after deleting the last account (empty map is invalid)")
@@ -167,9 +167,9 @@ func TestAdminDeleteChannelConfig(t *testing.T) {
}
}
// adminChannelsList is a small read helper that issues GET /admin/channels and
// decodes the data array, returning the raw body too so a caller can assert that a
// secret never leaked. It fails the test on any transport/parse error.
// adminChannelsList 是一个小的读辅助函数:发起 GET /admin/channels,
// 解码 data 数组,同时返回原始响应体,使调用方能断言
// 秘密从未泄露。任何传输/解析错误都会让测试失败。
func adminChannelsList(t *testing.T, ts *httptest.Server, token string) ([]ChannelSummary, []byte) {
t.Helper()
resp, body := doReq(t, http.MethodGet, ts.URL+"/api/v1/admin/channels", nil, token)
@@ -183,10 +183,10 @@ func adminChannelsList(t *testing.T, ts *httptest.Server, token string) ([]Chann
return items, body
}
// TestAdminDeleteChannelAccountRemovesFromList is the regression for the
// stale-adapter bug: deleting an account removes it from channels.json, but the
// adapter stays registered in caps. The list must still drop it (channels.json is
// the source of truth), so a deleted account never reappears on refresh.
// TestAdminDeleteChannelAccountRemovesFromList 是陈旧适配器 bug 的
// 回归:删除账号会把它从 channels.json 移除,但适配器
// 仍注册在 caps 中。列表必须仍然丢弃它(channels.json 是
// 唯一事实来源),因此已删除账号绝不在刷新时复现。
func TestAdminDeleteChannelAccountRemovesFromList(t *testing.T) {
t.Parallel()
caps := capreg.New()
@@ -202,7 +202,7 @@ func TestAdminDeleteChannelAccountRemovesFromList(t *testing.T) {
_, ts, jwt := buildEnv(t, cfgDefault(), Deps{Registry: caps, Channels: store})
tok := signAny(t, jwt, "acct", auth.RoleOwner)
// Before the delete the account shows up (aggregated into a single "kook" row).
// 删除前该账号会出现(聚合进单个 "kook" 行)。
items, _ := adminChannelsList(t, ts, tok)
if len(items) != 1 || items[0].Name != "kook" || len(items[0].Accounts) != 1 || items[0].Accounts[0].ID != "3fc8" {
t.Fatalf("before delete items = %+v, want one kook row with account 3fc8", items)
@@ -216,16 +216,16 @@ func TestAdminDeleteChannelAccountRemovesFromList(t *testing.T) {
t.Fatalf("reloaded = %v, want [kook]", store.reloaded)
}
// The stale adapter remains in caps (the bridge reload does not touch the
// registry), yet the deleted account must not reappear in the list.
// 陈旧适配器仍留在 caps 中(bridge 重载不触碰注册表),
// 但已删除的账号不得在列表中复现。
if items, _ := adminChannelsList(t, ts, tok); len(items) != 0 {
t.Fatalf("after delete items = %+v, want none (deleted account must vanish)", items)
}
}
// TestAdminDeleteChannelAccountKeepsSibling verifies that deleting one account of a
// multi-account platform drops only that account: the sibling adapter and its
// account remain, and the deleted one disappears.
// TestAdminDeleteChannelAccountKeepsSibling 验证删除多账号平台的
// 一个账号只丢弃该账号:兄弟适配器及其
// 账号保留,被删除的那个消失。
func TestAdminDeleteChannelAccountKeepsSibling(t *testing.T) {
t.Parallel()
caps := capreg.New()
@@ -260,10 +260,10 @@ func TestAdminDeleteChannelAccountKeepsSibling(t *testing.T) {
}
}
// TestAdminSaveChannelConfigListMirrorsChannelsJSON verifies the save path: after
// persisting an account the list reflects it, while a stale caps adapter for a
// different account id (here kook:oldid, never in channels.json) is dropped. The
// account's token is never leaked.
// TestAdminSaveChannelConfigListMirrorsChannelsJSON 验证保存路径:
// 持久化账号后列表会反映它,而针对不同账号 id(这里是
// kook:oldid,从未出现在 channels.json)的陈旧 caps 适配器被丢弃。该
// 账号的 token 从不泄露。
func TestAdminSaveChannelConfigListMirrorsChannelsJSON(t *testing.T) {
t.Parallel()
caps := capreg.New()