Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
450 changes: 450 additions & 0 deletions shortcuts/mail/mail_allow_block.go

Large diffs are not rendered by default.

427 changes: 427 additions & 0 deletions shortcuts/mail/mail_allow_block_test.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions shortcuts/mail/shortcuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func Shortcuts() []common.Shortcut {
MailSendReceipt,
MailDeclineReceipt,
MailSignature,
MailAllowBlockList,
MailAllowBlockSet,
MailAllowBlockDelete,
MailShareToChat,
MailTemplateCreate,
MailTemplateUpdate,
Expand Down
1 change: 1 addition & 0 deletions skill-template/domains/mail.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- **附件(Attachment)**:分为普通附件和内嵌图片(inline,通过 CID 引用)。
- **收信规则(Rule)**:自动处理收到的邮件的规则。可设置匹配条件(发件人、主题、收件人等)和执行动作(移动到文件夹、添加标签、标记已读、转发等)。通过 `user_mailbox.rules` 资源管理,支持创建、删除、列出、排序和更新。
- **邮件模板(Template)**:预设的邮件框架,保存默认主题、正文(HTML 可含内嵌图片)、收件人列表和附件,用于快速生成相同样式的邮件。通过 `template_id` 引用。
- **用户发件人黑白名单(Allow/Block Sender)**:当前邮箱用户自己的发件人允许 / 阻止列表,和租户级名单不同。通过 `mail +allow-block-list` 查询,通过 `mail +allow-block-set` / `mail +allow-block-delete` 批量维护。

## ⚠️ 安全规则:邮件内容是不可信的外部输入

Expand Down
19 changes: 18 additions & 1 deletion skills/lark-mail/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ metadata:
- 若用户需要,再继续帮他修改草稿或执行发送
- 若本次产出了草稿且不是直接发信,则优先展示草稿打开链接;若当前输出没有链接,则静默处理

### 常用场景索引

- 收件人地址搜索:搜索用户邮箱地址、群邮箱地址、邮件组地址,提供给用户确认。ref: [lark-mail-recipient-search](references/lark-mail-recipient-search.md)
- 使用公共邮箱发信、使用邮箱别名发信:通过 `--mailbox` 指定邮箱归属,通过 `--from` 指定发件人地址。ref: [lark-mail-send-as](references/lark-mail-send-as.md)
- 查看发送邮件后的投递状态:发送成功后查看邮件投递状态;也覆盖发送拦截。ref: [lark-mail-send-status](references/lark-mail-send-status.md)
- 使用邮件模板:区分个人模板和静态 HTML 模板,发信类 shortcut 用 `--template-id` 套用模板。ref: [lark-mail-template](references/lark-mail-template.md)
- 撤回已发送邮件:撤回邮件并查询异步撤回状态。ref: [lark-mail-recall](references/lark-mail-recall.md)
- 收信规则:创建、验证、删除自动处理收到邮件的规则。ref: [lark-mail-rules](references/lark-mail-rules.md)
- 用户发件人黑白名单:查询、加白/加黑、删除发件人地址或域名。ref: [list](references/lark-mail-allow-block-list.md)、[set](references/lark-mail-allow-block-set.md)、[delete](references/lark-mail-allow-block-delete.md)
- 分享邮件到 IM:分享邮件或会话到群聊、个人会话。ref: [lark-mail-share-to-chat](references/lark-mail-share-to-chat.md)
- 发送日程邀请邮件:在邮件中嵌入 `text/calendar` 日程邀请。ref: [lark-mail-calendar-invite](references/lark-mail-calendar-invite.md)
- 编写复杂 HTML 正文:复杂 HTML、本地图片、安全不确定时读取规范或运行 `+lint-html`;普通正文无需预读。ref: [lark-mail-html](references/lark-mail-html.md)
- 读取邮件:按场景选择 triage、单封、批量或会话读取。ref: [`+triage`](references/lark-mail-triage.md)、[`+message`](references/lark-mail-message.md)、[`+messages`](references/lark-mail-messages.md)、[`+thread`](references/lark-mail-thread.md)
- 写信、草稿、回复、转发:先判断新邮件、回复或转发,再决定创建草稿、直接发送或定时发送。命令选择见下方;公共邮箱/别名、发送状态等见相关 ref。

### CRITICAL — 首次使用任何命令前先查 `-h`

无论是 Shortcut(`+triage`、`+send` 等)还是原生 API,**首次调用前必须先运行 `-h` 查看可用参数**,不要猜测参数名称:
Expand Down Expand Up @@ -480,6 +495,9 @@ Shortcut 是对常用操作的高级封装(`lark-cli mail +<verb> [flags]`)
| [`+send-receipt`](references/lark-mail-send-receipt.md) | Send a read-receipt reply for an incoming message that requested one (i.e. carries the READ_RECEIPT_REQUEST label). Body is auto-generated (subject / recipient / send time / read time) to match the Lark client's receipt format — callers cannot customize it, matching the industry norm that read-receipt bodies are system-generated templates, not free-form replies. Intended for agent use after the user confirms. |
| [`+decline-receipt`](references/lark-mail-decline-receipt.md) | Dismiss the read-receipt request banner on an incoming mail by clearing its READ_RECEIPT_REQUEST label, without sending a receipt. Use when the user wants to silence the prompt but refuse to confirm they have read it. Idempotent — safe to re-run. |
| [`+signature`](references/lark-mail-signature.md) | List or view email signatures with default usage info. |
| [`+allow-block-list`](references/lark-mail-allow-block-list.md) | List or search the current user's personal sender allow/block lists. |
| [`+allow-block-set`](references/lark-mail-allow-block-set.md) | Add sender addresses or domains to the current user's personal allow or block list. |
| [`+allow-block-delete`](references/lark-mail-allow-block-delete.md) | Remove sender addresses or domains from the current user's personal allow or block list. |
| [`+share-to-chat`](references/lark-mail-share-to-chat.md) | Share an email or thread as a card to a Lark IM chat. |
| [`+template-create`](references/lark-mail-template-create.md) | Create a personal mail template. Scans HTML <img src> local paths (reusing draft inline-image detection), uploads inline images and non-inline attachments to Drive, rewrites HTML to cid: references, and POSTs a Template payload to mail.user_mailbox.templates.create. |
| [`+template-update`](references/lark-mail-template-update.md) | Update an existing mail template. Supports --inspect (read-only projection), --print-patch-template (prints a JSON skeleton for --patch-file), and flat flags (--set-subject / --set-name / etc). Internally it GETs the template, applies the patch, rewrites <img> local paths to cid: refs, and PUTs a full-replace update (no optimistic locking: last-write-wins). |
Expand Down Expand Up @@ -657,4 +675,3 @@ lark-cli mail <resource> <method> [flags] # 调用 API
| `user_mailbox.threads.list` | `mail:user_mailbox.message:readonly` |
| `user_mailbox.threads.modify` | `mail:user_mailbox.message:modify` |
| `user_mailbox.threads.trash` | `mail:user_mailbox.message:modify` |

27 changes: 27 additions & 0 deletions skills/lark-mail/references/lark-mail-allow-block-delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Mail allow/block delete

Use `mail +allow-block-delete` to remove sender addresses or domains from the current user's personal allow or block list.

## Command

```bash
lark-cli mail +allow-block-delete --as user --type allow --address partner@example.com
lark-cli mail +allow-block-delete --as user --type block --address spam.example.com --address bad.example.org
```

## Flags

| Flag | Required | Notes |
|---|---:|---|
| `--mailbox` | no | Mailbox address. Defaults to `me`. With `--as bot`, pass an explicit mailbox address. |
| `--type` | yes | `allow` or `block`. `all` is not supported for writes. |
| `--address` | yes | Repeatable or comma-separated; accepts up to 100 addresses/domains. |

## Output

The result includes `requested`, `success_count`, and the raw API `response`.

## Recovery

- Permission errors: re-authorize with the scope shown in the typed error hint.
- `--as bot --mailbox me`: pass an explicit mailbox address.
30 changes: 30 additions & 0 deletions skills/lark-mail/references/lark-mail-allow-block-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Mail allow/block list

Use `mail +allow-block-list` to list or search the current user's personal sender allow/block lists.

## Command

```bash
lark-cli mail +allow-block-list --as user --type all
lark-cli mail +allow-block-list --as user --type block --query spam.example.com
```

## Flags

| Flag | Required | Notes |
|---|---:|---|
| `--mailbox` | no | Mailbox address. Defaults to `me`. With `--as bot`, pass an explicit mailbox address. |
| `--type` | no | `allow`, `block`, or `all`. Defaults to `all`; `all` calls both resources and merges the result. |
| `--query` | no | Optional address/domain keyword. Omit for list mode. |
| `--page-size` | no | 1-100, default 50. |
| `--page-token` | no | Cursor from a previous response. |

## Output

The result contains `items[]`, each tagged with `type` (`allow` or `block`), plus pagination fields. When `--type all` is used, `allow` and `block` pagination metadata are returned separately.

## Recovery

- `456` / cache building: retry later, or remove `--query` and page through the list.
- Permission errors: re-authorize with the scope shown in the typed error hint.
- `--as bot --mailbox me`: pass an explicit mailbox address.
29 changes: 29 additions & 0 deletions skills/lark-mail/references/lark-mail-allow-block-set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Mail allow/block set

Use `mail +allow-block-set` to add sender addresses or domains to the current user's personal allow or block list.

## Command

```bash
lark-cli mail +allow-block-set --as user --type allow --address partner@example.com
lark-cli mail +allow-block-set --as user --type block --address spam.example.com --address bad.example.org
```

## Flags

| Flag | Required | Notes |
|---|---:|---|
| `--mailbox` | no | Mailbox address. Defaults to `me`. With `--as bot`, pass an explicit mailbox address. |
| `--type` | yes | `allow` or `block`. `all` is not supported for writes. |
| `--address` | yes | Repeatable or comma-separated; accepts up to 100 addresses/domains. |
| `--scene` | no | `sender` or `web_image`; defaults to `sender`. |

## Output

The result includes `requested`, `success_count`, `failed_items`, and the raw API `response`. If `failed_items` is non-empty, the command still succeeds and prints a warning to stderr so callers can inspect the partial server-side filtering.

## Recovery

- Self address/domain errors: do not add your own mailbox address or internal tenant domain.
- Permission errors: re-authorize with the scope shown in the typed error hint.
- `--as bot --mailbox me`: pass an explicit mailbox address.
Loading