message.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. package msgaudit
  2. // BaseMessage 基础消息
  3. type BaseMessage struct {
  4. MsgID string `json:"msgid,omitempty"` // 消息 id,消息的唯一标识,企业可以使用此字段进行消息去重。
  5. Action string `json:"action,omitempty"` // 消息动作,目前有 send(发送消息)/recall(撤回消息)/switch(切换企业日志) 三种类型。
  6. From string `json:"from,omitempty"` // 消息发送方 id。同一企业内容为 userid,非相同企业为 external_userid。消息如果是机器人发出,也为 external_userid。
  7. ToList []string `json:"tolist,omitempty"` // 消息接收方列表,可能是多个,同一个企业内容为 userid,非相同企业为 external_userid。
  8. RoomID string `json:"roomid,omitempty"` // 群聊消息的群 id。如果是单聊则为空。
  9. MsgTime int64 `json:"msgtime,omitempty"` // 消息发送时间戳,utc 时间,ms 单位。
  10. MsgType string `json:"msgtype,omitempty"` // 文本消息为:text。
  11. }
  12. // TextMessage 文本消息
  13. type TextMessage struct {
  14. BaseMessage
  15. Text struct {
  16. Content string `json:"content,omitempty"` // 消息内容。
  17. } `json:"text,omitempty"`
  18. }
  19. // ImageMessage 图片消息
  20. type ImageMessage struct {
  21. BaseMessage
  22. Image struct {
  23. SdkFileID string `json:"sdkfileid,omitempty"` // 媒体资源的 id 信息。
  24. Md5Sum string `json:"md5sum,omitempty"` // 图片资源的 md5 值,供进行校验。
  25. FileSize uint32 `json:"filesize,omitempty"` // 图片资源的文件大小。
  26. } `json:"image,omitempty"`
  27. }
  28. // RevokeMessage 撤回消息
  29. type RevokeMessage struct {
  30. BaseMessage
  31. Revoke struct {
  32. PreMsgID string `json:"pre_msgid,omitempty"` // 标识撤回的原消息的 msgid
  33. } `json:"revoke,omitempty"`
  34. }
  35. // AgreeMessage 同意会话聊天内容
  36. type AgreeMessage struct {
  37. BaseMessage
  38. Agree struct {
  39. UserID string `json:"userid,omitempty"` // 同意/不同意协议者的 userid,外部企业默认为 external_userid。
  40. AgreeTime int64 `json:"agree_time,omitempty"` // 同意/不同意协议的时间,utc 时间,ms 单位。
  41. } `json:"agree,omitempty"`
  42. }
  43. // VoiceMessage 语音消息
  44. type VoiceMessage struct {
  45. BaseMessage
  46. Voice struct {
  47. SdkFileID string `json:"sdkfileid,omitempty"` // 媒体资源的 id 信息。
  48. VoiceSize uint32 `json:"voice_size,omitempty"` // 语音消息大小。
  49. PlayLength uint32 `json:"play_length,omitempty"` // 播放长度。
  50. Md5Sum string `json:"md5sum,omitempty"` // 图片资源的 md5 值,供进行校验。
  51. } `json:"voice,omitempty"`
  52. }
  53. // VideoMessage 视频消息
  54. type VideoMessage struct {
  55. BaseMessage
  56. Video struct {
  57. SdkFileID string `json:"sdkfileid,omitempty"` // 媒体资源的 id 信息。
  58. FileSize uint32 `json:"filesize,omitempty"` // 图片资源的文件大小。
  59. PlayLength uint32 `json:"play_length,omitempty"` // 播放长度。
  60. Md5Sum string `json:"md5sum,omitempty"` // 图片资源的 md5 值,供进行校验。
  61. } `json:"video,omitempty"`
  62. }
  63. // CardMessage 名片消息
  64. type CardMessage struct {
  65. BaseMessage
  66. Card struct {
  67. CorpName string `json:"corpname,omitempty"` // 名片所有者所在的公司名称。
  68. UserID string `json:"userid,omitempty"` // 名片所有者的 id,同一公司是 userid,不同公司是 external_userid
  69. } `json:"card,omitempty"`
  70. }
  71. // LocationMessage 位置消息
  72. type LocationMessage struct {
  73. BaseMessage
  74. Location struct {
  75. Lng float64 `json:"longitude,omitempty"` // 经度,单位 double
  76. Lat float64 `json:"latitude,omitempty"` // 纬度,单位 double
  77. Address string `json:"address,omitempty"` // 地址信息
  78. Title string `json:"title,omitempty"` // 位置信息的 title。
  79. Zoom uint32 `json:"zoom,omitempty"` // 缩放比例。
  80. } `json:"location,omitempty"`
  81. }
  82. // EmotionMessage 表情消息
  83. type EmotionMessage struct {
  84. BaseMessage
  85. Emotion struct {
  86. Type uint32 `json:"type,omitempty"` // 表情类型,png 或者 gif.1 表示 gif 2 表示 png。
  87. Width uint32 `json:"width,omitempty"` // 表情图片宽度。
  88. Height uint32 `json:"height,omitempty"` // 表情图片高度。
  89. ImageSize uint32 `json:"imagesize,omitempty"` // 资源的文件大小。
  90. SdkFileID string `json:"sdkfileid,omitempty"` // 媒体资源的 id 信息。
  91. Md5Sum string `json:"md5sum,omitempty"` // 图片资源的 md5 值,供进行校验。
  92. } `json:"emotion,omitempty"`
  93. }
  94. // FileMessage 文件消息
  95. type FileMessage struct {
  96. BaseMessage
  97. File struct {
  98. FileName string `json:"filename,omitempty"` // 文件名称。
  99. FileExt string `json:"fileext,omitempty"` // 文件类型后缀。
  100. SdkFileID string `json:"sdkfileid,omitempty"` // 媒体资源的 id 信息。
  101. FileSize uint32 `json:"filesize,omitempty"` // 文件大小。
  102. Md5Sum string `json:"md5sum,omitempty"` // 资源的 md5 值,供进行校验。
  103. } `json:"file,omitempty"`
  104. }
  105. // LinkMessage 链接消息
  106. type LinkMessage struct {
  107. BaseMessage
  108. Link struct {
  109. Title string `json:"title,omitempty"` // 消息标题。
  110. Desc string `json:"description,omitempty"` // 消息描述。
  111. LinkURL string `json:"link_url,omitempty"` // 链接 url 地址
  112. ImageURL string `json:"image_url,omitempty"` // 链接图片 url。
  113. } `json:"link,omitempty"`
  114. }
  115. // WeappMessage 小程序消息
  116. type WeappMessage struct {
  117. BaseMessage
  118. WeApp struct {
  119. Title string `json:"title,omitempty"` // 消息标题。
  120. Desc string `json:"description,omitempty"` // 消息描述。
  121. Username string `json:"username,omitempty"` // 用户名称。
  122. DisplayName string `json:"displayname,omitempty"` // 小程序名称
  123. } `json:"weapp,omitempty"`
  124. }
  125. // ChatRecordMessage 会话记录消息
  126. type ChatRecordMessage struct {
  127. BaseMessage
  128. ChatRecord struct {
  129. Title string `json:"title,omitempty"` // 聊天记录标题
  130. Item []ChatRecord `json:"item,omitempty"` // 消息记录内的消息内容,批量数据
  131. } `json:"chatrecord,omitempty"`
  132. }
  133. // TodoMessage 待办消息
  134. type TodoMessage struct {
  135. BaseMessage
  136. Todo struct {
  137. Title string `json:"title,omitempty"` // 代办的来源文本
  138. Content string `json:"content,omitempty"` // 代办的具体内容
  139. } `json:"todo,omitempty"`
  140. }
  141. // VoteMessage 投票消息
  142. type VoteMessage struct {
  143. BaseMessage
  144. VoteTitle string `json:"votetitle,omitempty"` // 投票主题。
  145. VoteItem []string `json:"voteitem,omitempty"` // 投票选项,可能多个内容。
  146. VoteType uint32 `json:"votetype,omitempty"` // 投票类型.101 发起投票、102 参与投票。
  147. VoteID string `json:"voteid,omitempty"` // 投票 id,方便将参与投票消息与发起投票消息进行前后对照。
  148. }
  149. // CollectMessage 填表消息
  150. type CollectMessage struct {
  151. BaseMessage
  152. Collect struct {
  153. RoomName string `json:"room_name,omitempty"` // 填表消息所在的群名称。
  154. Creator string `json:"creator,omitempty"` // 创建者在群中的名字
  155. CreateTime int64 `json:"create_time,omitempty"` // 创建的时间
  156. Details []CollectDetails `json:"details,omitempty"` // 表内容
  157. } `json:"collect,omitempty"`
  158. }
  159. // RedpacketMessage 红包消息
  160. type RedpacketMessage struct {
  161. BaseMessage
  162. RedPacket struct {
  163. Type uint32 `json:"type,omitempty"` // 红包消息类型。1 普通红包、2 拼手气群红包、3 激励群红包。
  164. Wish string `json:"wish,omitempty"` // 红包祝福语
  165. TotalCnt uint32 `json:"totalcnt,omitempty"` // 红包总个数
  166. TotalAmount uint32 `json:"totalamount,omitempty"` // 红包总金额。单位为分。
  167. } `json:"redpacket,omitempty"`
  168. }
  169. // MeetingMessage 会议邀请消息
  170. type MeetingMessage struct {
  171. BaseMessage
  172. Meeting struct {
  173. Topic string `json:"topic,omitempty"` // 会议主题
  174. StartTime int64 `json:"starttime,omitempty"` // 会议开始时间。Utc 时间
  175. EndTime int64 `json:"endtime,omitempty"` // 会议结束时间。Utc 时间
  176. Address string `json:"address,omitempty"` // 会议地址
  177. Remarks string `json:"remarks,omitempty"` // 会议备注
  178. MeetingType uint32 `json:"meetingtype,omitempty"` // 会议消息类型。101 发起会议邀请消息、102 处理会议邀请消息
  179. MeetingID uint64 `json:"meetingid,omitempty"` // 会议 id。方便将发起、处理消息进行对照
  180. Status uint32 `json:"status,omitempty"` // 会议邀请处理状态。1 参加会议、2 拒绝会议、3 待定、4 未被邀请、5 会议已取消、6 会议已过期、7 不在房间内。
  181. } `json:"meeting,omitempty"`
  182. }
  183. // DocMessage 在线文档消息
  184. type DocMessage struct {
  185. BaseMessage
  186. Doc struct {
  187. Title string `json:"title,omitempty"` // 在线文档名称
  188. LinkURL string `json:"link_url,omitempty"` // 在线文档链接
  189. DocCreator string `json:"doc_creator,omitempty"` // 在线文档创建者。本企业成员创建为 userid;外部企业成员创建为 external_userid
  190. } `json:"doc,omitempty"`
  191. }
  192. // MarkdownMessage MarkDown 消息
  193. type MarkdownMessage struct {
  194. BaseMessage
  195. Info struct {
  196. Content string `json:"content,omitempty"` // markdown 消息内容,目前为机器人发出的消息
  197. } `json:"info,omitempty"`
  198. }
  199. // NewsMessage 图文消息
  200. type NewsMessage struct {
  201. BaseMessage
  202. Info struct {
  203. Item []News `json:"item,omitempty"` // 图文消息数组
  204. } `json:"info,omitempty"` // 图文消息的内容
  205. }
  206. // CalendarMessage 日程消息
  207. type CalendarMessage struct {
  208. BaseMessage
  209. Calendar struct {
  210. Title string `json:"title,omitempty"` // 日程主题
  211. CreatorName string `json:"creatorname,omitempty"` // 日程组织者
  212. AttendeeName []string `json:"attendeename,omitempty"` // 日程参与人。数组,内容为 String 类型
  213. StartTime int64 `json:"starttime,omitempty"` // 日程开始时间。Utc 时间,单位秒
  214. EndTime int64 `json:"endtime,omitempty"` // 日程结束时间。Utc 时间,单位秒
  215. Place string `json:"place,omitempty"` // 日程地点
  216. Remarks string `json:"remarks,omitempty"` // 日程备注
  217. } `json:"calendar,omitempty"`
  218. }
  219. // MixedMessage 混合消息
  220. type MixedMessage struct {
  221. BaseMessage
  222. Mixed struct {
  223. Item []MixedMsg `json:"item,omitempty"`
  224. } `json:"mixed,omitempty"` // 消息内容。可包含图片、文字、表情等多种消息。Object 类型
  225. }
  226. // MeetingVoiceCallMessage 音频存档消息
  227. type MeetingVoiceCallMessage struct {
  228. BaseMessage
  229. VoiceID string `json:"voiceid,omitempty"` // 音频 id
  230. MeetingVoiceCall *MeetingVoiceCall `json:"meeting_voice_call,omitempty"` // 音频消息内容。包括结束时间、fileid,可能包括多个 demofiledata、sharescreendata 消息,demofiledata 表示文档共享信息,sharescreendata 表示屏幕共享信息。Object 类型
  231. }
  232. // VoipDocShareMessage 音频共享消息
  233. type VoipDocShareMessage struct {
  234. BaseMessage
  235. VoipID string `json:"voipid,omitempty"` // 音频 id
  236. VoipDocShare *VoipDocShare `json:"voip_doc_share,omitempty"` // 共享文档消息内容。包括 filename、md5sum、filesize、sdkfileid 字段。Object 类型
  237. }
  238. // ExternalRedPacketMessage 互通小红包消息
  239. type ExternalRedPacketMessage struct {
  240. BaseMessage
  241. RedPacket struct {
  242. Type uint32 `json:"type,omitempty"` // 红包消息类型。1 普通红包、2 拼手气群红包。Uint32 类型
  243. Wish string `json:"wish,omitempty"` // 红包祝福语。String 类型
  244. TotalCnt uint32 `json:"totalcnt,omitempty"` // 红包总个数。Uint32 类型
  245. TotalAmount uint32 `json:"totalamount,omitempty"` // 红包总金额。Uint32 类型,单位为分。
  246. } `json:"redpacket,omitempty"`
  247. }
  248. // SphFeedMessage 视频号消息
  249. type SphFeedMessage struct {
  250. BaseMessage
  251. SphFeed struct {
  252. FeedType uint32 `json:"feed_type,omitempty"` // 视频号消息类型。2 图片、4 视频、9 直播。Uint32 类型
  253. SphName string `json:"sph_name,omitempty"` // 视频号账号名称。String 类型
  254. FeedDesc string `json:"feed_desc,omitempty"` // 视频号消息描述。String 类型
  255. }
  256. }
  257. // SwitchMessage 企业切换日志
  258. type SwitchMessage struct {
  259. MsgID string `json:"msgid,omitempty"` // 消息 id,消息的唯一标识,企业可以使用此字段进行消息去重
  260. Action string `json:"action,omitempty"` // 消息动作,切换企业为 switch
  261. Time int64 `json:"time,omitempty"` // 消息发送时间戳,utc 时间,ms 单位。
  262. User string `json:"user,omitempty"` // 具体为切换企业的成员的 userid。
  263. }
  264. // ChatRecord 会话记录消息
  265. type ChatRecord struct {
  266. Type string `json:"type,omitempty"` // 每条聊天记录的具体消息类型:ChatRecordText/ ChatRecordFile/ ChatRecordImage/ ChatRecordVideo/ ChatRecordLink/ ChatRecordLocation/ ChatRecordMixed ….
  267. Content string `json:"content,omitempty"` // 消息内容。Json 串,内容为对应类型的 json
  268. MsgTime int64 `json:"msgtime,omitempty"` // 消息时间,utc 时间,ms 单位。
  269. FromChatroom bool `json:"from_chatroom,omitempty"` // 是否来自群会话。
  270. }
  271. // CollectDetails 填表消息
  272. type CollectDetails struct {
  273. ID uint64 `json:"id,omitempty"` // 表项 id
  274. Ques string `json:"ques,omitempty"` // 表项名称
  275. Type string `json:"type,omitempty"` // 表项类型,有 Text(文本),Number(数字),Date(日期),Time(时间)
  276. }
  277. // News 图文消息
  278. type News struct {
  279. Title string `json:"title,omitempty"` // 图文消息标题
  280. Desc string `json:"description,omitempty"` // 图文消息描述
  281. URL string `json:"url,omitempty"` // 图文消息点击跳转地址
  282. PicURL string `json:"picurl,omitempty"` // 图文消息配图的 url
  283. }
  284. // MixedMsg 混合消息
  285. type MixedMsg struct {
  286. Type string `json:"type,omitempty"`
  287. Content string `json:"content,omitempty"`
  288. }
  289. // MeetingVoiceCall 音频存档消息
  290. type MeetingVoiceCall struct {
  291. EndTime int64 `json:"endtime,omitempty"` // 音频结束时间
  292. SdkFileID string `json:"sdkfileid,omitempty"` // 音频媒体下载的 id
  293. DemoFileData []DemoFileData `json:"demofiledata,omitempty"` // 文档分享对象,Object 类型
  294. ShareScreenData []ShareScreenData `json:"sharescreendata,omitempty"` // 屏幕共享对象,Object 类型
  295. }
  296. // DemoFileData 文档共享消息
  297. type DemoFileData struct {
  298. FileName string `json:"filename,omitempty"` // 文档共享名称
  299. DemoOperator string `json:"demooperator,omitempty"` // 文档共享操作用户的 id
  300. StartTime int64 `json:"starttime,omitempty"` // 文档共享开始时间
  301. EndTime int64 `json:"endtime,omitempty"` // 文档共享结束时间
  302. }
  303. // ShareScreenData 屏幕共享信息
  304. type ShareScreenData struct {
  305. Share string `json:"share,omitempty"` // 屏幕共享用户的 id
  306. StartTime int64 `json:"starttime,omitempty"` // 屏幕共享开始时间
  307. EndTime int64 `json:"endtime,omitempty"` // 屏幕共享结束时间
  308. }
  309. // VoipDocShare 音频共享文档消息
  310. type VoipDocShare struct {
  311. FileName string `json:"filename,omitempty"` // 文档共享文件名称
  312. Md5Sum string `json:"md5sum,omitempty"` // 共享文件的 md5 值
  313. FileSize uint64 `json:"filesize,omitempty"` // 共享文件的大小
  314. SdkFileID string `json:"sdkfileid,omitempty"` // 共享文件的 sdkfile,通过此字段进行媒体数据下载
  315. }