feat(mail): add allow-block sender shortcuts#1728
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds four mail shortcuts for per-user sender allow/block list management, including list/search/set/delete flows, validation, file-backed address input, API error decoration, registration, tests, and documentation updates. ChangesAllow/Block sender list feature
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant MailAllowBlockList
participant MailAllowBlockSet
participant MailAllowBlockDelete
participant MailBackend
CLI->>MailAllowBlockList: +allow-block-list / +allow-block-search
MailAllowBlockList->>MailBackend: GET allow_senders or blocked_senders
MailBackend-->>MailAllowBlockList: items and counts
MailAllowBlockList-->>CLI: formatted list/search output
CLI->>MailAllowBlockSet: +allow-block-set with addresses
MailAllowBlockSet->>MailBackend: POST batch_create
MailBackend-->>MailAllowBlockSet: failed_items / requested counts
MailAllowBlockSet-->>CLI: formatted set output
CLI->>MailAllowBlockDelete: +allow-block-delete with addresses
MailAllowBlockDelete->>MailBackend: DELETE batch_delete
MailBackend-->>MailAllowBlockDelete: deleted_count or fallback error
MailAllowBlockDelete-->>CLI: formatted delete output
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@2429df4777d3ecd5996f9915fcb24ebea7f89229🧩 Skill updatenpx skills add sysuljx/cli#feat/a834648 -y -g |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
shortcuts/mail/mail_allow_block_test.go (1)
273-293: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueHardcoded page-size default applied to all int flags.
Every
int-typed flag getsallowBlockDefaultPageSizeas its default here, regardless offl.Default. Currently harmless since the only int flag (page-size) is always overridden viavalues, but this will silently produce a wrong default if another int flag is added or a test omits an override forpage-size.♻️ Suggested fix to parse the flag's own default
switch fl.Type { case "int": - cmd.Flags().Int(fl.Name, allowBlockDefaultPageSize, "") + def, _ := strconv.Atoi(fl.Default) + cmd.Flags().Int(fl.Name, def, "")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@shortcuts/mail/mail_allow_block_test.go` around lines 273 - 293, The helper runtimeForAllowBlockDryRun is hardcoding allowBlockDefaultPageSize for every int flag instead of using each flag’s own default. Update the flag initialization loop to read fl.Default for int-typed flags as well, so future int flags and any tests that rely on the declared default behave correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/mail/mail_allow_block_test.go`:
- Around line 32-78: The validation test helper is too weak because
assertValidationError only checks the message text, so regressions in
category/subtype/param can slip through. Update assertValidationError to verify
the returned error with errs.ProblemOf and confirm the validation cause is
preserved, then keep TestAllowBlockValidate using that helper for
MailAllowBlockList, MailAllowBlockSearch, MailAllowBlockSet, and
MailAllowBlockDelete.
In `@shortcuts/mail/mail_allow_block.go`:
- Line 15: The shortcuts/mail package is importing internal/vfs directly, which
violates shortcuts-no-vfs. Update mail_allow_block.go to use runtime.FileIO()
and runtime.ValidatePath() for file access instead of vfs, and if the code needs
the entire file contents, open it through runtime.FileIO().Open() and read it
with io.ReadAll(); keep the change localized to the mail shortcut flow and any
helpers it calls.
In `@skills/lark-mail/references/lark-mail-allow-block.md`:
- Line 53: The allow/block list flow in the lark-mail reference should not
silently remove API-rejected senders and retry, because that makes the confirmed
payload differ from the actual write. Update the guidance to require surfacing
the rejected values, showing the adjusted final sender list/count again, and
asking the user to re-confirm before any retry or set/delete operation. Keep the
preview/confirmation requirement aligned with the final payload in the
allow/block list workflow.
---
Nitpick comments:
In `@shortcuts/mail/mail_allow_block_test.go`:
- Around line 273-293: The helper runtimeForAllowBlockDryRun is hardcoding
allowBlockDefaultPageSize for every int flag instead of using each flag’s own
default. Update the flag initialization loop to read fl.Default for int-typed
flags as well, so future int flags and any tests that rely on the declared
default behave correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 59b152a4-abb9-4d10-8c7a-3198565a3698
📒 Files selected for processing (6)
shortcuts/mail/mail_allow_block.goshortcuts/mail/mail_allow_block_test.goshortcuts/mail/shortcuts.goskill-template/domains/mail.mdskills/lark-mail/SKILL.mdskills/lark-mail/references/lark-mail-allow-block.md
Use shortcut runtime FileIO for address files, strengthen validation assertions, and clarify rejected sender retry guidance. Change-Type: ci-fix
Change-Type: ci-fix
| } | ||
| listType := runtime.Str("type") | ||
| data, err := runtime.CallAPITyped("DELETE", | ||
| allowBlockResourcePath(resolveMailboxID(runtime), listType)+"/batch_delete", |
There was a problem hiding this comment.
🤖 AI Review | [P1 稳定性] 删除命令调用了未注册的 OAPI 路径
+allow-block-delete 的 dry-run 和执行路径都拼成 DELETE .../batch_delete,但本轮 registry Meta 新增的用户级 allow/block sender 删除接口是 POST .../batch_remove(见 lark/larksuite-cli-registry!113 中 registry-conf/meta/mail_v1.json 的 user_mailbox.*.batch_remove)。真实 OAPI 只会注册 Meta 里的 method/path,当前 CLI 删除命令会打到未注册路由,用户删除白/黑名单时会遇到 404/405 或网关找不到接口。
修复建议: 将 CLI 删除逻辑、dry-run、单测和 skill 文档统一改为 POST {allow_senders|blocked_senders}/batch_remove,或者反向调整 registry/OpenAPI 契约为 DELETE .../batch_delete;关键是 5 个仓库的 method/path 保持一致。
如有疑问或认为判断不准确,欢迎直接回复讨论。
Adds mail shortcuts for managing allow and block sender lists.
Summary by CodeRabbit
+allow-block-list,+allow-block-search,+allow-block-set,+allow-block-delete(list/search, bulk add, and remove).--typevalidation, and bulk input via--address-filewith trimming/deduping; results aggregate allow/block with per-list counts.+allow-block-deletepreserves original address casing and improves deletion success counting across response shapes.