Skip to content

refactor(cyberhub): move draft toggle from Provider to ExportFilter#15

Open
wuchulonly wants to merge 1 commit into
masterfrom
feat/export-filter-with-draft
Open

refactor(cyberhub): move draft toggle from Provider to ExportFilter#15
wuchulonly wants to merge 1 commit into
masterfrom
feat/export-filter-with-draft

Conversation

@wuchulonly
Copy link
Copy Markdown
Contributor

@wuchulonly wuchulonly commented May 24, 2026

新增 ExportFilter.WithDraft(draft bool),透传 ?with_draft=true

Changes

  • pkg/types/export_filter.go: 加 Draft bool 字段 + WithDraft(bool) builder
  • pkg/cyberhub/client.go: applyFilterParamsfilter.Draft 为 true 时 params.Set("with_draft", "true")
  • pkg/cyberhub/provider.go: 移除上一条 commit (7e47524) 引入的 Provider.WithDraft() / Provider.draft,统一用 filter
  • pkg/cyberhub/client_test.go: 单元 + httptest 端到端

7e47524 加了 Provider.WithDraft() 把 ?with_draft=true 透传到导出 API。
现在把这个旋钮挪回 ExportFilter,跟 Statuses / ReviewStatus / 其它 With*
builder 放一起,理由:

- 一致性:所有 export 时的"问什么/怎么问"参数都集中在 ExportFilter,
  Provider 只负责"地址 / 鉴权 / 超时 / filter"四件事;
- 可达:filter.Draft 是值字段,bool 入参的 WithDraft(draft bool)
  允许显式 false 关闭(toggle 风格的 Provider.WithDraft() 没办法关);
- DRY:with_draft 这条 query 只在 applyFilterParams 里 set 一次,
  不再在 exportFingers / exportPOCs 两边各重复一次内联 if。

types.ExportFilter:
- 新增 Draft bool 字段;
- 新增 WithDraft(draft bool) *ExportFilter builder;
- 文档点明它与 Statuses / ReviewStatus 正交(filter 决定"哪些行",
  Draft 决定"读哪一列")。

pkg/cyberhub/provider.go:
- 移除 Provider.draft 字段和 Provider.WithDraft() 方法;
- Fingers / POCs 不再传 draft 参数,filter 自己带。

pkg/cyberhub/client.go:
- exportFingers / exportPOCs 签名去掉 draft bool 入参;
- 删掉两个函数里内联的 `if draft { params.Set("with_draft", "true") }`;
- 在 applyFilterParams 里集中处理 with_draft 透传。

pkg/cyberhub/client_test.go:
- TestApplyFilterParams_Draft 覆盖 default false / true / 与 Statuses+
  ReviewStatus 共存 / nil filter 四种场景;
- TestWithDraftBuilder 验证 builder 链返回值;
- 新增 TestProvider_DraftBehavior 以 httptest 跑端到端:Fingers + POCs
  各两种(不带 Draft / WithDraft+WithReviewStatus),并验证 POCs
  WithDraft 单独使用时 default active 仍然兜底。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant