Repository navigation
feat(lark): 支持 im.message.recalled_v1 消息撤回事件转换为 message-deleted - #447
Open
VincentZyu233 wants to merge 1 commit into
Open
VincentZyu233 wants to merge 1 commit into
VincentZyu233 wants to merge 1 commit into
Conversation
- Add im.message.recalled_v1 event structure to Events interface - Adapt im.message.recalled_v1 to Satori session.type = 'message-deleted' - Populate session.messageId, channelId, guildId, userId, isDirect, and timestamp Co-authored-by: gemini-code-assist <200291788+gemini-code-assist@users.noreply.github.com>
Contributor
Author
🎬 飞书实机实测有效性验证与动图演示本 PR 的改动已在飞书官方客户端(桌面端单聊与群聊场景)完成全流程实测验证:
⚙️ 飞书开放平台后台配置指引(开发者配置要求)在飞书平台使用消息撤回感知能力,需要在 飞书开放平台开发者后台 完成以下两项配置:
|
There was a problem hiding this comment.
🟡 Changes recommended
Private-message recalls are misclassified because the payload lacks chat_type, causing downstream private-message filters to miss deletions; chat_mode should be resolved through a chat lookup.
1 open issue
What changed in this PR
本 PR 为飞书适配器增加消息撤回事件转换,使下游 Satori/Koishi 插件能够通过 message-deleted 监听撤回通知。
Changes:
- 补充
im.message.recalled_v1事件类型定义。 - 新增撤回事件处理分支,映射消息、会话、用户及时间戳等字段。
| File | Description |
|---|---|
adapters/lark/src/utils.ts |
定义撤回事件数据结构,并将其转换为标准 message-deleted 会话事件。 |
Review effort: Balanced
| session.channelId = body.event.chat_id | ||
| session.guildId = body.event.chat_id | ||
| session.userId = body.event.operator_id?.open_id || body.event.sender_id?.open_id | ||
| session.isDirect = body.event.chat_type === 'p2p' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


📝 变更概述
本 PR 为飞书适配器 (
@satorijs/adapter-lark) 增加了对飞书消息撤回事件 (im.message.recalled_v1) 的支持,并将其规范转换为 Satori 标准的message-deleted会话事件。🔍 背景与实现细节
event_type: "im.message.recalled_v1"事件。adapters/lark/src/utils.ts的adaptSession中未处理该事件类型,导致下游插件和 Koishi 生态无法监听到飞书平台的message-deleted事件。Events接口中补充im.message.recalled_v1事件的数据结构定义;adaptSession中增加im.message.recalled_v1的映射分支,将session.type设置为'message-deleted';session.messageId:对应body.event.message_id(真实被撤回的消息 ID);session.channelId与session.guildId:对应body.event.chat_id;session.userId:优先取操作者 open_id(body.event.operator_id?.open_id || body.event.sender_id?.open_id);session.isDirect:当body.event.chat_type === 'p2p'时为 true,否则为 false;session.timestamp:对应+body.event.recall_time。🧪 实测验证
ctx.on('message-deleted')能够准确实时捕获被撤回的消息 ID 并联动处理。