Compare commits

...

5 Commits

Author SHA1 Message Date
李寻欢 f5d0ab01cd 完善回调解析结构体 2022-10-18 15:48:57 +08:00
李寻欢 8d299c45a5 bug fix. 2022-01-19 10:20:10 +08:00
李寻欢 ce5439d4b2 新增发送单聊消息接口 2022-01-19 09:42:50 +08:00
李寻欢 f51fb38d0b 🎨 完善参数 2022-01-12 14:25:36 +08:00
李寻欢 6afb11d8a1 🐛 fix a bug. 2022-01-12 09:12:53 +08:00
7 changed files with 46 additions and 13 deletions

13
api/message.go Normal file
View File

@ -0,0 +1,13 @@
package api
import (
"gitee.ltd/lxh/txim/api/param"
"gitee.ltd/lxh/txim/common"
)
// SendMessageToUser 发送单聊消息给用户
func SendMessageToUser(p *param.PushMessageToUserReq) (*param.PushMessageToUserRes, error) {
a := param.PushMessageToUserRes{}
err := Api(common.SendMessageToUser, p, &a)
return &a, err
}

View File

@ -77,3 +77,11 @@ type PushOrdinaryMsgToGroupReq struct {
Random int `json:"Random"` // 随机数
MsgBody []callback.TIMMessage `json:"MsgBody"` // 消息内容
}
// PushMessageToUserReq 给用户发单聊消息参数
type PushMessageToUserReq struct {
FromAccount string `json:"From_Account"` // 发信人
ToAccount string `json:"To_Account"` // 收信人
Random int `json:"MsgRandom"` // 随机数
MsgBody []callback.TIMMessage `json:"MsgBody"` // 消息内容
}

View File

@ -54,3 +54,12 @@ type PushOrdinaryMsgToGroupRes struct {
MsgTime int `json:"MsgTime"` // 消息发送的时间戳,对应后台 server 时间
MsgSeq int `json:"MsgSeq"` // 消息序列号,唯一标示一条消息
}
// PushMessageToUserRes 给用户发单聊消息返回参数
type PushMessageToUserRes struct {
ActionStatus string `json:"ActionStatus"`
ErrorInfo string `json:"ErrorInfo"`
ErrorCode int `json:"ErrorCode"`
MsgTime int `json:"MsgTime"`
MsgKey string `json:"MsgKey"`
}

View File

@ -11,7 +11,11 @@ type MessageCallbackData struct {
MsgTime int `json:"MsgTime"` // 消息的发送时间戳,单位为秒
MsgKey string `json:"MsgKey"` //消息的唯一标识,可用于 REST API 撤回单聊消息
OnlineOnlyFlag int `json:"OnlineOnlyFlag"` //在线消息为1否则为0
CloudCustomData string `json:"CloudCustomData"` // 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到)
SendMsgResult int `json:"SendMsgResult"` // 消息发送之后独有
ErrorInfo string `json:"ErrorInfo"` // 消息发送之后独有
UnreadMsgNum int `json:"UnreadMsgNum"` // 消息发送之后独有
UnreadMsgNum int `json:"UnreadMsgNum"` // 消息发送之后、已读回调、撤回消息共有
ReportAccount string `json:"Report_Account"` // 已读回调独有
PeerAccount string `json:"Peer_Account"` // 已读回调独有
LastReadTime int `json:"LastReadTime"` // 已读回调独有
}

10
callback/response.go Normal file
View File

@ -0,0 +1,10 @@
package callback
// ToTxMessageResponse 返回给腾讯的应答数据 - 是否允许发送当前消息
type ToTxMessageResponse struct {
ActionStatus string `json:"ActionStatus"` // 请求处理的结果OK 表示处理成功FAIL 表示失败
ErrorInfo string `json:"ErrorInfo"` // 错误码0为允许发言1为拒绝发言。若业务希望拒绝发言的同时将错误码 ErrorCode 和 ErrorInfo 传递至客户端,请将错误码 ErrorCode 设置在 [120001, 130000] 区间内
ErrorCode int `json:"ErrorCode"` // 错误信息
MsgBody []TIMMessage `json:"MsgBody,omitempty"` // 经过 App 修改之后的消息体,即时通信 IM 后台将把修改后的消息发送给接收方
CloudCustomData string `json:"CloudCustomData,omitempty"` // 自定义数据
}

View File

@ -11,5 +11,6 @@ var (
AccountDelete Api = Api{"im_open_login_svc", "account_delete"}
GroupCreate Api = Api{"group_open_http_svc", "create_group"}
PushOrdinaryMsgToGroup Api = Api{"group_open_http_svc", "send_group_msg"} // 发送普通群消息
SendMessageToUser Api = Api{"openim", "sendmsg"} // 发送单聊消息
ProfileSet Api = Api{"profile", "portrait_set"}
)

View File

@ -1,12 +0,0 @@
package common
import "gitee.ltd/lxh/txim/callback"
// ToTxMessageResponse 返回给腾讯的应答数据 - 是否允许发送当前消息
type ToTxMessageResponse struct {
ActionStatus string `json:"ActionStatus"` // 请求处理的结果OK 表示处理成功FAIL 表示失败
ErrorInfo string `json:"ErrorInfo"` // 错误码0为允许发言1为拒绝发言。若业务希望拒绝发言的同时将错误码 ErrorCode 和 ErrorInfo 传递至客户端,请将错误码 ErrorCode 设置在 [120001, 130000] 区间内
ErrorCode int `json:"ErrorCode"` // 错误信息
MsgBody []callback.TIMMessage `json:"MsgBody,omitempty"` // 经过 App 修改之后的消息体,即时通信 IM 后台将把修改后的消息发送给接收方
CloudCustomData string `json:"CloudCustomData,omitempty"` // 自定义数据
}