Skip to content

feat(mail): add allow-block sender shortcuts#1728

Open
sysuljx wants to merge 4 commits into
larksuite:mainfrom
sysuljx:feat/a834648
Open

feat(mail): add allow-block sender shortcuts#1728
sysuljx wants to merge 4 commits into
larksuite:mainfrom
sysuljx:feat/a834648

Conversation

@sysuljx

@sysuljx sysuljx commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Adds mail shortcuts for managing allow and block sender lists.

  • Adds list, search, set, and delete commands for allow/block senders.
  • Implements request validation, dry-run output, HTTP method/path/body handling, address parsing, and user-facing error hints.
  • Registers the shortcuts and covers validation, request construction, address files, retry hints, and error wrapping in tests.
  • Updates the mail skill documentation and references for the new commands.

Summary by CodeRabbit

  • New Features
    • Added user-level mail allow/block sender list commands: +allow-block-list, +allow-block-search, +allow-block-set, +allow-block-delete (listing/searching, bulk add, and remove).
    • Supports pagination + keyword search, stricter --type rules, and --address-file bulk input with trimming/deduping; list output aggregates allow/block with per-list counts.
  • Bug Fixes
    • +allow-block-delete preserves original address casing and improves deletion success counting across response formats.
  • Documentation
    • Updated mail and skill docs with the user-level workflow, plus preview/confirmation requirements for set/delete.
  • Tests
    • Added coverage for command registration, validation, dry-run payloads, set/delete behavior, and API error hinting.

@github-actions github-actions Bot added domain/mail PR touches the mail domain size/L Large or sensitive change across domains or core paths labels Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bd24a1fa-ce77-4857-8837-96bf041f12b2

📥 Commits

Reviewing files that changed from the base of the PR and between 1a525ef and e3d96e3.

📒 Files selected for processing (1)
  • skills/lark-mail/references/lark-mail-allow-block.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-mail/references/lark-mail-allow-block.md

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Allow/Block sender list feature

Layer / File(s) Summary
Shared constants and helpers
shortcuts/mail/mail_allow_block.go
Defines allow/block constants and limits, shared flags, output shapes, validation helpers, request builders, item normalization, count conversion, and API error decoration helpers.
List and search shortcuts
shortcuts/mail/mail_allow_block.go
Implements +allow-block-list and +allow-block-search, including shortcut wiring, validation, backend GET requests, aggregation, and formatted output.
Set and delete shortcuts
shortcuts/mail/mail_allow_block.go
Implements +allow-block-set and +allow-block-delete, including address collection, file reading, deduplication, batch payload construction, API invocation, fallback handling, and formatted counts.
Shortcut registration
shortcuts/mail/shortcuts.go
Registers the four new allow-block shortcuts in Shortcuts().
Unit tests for allow-block shortcuts
shortcuts/mail/mail_allow_block_test.go
Adds tests for registration, validation, dry-run API targets, file-backed sender input, delete casing, list aggregation, and API error decoration.
Skill and reference documentation
skill-template/domains/mail.md, skills/lark-mail/SKILL.md, skills/lark-mail/references/lark-mail-allow-block.md
Updates skill-template and lark-mail documentation to define the user-level allow/block sender list, require confirmation for set/delete, and add a dedicated reference guide.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant MailAllowBlockSet
  participant MailAllowBlockDelete
  participant SenderAPI
  CLI->>MailAllowBlockSet: --address / --address-file
  MailAllowBlockSet->>MailAllowBlockSet: parse, dedupe, enforce max count
  MailAllowBlockSet->>SenderAPI: POST batch create senders
  SenderAPI-->>MailAllowBlockSet: succeeded/failed counts or error
  MailAllowBlockSet-->>CLI: decorated error or formatted output
  CLI->>MailAllowBlockDelete: --address / --address-file
  MailAllowBlockDelete->>SenderAPI: DELETE batch senders
  SenderAPI-->>MailAllowBlockDelete: deleted count or error
  MailAllowBlockDelete-->>CLI: formatted output
Loading

Possibly related PRs

  • larksuite/cli#749: Extends the same confirmation-rule documentation pattern used here for +allow-block-set and +allow-block-delete.

Suggested reviewers: chanthuang, infeng

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change summary but omits required template sections for Test Plan and Related Issues. Rewrite the PR description using the repository template, adding Summary, Changes, Test Plan, and Related Issues sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: new allow/block sender shortcuts for mail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Quality Summary

CI did not complete successfully. Use the failed check links below to decide whether this PR needs a code change or a rerun.

Failed checks

  • deterministic-gate — failure — details
  • results — failure — details

deterministic-gate

  • public_content_change_id_trailercommit:cccf025599d9:9 — public contribution contains a Change-Id trailer — Action: remove the value from the public contribution and replace it with a non-sensitive placeholder

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@e3d96e3f0781a086564805d4672b4683953125df

🧩 Skill update

npx skills add sysuljx/cli#feat/a834648 -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
shortcuts/mail/mail_allow_block_test.go (1)

273-293: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Hardcoded page-size default applied to all int flags.

Every int-typed flag gets allowBlockDefaultPageSize as its default here, regardless of fl.Default. Currently harmless since the only int flag (page-size) is always overridden via values, but this will silently produce a wrong default if another int flag is added or a test omits an override for page-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

📥 Commits

Reviewing files that changed from the base of the PR and between c2d6038 and dc55434.

📒 Files selected for processing (6)
  • shortcuts/mail/mail_allow_block.go
  • shortcuts/mail/mail_allow_block_test.go
  • shortcuts/mail/shortcuts.go
  • skill-template/domains/mail.md
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-allow-block.md

Comment thread shortcuts/mail/mail_allow_block_test.go
Comment thread shortcuts/mail/mail_allow_block.go Outdated
Comment thread skills/lark-mail/references/lark-mail-allow-block.md Outdated
sysuljx added 3 commits July 3, 2026 12:05
Use shortcut runtime FileIO for address files, strengthen validation assertions, and clarify rejected sender retry guidance.

Change-Type: ci-fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/mail PR touches the mail domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant