新增发送单聊消息接口

This commit is contained in:
李寻欢 2022-01-19 09:42:50 +08:00
parent f51fb38d0b
commit ce5439d4b2
4 changed files with 31 additions and 0 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:"Random"` // 随机数
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,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"}
)