docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批: 已推库 16 个文件 + 本批剩余文件)。 校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0); 全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
This commit is contained in:
1 parent
91e8d7a029
commit
074ffc4ebf
73 files changed
+2529
-2529
No files matched your search
@@ -16,9 +16,9 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/plugins/channels/weixin_ilink"
|
||||
)
|
||||
|
||||
// rescanStubAdapter is a channel adapter that also exposes the optional rescan
|
||||
// capability, exactly as *weixin_ilink.Adapter does once iLink answers
|
||||
// errcode=-14 (session rejected, re-scan required).
|
||||
// rescanStubAdapter 是一个渠道适配器,它同时暴露可选的 rescan
|
||||
// 能力,正如 *weixin_ilink.Adapter 在 iLink 应答 errcode=-14
|
||||
// (会话被拒,需要重新扫码)之后那样。
|
||||
type rescanStubAdapter struct {
|
||||
name string
|
||||
connected bool
|
||||
@@ -47,9 +47,9 @@ func (s *rescanStubAdapter) ReadMessages(ctx context.Context, _ func(adapter.Uni
|
||||
}
|
||||
func (s *rescanStubAdapter) RescanRequired() (bool, string) { return s.rescan, s.reason }
|
||||
|
||||
// namedRescanAdapter mirrors cmd/cyrene's namedAdapter: an unexported wrapper
|
||||
// embedding adapter.PlatformAdapter, which promotes only the interface's methods.
|
||||
// The gateway therefore has to unwrap it to reach the adapter's rescan capability.
|
||||
// namedRescanAdapter 仿照 cmd/cyrene 的 namedAdapter:一个内嵌
|
||||
// adapter.PlatformAdapter 的未导出包装器,它只提升接口的方法。
|
||||
// 因此网关必须拆开它才能抵达适配器的 rescan 能力。
|
||||
type namedRescanAdapter struct{ adapter.PlatformAdapter }
|
||||
|
||||
var (
|
||||
@@ -57,15 +57,15 @@ var (
|
||||
_ sdk.Channel = namedRescanAdapter{}
|
||||
)
|
||||
|
||||
// TestAdminChannelsReportsNeedsRescan asserts the panel can tell "needs a fresh
|
||||
// scan" apart from plain "not connected": the rejected adapter's row carries
|
||||
// needsRescan + the reason, and a healthy adapter omits both rather than shipping
|
||||
// a fabricated value.
|
||||
// TestAdminChannelsReportsNeedsRescan 断言面板能把「需要重新扫码」
|
||||
// 与单纯的「未连接」区分开:被拒适配器的行携带
|
||||
// needsRescan + 原因,而健康适配器两者都省略,
|
||||
// 而不是送出一个编造的值。
|
||||
func TestAdminChannelsReportsNeedsRescan(t *testing.T) {
|
||||
t.Parallel()
|
||||
const reason = "iLink getupdates 返回 errcode=-14(本次会话已被 iLink 拒绝)"
|
||||
caps := capreg.New()
|
||||
// Registered through the wrapper, the way the composition root registers it.
|
||||
// 经包装器注册,与组合根注册它的方式一致。
|
||||
if err := caps.Register(capreg.Capability{
|
||||
Name: "weixin-ilink",
|
||||
Kind: capreg.KindChannel,
|
||||
@@ -112,8 +112,8 @@ func TestAdminChannelsReportsNeedsRescan(t *testing.T) {
|
||||
t.Errorf("telegram = %+v, want a connected row without rescan fields", tg)
|
||||
}
|
||||
|
||||
// The healthy channel must OMIT the fields (omitempty), not send defaults: the
|
||||
// panel distinguishes "adapter did not report" from "adapter reported false".
|
||||
// 健康渠道必须省略这些字段(omitempty),而不是发送默认值:
|
||||
// 面板要区分「适配器未报告」与「适配器报告了 false」。
|
||||
var raw []map[string]json.RawMessage
|
||||
if err := json.Unmarshal(decodeBody(t, body)["data"], &raw); err != nil {
|
||||
t.Fatalf("decode raw items: %v (body=%s)", err, body)
|
||||
@@ -129,15 +129,15 @@ func TestAdminChannelsReportsNeedsRescan(t *testing.T) {
|
||||
t.Error("telegram row carries lastError although there is none")
|
||||
}
|
||||
}
|
||||
// The reason is informational text, never a credential.
|
||||
// 原因是提示性文本,绝不是凭据。
|
||||
if strings.Contains(string(body), `"bot_token"`) {
|
||||
t.Errorf("channel list leaked a bot_token field: %s", body)
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminChannelOpenRejectedSessionReturns409 asserts the open endpoint answers
|
||||
// honestly for a session a reconnect cannot fix: 409 session_rejected with the
|
||||
// re-scan instruction, never a 200 that would make the panel show "connected".
|
||||
// TestAdminChannelOpenRejectedSessionReturns409 断言 open 端点对重连
|
||||
// 修不好的会话诚实作答:409 session_rejected 附带重新扫码
|
||||
// 指引,绝不返回会让面板显示「已连接」的 200。
|
||||
func TestAdminChannelOpenRejectedSessionReturns409(t *testing.T) {
|
||||
t.Parallel()
|
||||
caps := capreg.New()
|
||||
@@ -175,10 +175,10 @@ func TestAdminChannelOpenRejectedSessionReturns409(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdminChannelsRescanFromRealIlinkAdapter closes the loop across the layers:
|
||||
// a REAL *weixin_ilink.Adapter that iLink answered errcode=-14 for, registered the
|
||||
// way the composition root registers it (wrapped), must surface needsRescan +
|
||||
// lastError in the admin channel list.
|
||||
// TestAdminChannelsRescanFromRealIlinkAdapter 跨层闭环:一个真正被
|
||||
// iLink 应答 errcode=-14 的 *weixin_ilink.Adapter,按组合根
|
||||
// 注册它的方式(包装后)注册,必须在管理渠道列表中
|
||||
// 浮现 needsRescan + lastError。
|
||||
func TestAdminChannelsRescanFromRealIlinkAdapter(t *testing.T) {
|
||||
t.Parallel()
|
||||
ilog := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in new issue
Block a user