From ce5439d4b2df325c3e7940a4802fd2bd55715f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 19 Jan 2022 09:42:50 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=8D=95=E8=81=8A=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/message.go | 13 +++++++++++++ api/param/request.go | 8 ++++++++ api/param/response.go | 9 +++++++++ common/api.go | 1 + 4 files changed, 31 insertions(+) create mode 100644 api/message.go diff --git a/api/message.go b/api/message.go new file mode 100644 index 0000000..8394bcb --- /dev/null +++ b/api/message.go @@ -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 +} diff --git a/api/param/request.go b/api/param/request.go index a8fb447..5d668d2 100644 --- a/api/param/request.go +++ b/api/param/request.go @@ -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"` // 消息内容 +} diff --git a/api/param/response.go b/api/param/response.go index e7d8ec2..2fbd0a0 100644 --- a/api/param/response.go +++ b/api/param/response.go @@ -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"` +} diff --git a/common/api.go b/common/api.go index 801ca2b..9d80259 100644 --- a/common/api.go +++ b/common/api.go @@ -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"} )