Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
李寻欢 | f5d0ab01cd | |
李寻欢 | 8d299c45a5 | |
李寻欢 | ce5439d4b2 | |
李寻欢 | f51fb38d0b | |
李寻欢 | 6afb11d8a1 | |
李寻欢 | 28dee5fee8 | |
李寻欢 | cbc07e4ec5 | |
李寻欢 | c9b00d6a7b |
|
@ -12,3 +12,10 @@ func GroupCreate(r *param.GroupCreateReq) (*param.GroupCreateRes, error) {
|
|||
err := Api(common.GroupCreate, r, &a)
|
||||
return &a, err
|
||||
}
|
||||
|
||||
// PushOrdinaryMsgToGroup 发送普通群消息
|
||||
func PushOrdinaryMsgToGroup(p *param.PushOrdinaryMsgToGroupReq) (*param.PushOrdinaryMsgToGroupRes, error) {
|
||||
a := param.PushOrdinaryMsgToGroupRes{}
|
||||
err := Api(common.PushOrdinaryMsgToGroup, p, &a)
|
||||
return &a, err
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package param
|
||||
|
||||
import "gitee.ltd/lxh/txim/common"
|
||||
import (
|
||||
"gitee.ltd/lxh/txim/callback"
|
||||
"gitee.ltd/lxh/txim/common"
|
||||
)
|
||||
|
||||
// AccountImportReq 单个账号导入
|
||||
type AccountImportReq struct {
|
||||
|
@ -64,3 +67,21 @@ type ProfileSetReqItem struct {
|
|||
Tag string `json:"Tag"`
|
||||
Value interface{} `json:"Value"`
|
||||
}
|
||||
|
||||
// ========================================================
|
||||
|
||||
// PushOrdinaryMsgToGroupReq 发送普通群聊普通消息参数
|
||||
type PushOrdinaryMsgToGroupReq struct {
|
||||
GroupId string `json:"GroupId"` // 群组Id
|
||||
FromAccount string `json:"From_Account"` // 发信人
|
||||
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"` // 消息内容
|
||||
}
|
||||
|
|
|
@ -43,3 +43,23 @@ type GroupCreateRes struct {
|
|||
|
||||
// ProfileSetRes 资料设置返回
|
||||
type ProfileSetRes struct{}
|
||||
|
||||
// ===============================================================
|
||||
|
||||
// PushOrdinaryMsgToGroupRes 发送普通群聊普通消息返回参数
|
||||
type PushOrdinaryMsgToGroupRes struct {
|
||||
ActionStatus string `json:"ActionStatus"` // 请求处理的结果,OK 表示处理成功,FAIL 表示失败
|
||||
ErrorInfo string `json:"ErrorInfo"` // 错误信息
|
||||
ErrorCode int `json:"ErrorCode"` // 错误码,0表示成功,非0表示失败
|
||||
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"`
|
||||
}
|
||||
|
|
|
@ -4,50 +4,50 @@ package callback
|
|||
|
||||
// TIMMessage 消息体
|
||||
type TIMMessage struct {
|
||||
MsgType string `json:"MsgType"` // 消息元素类别;目前支持的消息对象包括:TIMTextElem(文本消息),TIMLocationElem(位置消息),TIMFaceElem(表情消息),TIMCustomElem(自定义消息),TIMSoundElem(语音消息),TIMImageElem(图像消息),TIMFileElem(文件消息),TIMVideoFileElem(视频消息)
|
||||
MsgContent TIMMessageContent `json:"MsgContent"` // 消息元素的内容,不同的 MsgType 有不同的 MsgContent 格式
|
||||
MsgType string `json:"MsgType,omitempty"` // 消息元素类别;目前支持的消息对象包括:TIMTextElem(文本消息),TIMLocationElem(位置消息),TIMFaceElem(表情消息),TIMCustomElem(自定义消息),TIMSoundElem(语音消息),TIMImageElem(图像消息),TIMFileElem(文件消息),TIMVideoFileElem(视频消息)
|
||||
MsgContent TIMMessageContent `json:"MsgContent,omitempty"` // 消息元素的内容,不同的 MsgType 有不同的 MsgContent 格式
|
||||
}
|
||||
|
||||
// TIMMessageContent 消息结构体
|
||||
// https://cloud.tencent.com/document/product/269/2720
|
||||
type TIMMessageContent struct {
|
||||
Text string `json:"Text"` // [TIMTextElem]消息内容
|
||||
Desc string `json:"Desc"` // [TIMLocationElem]地理位置描述信息。 | [TIMCustomElem]自定义消息描述信息。
|
||||
Latitude float64 `json:"Latitude"` // [TIMLocationElem]纬度
|
||||
Longitude float64 `json:"Longitude"` // [TIMLocationElem]经度
|
||||
Index int `json:"Index"` // [TIMFaceElem]表情索引,用户自定义
|
||||
Data string `json:"Data"` // [TIMFaceElem]额外数据 | [TIMCustomElem]自定义消息数据。
|
||||
Ext string `json:"Ext"` // [TIMCustomElem]扩展字段
|
||||
Sound string `json:"Sound"` // [TIMCustomElem]自定义 APNs 推送铃音
|
||||
URL string `json:"Url"` // [TIMSoundElem]语音下载地址,可通过该 URL 地址直接下载相应语音 | [TIMFileElem]文件下载标记
|
||||
UUID string `json:"UUID"` // [TIMSoundElem]语音的唯一标识,客户端用于索引语音的键值 | [TIMImageElem]图片的唯一标识 | [TIMFileElem]文件的唯一标识
|
||||
Size int `json:"Size"` // [TIMSoundElem]语音数据大小,单位:字节。
|
||||
Second int `json:"Second"` // [TIMSoundElem]语音时长,单位:秒。
|
||||
DownloadFlag int `json:"Download_Flag"` // [TIMSoundElem]语音下载方式标记。目前 Download_Flag 取值只能为2,表示可通过Url字段值的 URL 地址直接下载语音。 | [TIMFileElem]文件下载方式标记
|
||||
ImageFormat int `json:"ImageFormat"` // [TIMImageElem]图片格式。JPG = 1,GIF = 2,PNG = 3,BMP = 4,其他 = 255
|
||||
ImageInfoArray []TIMMessageImageInfoArray `json:"ImageInfoArray"` // [TIMImageElem]原图、缩略图或者大图下载信息
|
||||
FileSize int `json:"FileSize"` // [TIMFileElem]文件数据大小,单位:字节
|
||||
FileName string `json:"FileName"` // [TIMFileElem]文件名称
|
||||
VideoURL string `json:"VideoUrl"` // [TIMVideoFileElem]视频下载地址。可通过该 URL 地址直接下载相应视频
|
||||
VideoUUID string `json:"VideoUUID"` // [TIMVideoFileElem]视频的唯一标识,客户端用于索引视频的键值
|
||||
VideoSize int `json:"VideoSize"` // [TIMVideoFileElem]视频数据大小,单位:字节
|
||||
VideoSecond int `json:"VideoSecond"` // [TIMVideoFileElem]视频时长,单位:秒
|
||||
VideoFormat string `json:"VideoFormat"` // [TIMVideoFileElem]视频格式,例如 mp4
|
||||
VideoDownloadFlag int `json:"VideoDownloadFlag"` // [TIMVideoFileElem]视频下载方式标记。目前 VideoDownloadFlag 取值只能为2,表示可通过VideoUrl字段值的 URL 地址直接下载视频
|
||||
ThumbURL string `json:"ThumbUrl"` // [TIMVideoFileElem]视频缩略图下载地址。可通过该 URL 地址直接下载相应视频缩略图
|
||||
ThumbUUID string `json:"ThumbUUID"` // [TIMVideoFileElem]视频缩略图的唯一标识,客户端用于索引视频缩略图的键值
|
||||
ThumbSize int `json:"ThumbSize"` // [TIMVideoFileElem]缩略图大小,单位:字节
|
||||
ThumbWidth int `json:"ThumbWidth"` // [TIMVideoFileElem]缩略图宽度,单位为像素
|
||||
ThumbHeight int `json:"ThumbHeight"` // [TIMVideoFileElem]缩略图高度,单位为像素
|
||||
ThumbFormat string `json:"ThumbFormat"` // [TIMVideoFileElem]缩略图格式,例如 JPG、BMP 等
|
||||
ThumbDownloadFlag int `json:"ThumbDownloadFlag"` // [TIMVideoFileElem]视频缩略图下载方式标记。目前 ThumbDownloadFlag 取值只能为2,表示可通过ThumbUrl字段值的 URL 地址直接下载视频缩略图
|
||||
Text string `json:"Text,omitempty"` // [TIMTextElem]消息内容
|
||||
Desc string `json:"Desc,omitempty"` // [TIMLocationElem]地理位置描述信息。 | [TIMCustomElem]自定义消息描述信息。
|
||||
Latitude float64 `json:"Latitude,omitempty"` // [TIMLocationElem]纬度
|
||||
Longitude float64 `json:"Longitude,omitempty"` // [TIMLocationElem]经度
|
||||
Index int `json:"Index,omitempty"` // [TIMFaceElem]表情索引,用户自定义
|
||||
Data string `json:"Data,omitempty"` // [TIMFaceElem]额外数据 | [TIMCustomElem]自定义消息数据。
|
||||
Ext string `json:"Ext,omitempty"` // [TIMCustomElem]扩展字段
|
||||
Sound string `json:"Sound,omitempty"` // [TIMCustomElem]自定义 APNs 推送铃音
|
||||
URL string `json:"Url,omitempty"` // [TIMSoundElem]语音下载地址,可通过该 URL 地址直接下载相应语音 | [TIMFileElem]文件下载标记
|
||||
UUID string `json:"UUID,omitempty"` // [TIMSoundElem]语音的唯一标识,客户端用于索引语音的键值 | [TIMImageElem]图片的唯一标识 | [TIMFileElem]文件的唯一标识
|
||||
Size int `json:"Size,omitempty"` // [TIMSoundElem]语音数据大小,单位:字节。
|
||||
Second int `json:"Second,omitempty"` // [TIMSoundElem]语音时长,单位:秒。
|
||||
DownloadFlag int `json:"Download_Flag,omitempty"` // [TIMSoundElem]语音下载方式标记。目前 Download_Flag 取值只能为2,表示可通过Url字段值的 URL 地址直接下载语音。 | [TIMFileElem]文件下载方式标记
|
||||
ImageFormat int `json:"ImageFormat,omitempty"` // [TIMImageElem]图片格式。JPG = 1,GIF = 2,PNG = 3,BMP = 4,其他 = 255
|
||||
ImageInfoArray []TIMMessageImageInfoArray `json:"ImageInfoArray,omitempty"` // [TIMImageElem]原图、缩略图或者大图下载信息
|
||||
FileSize int `json:"FileSize,omitempty"` // [TIMFileElem]文件数据大小,单位:字节
|
||||
FileName string `json:"FileName,omitempty"` // [TIMFileElem]文件名称
|
||||
VideoURL string `json:"VideoUrl,omitempty"` // [TIMVideoFileElem]视频下载地址。可通过该 URL 地址直接下载相应视频
|
||||
VideoUUID string `json:"VideoUUID,omitempty"` // [TIMVideoFileElem]视频的唯一标识,客户端用于索引视频的键值
|
||||
VideoSize int `json:"VideoSize,omitempty"` // [TIMVideoFileElem]视频数据大小,单位:字节
|
||||
VideoSecond int `json:"VideoSecond,omitempty"` // [TIMVideoFileElem]视频时长,单位:秒
|
||||
VideoFormat string `json:"VideoFormat,omitempty"` // [TIMVideoFileElem]视频格式,例如 mp4
|
||||
VideoDownloadFlag int `json:"VideoDownloadFlag,omitempty"` // [TIMVideoFileElem]视频下载方式标记。目前 VideoDownloadFlag 取值只能为2,表示可通过VideoUrl字段值的 URL 地址直接下载视频
|
||||
ThumbURL string `json:"ThumbUrl,omitempty"` // [TIMVideoFileElem]视频缩略图下载地址。可通过该 URL 地址直接下载相应视频缩略图
|
||||
ThumbUUID string `json:"ThumbUUID,omitempty"` // [TIMVideoFileElem]视频缩略图的唯一标识,客户端用于索引视频缩略图的键值
|
||||
ThumbSize int `json:"ThumbSize,omitempty"` // [TIMVideoFileElem]缩略图大小,单位:字节
|
||||
ThumbWidth int `json:"ThumbWidth,omitempty"` // [TIMVideoFileElem]缩略图宽度,单位为像素
|
||||
ThumbHeight int `json:"ThumbHeight,omitempty"` // [TIMVideoFileElem]缩略图高度,单位为像素
|
||||
ThumbFormat string `json:"ThumbFormat,omitempty"` // [TIMVideoFileElem]缩略图格式,例如 JPG、BMP 等
|
||||
ThumbDownloadFlag int `json:"ThumbDownloadFlag,omitempty"` // [TIMVideoFileElem]视频缩略图下载方式标记。目前 ThumbDownloadFlag 取值只能为2,表示可通过ThumbUrl字段值的 URL 地址直接下载视频缩略图
|
||||
}
|
||||
|
||||
// TIMMessageImageInfoArray 图片消息数组
|
||||
type TIMMessageImageInfoArray struct {
|
||||
Type int `json:"Type"` // 图片类型: 1-原图,2-大图,3-缩略图
|
||||
Size int `json:"Size"` // 图片数据大小,单位:字节
|
||||
Width int `json:"Width"` // 图片宽度,单位为像素
|
||||
Height int `json:"Height"` // 图片高度,单位为像素
|
||||
URL string `json:"URL"` // 图片下载地址
|
||||
Type int `json:"Type,omitempty"` // 图片类型: 1-原图,2-大图,3-缩略图
|
||||
Size int `json:"Size,omitempty"` // 图片数据大小,单位:字节
|
||||
Width int `json:"Width,omitempty"` // 图片宽度,单位为像素
|
||||
Height int `json:"Height,omitempty"` // 图片高度,单位为像素
|
||||
URL string `json:"URL,omitempty"` // 图片下载地址
|
||||
}
|
||||
|
|
|
@ -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"` // 已读回调独有
|
||||
}
|
||||
|
|
|
@ -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"` // 自定义数据
|
||||
}
|
|
@ -6,9 +6,11 @@ type Api struct {
|
|||
}
|
||||
|
||||
var (
|
||||
AccountImport Api = Api{"im_open_login_svc", "account_import"}
|
||||
AccountCheck Api = Api{"im_open_login_svc", "account_check"}
|
||||
AccountDelete Api = Api{"im_open_login_svc", "account_delete"}
|
||||
GroupCreate Api = Api{"group_open_http_svc", "create_group"}
|
||||
ProfileSet Api = Api{"profile", "portrait_set"}
|
||||
AccountImport Api = Api{"im_open_login_svc", "account_import"}
|
||||
AccountCheck Api = Api{"im_open_login_svc", "account_check"}
|
||||
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"}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue