Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rx_message里的rx是啥意思呀? #148

Open
shuaiyy opened this issue Apr 19, 2023 · 4 comments
Open

rx_message里的rx是啥意思呀? #148

shuaiyy opened this issue Apr 19, 2023 · 4 comments

Comments

@shuaiyy
Copy link

shuaiyy commented Apr 19, 2023

rx是啥的缩写呢,这个消息只是企业微信APP的消息吗?

我想复用这个结构实现处理 群机器人Webhook的回调消息。

// RxMessage 一条接收到的消息
type RxMessage struct {
	// FromUserID 发送者的 UserID
	FromUserID string
	// SendTime 消息发送时间
	SendTime time.Time
	// MsgType 消息类型
	MsgType MessageType
	// AgentID 企业应用 ID,可在应用的设置页面查看
	AgentID int64
	// Event 事件类型 MsgType为event存在
	Event EventType
	// ChangeType 变更类型 Event为change_external_contact存在
	ChangeType ChangeType
	extras messageKind
// --------- 类型变更  ---------------
	// MsgID 消息 ID, int64 --> string
	MsgID string
// ---------- 新增字段 ---------------
	// WebhookUrl 是否是webhook推送的消息
	WebhookUrl string
	// ChatType 消息类型
	ChatType ChatType
	// ChatID 消息 ID
	ChatID string

}
@xen0n
Copy link
Owner

xen0n commented Apr 19, 2023

网络领域 Tx/Rx 表示 transmit/receive 即 发送/接收。

关于 MsgIDstring 类型,我理解你可能想借此实现向前兼容?也就是说,即便用户不升级依赖的本库版本,也能捞着处理企业微信未来可能新增的消息类型?这么做情有可原,但我担心的是可能会造成事实上的弱类型。我个人可能需要再思考一下。

关于新增字段的部分,这种 webhook 回调消息从性质上说是否也是一种聊天消息?RxMessage 本义是用户在与 app 的聊天框里发送的消息。如果 webhook 回调消息不是一种聊天消息,那么复用同一个类型从领域建模上说就是不合适的。

@shuaiyy
Copy link
Author

shuaiyy commented Apr 19, 2023

MsgIDstring 类型,是因为群机器人消息的MsgID是string类型;

机器人webhook回调应该是一种聊天消息,下面内容是官方文档:

概述
最后更新:2022/06/29
关于接受消息
开发者在机器人配置界面设置接受消息的url,当用户与机器人发生交互的时候,交互事件将加密回调给机器人接受消息url,机器人服务通过接受解密并处理回调事件,实现更加丰富的自定义功能。

目前支持的交互事件回调:
1.用户群里@机器人或者单聊中向机器人发送文本消息或图文混排消息,查看文档
2.群机器人被添加到或被移除出群聊,查看文档
3.用户进入机器人单聊界面,查看文档
4.用户在单聊界面中给机器人发送图片消息,查看文档
5.用户点击模版卡片中的交互控件,查看文档

@xen0n
Copy link
Owner

xen0n commented Apr 19, 2023

MsgIDstring 类型,是因为群机器人消息的 MsgIDstring 类型

Okay 我之前以为是消息类型了。很不幸这个变化会破坏兼容,我应该会在 v2 考虑这一点。

下面内容是官方文档

这边的一些链接我没有权限查看,到时候可能无法协助验证。

@xen0n
Copy link
Owner

xen0n commented Apr 19, 2023

另外:如果没有看到完整文档,我也没有办法帮忙确认新增 API 的设计是否合理,这样的话只有等到文档公开了,才可能合并相关支持的 PR。(否则万一后边发现 API 设计要不兼容变更,就得发 v3 了。)

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

No branches or pull requests

2 participants