mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 02:58:26 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
commit
0abb4a82b1
@ -128,7 +128,7 @@ func GetGroupByName(c *gin.Context) {
|
|||||||
func CreateGroup(c *gin.Context) {
|
func CreateGroup(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.CreateGroupRequest
|
req cms_api_struct.CreateGroupRequest
|
||||||
_ cms_api_struct.CreateGroupResponse
|
_ cms_api_struct.CreateGroupResponse
|
||||||
reqPb pbGroup.CreateGroupReq
|
reqPb pbGroup.CreateGroupReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
@ -253,9 +253,9 @@ func OpenPrivateChat(c *gin.Context) {
|
|||||||
|
|
||||||
func GetGroupMembers(c *gin.Context) {
|
func GetGroupMembers(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupMembersRequest
|
req cms_api_struct.GetGroupMembersRequest
|
||||||
reqPb pbGroup.GetGroupMembersCMSReq
|
reqPb pbGroup.GetGroupMembersCMSReq
|
||||||
resp cms_api_struct.GetGroupMembersResponse
|
resp cms_api_struct.GetGroupMembersResponse
|
||||||
)
|
)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
@ -286,21 +286,20 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
MemberPosition: int(groupMembers.RoleLevel),
|
MemberPosition: int(groupMembers.RoleLevel),
|
||||||
MemberNickName: groupMembers.Nickname,
|
MemberNickName: groupMembers.Nickname,
|
||||||
MemberId: groupMembers.UserID,
|
MemberId: groupMembers.UserID,
|
||||||
JoinTime: utils.UnixSecondToTime(groupMembers.JoinTime).String(),
|
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func AddGroupMembers(c *gin.Context) {
|
func AddGroupMembers(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.RemoveGroupMembersRequest
|
req cms_api_struct.RemoveGroupMembersRequest
|
||||||
resp cms_api_struct.RemoveGroupMembersResponse
|
resp cms_api_struct.RemoveGroupMembersResponse
|
||||||
reqPb pbGroup.AddGroupMembersCMSReq
|
reqPb pbGroup.AddGroupMembersCMSReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(),"BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationId, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -321,12 +320,12 @@ func AddGroupMembers(c *gin.Context) {
|
|||||||
|
|
||||||
func RemoveGroupMembers(c *gin.Context) {
|
func RemoveGroupMembers(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.RemoveGroupMembersRequest
|
req cms_api_struct.RemoveGroupMembersRequest
|
||||||
resp cms_api_struct.RemoveGroupMembersResponse
|
resp cms_api_struct.RemoveGroupMembersResponse
|
||||||
reqPb pbGroup.RemoveGroupMembersCMSReq
|
reqPb pbGroup.RemoveGroupMembersCMSReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(),"BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -347,12 +346,12 @@ func RemoveGroupMembers(c *gin.Context) {
|
|||||||
|
|
||||||
func DeleteGroup(c *gin.Context) {
|
func DeleteGroup(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.DeleteGroupRequest
|
req cms_api_struct.DeleteGroupRequest
|
||||||
_ cms_api_struct.DeleteGroupResponse
|
_ cms_api_struct.DeleteGroupResponse
|
||||||
reqPb pbGroup.DeleteGroupReq
|
reqPb pbGroup.DeleteGroupReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(),"BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -370,12 +369,12 @@ func DeleteGroup(c *gin.Context) {
|
|||||||
|
|
||||||
func SetGroupMaster(c *gin.Context) {
|
func SetGroupMaster(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.SetGroupMasterRequest
|
req cms_api_struct.SetGroupMasterRequest
|
||||||
_ cms_api_struct.SetGroupMasterResponse
|
_ cms_api_struct.SetGroupMasterResponse
|
||||||
reqPb pbGroup.OperateUserRoleReq
|
reqPb pbGroup.OperateUserRoleReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(),"BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -395,8 +394,8 @@ func SetGroupMaster(c *gin.Context) {
|
|||||||
|
|
||||||
func SetGroupOrdinaryUsers(c *gin.Context) {
|
func SetGroupOrdinaryUsers(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.SetGroupMemberRequest
|
req cms_api_struct.SetGroupMemberRequest
|
||||||
_ cms_api_struct.AdminLoginResponse
|
_ cms_api_struct.AdminLoginResponse
|
||||||
reqPb pbGroup.OperateUserRoleReq
|
reqPb pbGroup.OperateUserRoleReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
@ -420,8 +419,8 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
|
|||||||
|
|
||||||
func AlterGroupInfo(c *gin.Context) {
|
func AlterGroupInfo(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.AlterGroupInfoRequest
|
req cms_api_struct.AlterGroupInfoRequest
|
||||||
_ cms_api_struct.SetGroupMasterResponse
|
_ cms_api_struct.SetGroupMasterResponse
|
||||||
reqPb pbGroup.SetGroupInfoReq
|
reqPb pbGroup.SetGroupInfoReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
@ -431,12 +430,12 @@ func AlterGroupInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
reqPb.OpUserID = c.MustGet("userID").(string)
|
reqPb.OpUserID = c.MustGet("userID").(string)
|
||||||
reqPb.GroupInfo = &commonPb.GroupInfo{
|
reqPb.GroupInfo = &commonPb.GroupInfo{
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
GroupName: req.GroupName,
|
GroupName: req.GroupName,
|
||||||
Introduction: req.Introduction,
|
Introduction: req.Introduction,
|
||||||
Notification: req.Notification,
|
Notification: req.Notification,
|
||||||
FaceURL: req.ProfilePhoto,
|
FaceURL: req.ProfilePhoto,
|
||||||
GroupType: int32(req.GroupType),
|
GroupType: int32(req.GroupType),
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
|
@ -52,6 +52,8 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
|||||||
ws.getSeqReq(conn, &m)
|
ws.getSeqReq(conn, &m)
|
||||||
case constant.WSSendMsg:
|
case constant.WSSendMsg:
|
||||||
ws.sendMsgReq(conn, &m)
|
ws.sendMsgReq(conn, &m)
|
||||||
|
case constant.WSSendSignalMsg:
|
||||||
|
ws.sendSignalMsgReq(conn, &m)
|
||||||
case constant.WSPullMsgBySeqList:
|
case constant.WSPullMsgBySeqList:
|
||||||
ws.pullMsgBySeqListReq(conn, &m)
|
ws.pullMsgBySeqListReq(conn, &m)
|
||||||
default:
|
default:
|
||||||
@ -193,6 +195,57 @@ func (ws *WServer) sendMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
|||||||
ws.sendMsg(conn, mReply)
|
ws.sendMsg(conn, mReply)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ws *WServer) sendSignalMsgReq(conn *UserConn, m *Req) {
|
||||||
|
sendMsgCount++
|
||||||
|
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID)
|
||||||
|
nReply := new(pbChat.SendMsgResp)
|
||||||
|
isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg)
|
||||||
|
if isPass {
|
||||||
|
data := pData.(sdk_ws.MsgData)
|
||||||
|
pbData := pbChat.SendMsgReq{
|
||||||
|
Token: m.Token,
|
||||||
|
OperationID: m.OperationID,
|
||||||
|
MsgData: &data,
|
||||||
|
}
|
||||||
|
log.NewInfo(m.OperationID, "Ws call success to sendSignalMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, data)
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
|
client := pbChat.NewChatClient(etcdConn)
|
||||||
|
reply, err := client.SendMsg(context.Background(), &pbData)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(pbData.OperationID, "rpc sendMsg err", err.Error())
|
||||||
|
nReply.ErrCode = 200
|
||||||
|
nReply.ErrMsg = err.Error()
|
||||||
|
ws.sendSignalMsgResp(conn, m, nReply)
|
||||||
|
} else {
|
||||||
|
log.NewInfo(pbData.OperationID, "rpc call success to sendMsgReq", reply.String())
|
||||||
|
ws.sendSignalMsgResp(conn, m, reply)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
nReply.ErrCode = errCode
|
||||||
|
nReply.ErrMsg = errMsg
|
||||||
|
ws.sendSignalMsgResp(conn, m, nReply)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
func (ws *WServer) sendSignalMsgResp(conn *UserConn, m *Req, pb *pbChat.SendMsgResp) {
|
||||||
|
// := make(map[string]interface{})
|
||||||
|
|
||||||
|
var mReplyData sdk_ws.UserSendMsgResp
|
||||||
|
mReplyData.ClientMsgID = pb.GetClientMsgID()
|
||||||
|
mReplyData.ServerMsgID = pb.GetServerMsgID()
|
||||||
|
mReplyData.SendTime = pb.GetSendTime()
|
||||||
|
b, _ := proto.Marshal(&mReplyData)
|
||||||
|
mReply := Resp{
|
||||||
|
ReqIdentifier: m.ReqIdentifier,
|
||||||
|
MsgIncr: m.MsgIncr,
|
||||||
|
ErrCode: pb.GetErrCode(),
|
||||||
|
ErrMsg: pb.GetErrMsg(),
|
||||||
|
OperationID: m.OperationID,
|
||||||
|
Data: b,
|
||||||
|
}
|
||||||
|
ws.sendMsg(conn, mReply)
|
||||||
|
}
|
||||||
func (ws *WServer) sendMsg(conn *UserConn, mReply interface{}) {
|
func (ws *WServer) sendMsg(conn *UserConn, mReply interface{}) {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
enc := gob.NewEncoder(&b)
|
enc := gob.NewEncoder(&b)
|
||||||
|
@ -58,7 +58,7 @@ type SeqListData struct {
|
|||||||
|
|
||||||
func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
|
func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
|
||||||
switch r {
|
switch r {
|
||||||
case constant.WSSendMsg:
|
case constant.WSSendMsg | constant.WSSendSignalMsg:
|
||||||
data := open_im_sdk.MsgData{}
|
data := open_im_sdk.MsgData{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||||
|
@ -395,7 +395,7 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
|||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
utils.CopyStructFields(&memberNode, memberInfo)
|
utils.CopyStructFields(&memberNode, memberInfo)
|
||||||
memberNode.JoinTime = memberInfo.JoinTime.Unix()
|
memberNode.JoinTime = int32(memberInfo.JoinTime.Unix())
|
||||||
resp.MemberList = append(resp.MemberList, &memberNode)
|
resp.MemberList = append(resp.MemberList, &memberNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -827,7 +827,7 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
|
|||||||
GroupID: req.GroupId,
|
GroupID: req.GroupId,
|
||||||
UserID: groupMember.UserID,
|
UserID: groupMember.UserID,
|
||||||
RoleLevel: groupMember.RoleLevel,
|
RoleLevel: groupMember.RoleLevel,
|
||||||
JoinTime: groupMember.JoinTime.Unix(),
|
JoinTime: int32(groupMember.JoinTime.Unix()),
|
||||||
Nickname: groupMember.Nickname,
|
Nickname: groupMember.Nickname,
|
||||||
FaceURL: groupMember.FaceURL,
|
FaceURL: groupMember.FaceURL,
|
||||||
JoinSource: groupMember.JoinSource,
|
JoinSource: groupMember.JoinSource,
|
||||||
|
@ -20,8 +20,10 @@ const (
|
|||||||
WSGetNewestSeq = 1001
|
WSGetNewestSeq = 1001
|
||||||
WSPullMsgBySeqList = 1002
|
WSPullMsgBySeqList = 1002
|
||||||
WSSendMsg = 1003
|
WSSendMsg = 1003
|
||||||
|
WSSendSignalMsg = 1004
|
||||||
WSPushMsg = 2001
|
WSPushMsg = 2001
|
||||||
WSKickOnlineMsg = 2002
|
WSKickOnlineMsg = 2002
|
||||||
|
WsLogoutMsg = 2003
|
||||||
WSDataError = 3001
|
WSDataError = 3001
|
||||||
|
|
||||||
///ContentType
|
///ContentType
|
||||||
@ -139,16 +141,16 @@ const (
|
|||||||
|
|
||||||
//callbackCommand
|
//callbackCommand
|
||||||
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
||||||
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
||||||
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
||||||
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
||||||
CallbackWordFilterCommand = "callbackWordFilterCommand"
|
CallbackWordFilterCommand = "callbackWordFilterCommand"
|
||||||
//callback actionCode
|
//callback actionCode
|
||||||
ActionAllow = 0
|
ActionAllow = 0
|
||||||
ActionForbidden = 1
|
ActionForbidden = 1
|
||||||
//callback callbackHandleCode
|
//callback callbackHandleCode
|
||||||
CallbackHandleSuccess = 0
|
CallbackHandleSuccess = 0
|
||||||
CallbackHandleFailed = 1
|
CallbackHandleFailed = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
var ContentType2PushContent = map[int64]string{
|
var ContentType2PushContent = map[int64]string{
|
||||||
|
@ -117,7 +117,7 @@ func GroupMemberDBCopyOpenIM(dst *open_im_sdk.GroupMemberFullInfo, src *db.Group
|
|||||||
|
|
||||||
dst.AppMangerLevel = 1
|
dst.AppMangerLevel = 1
|
||||||
}
|
}
|
||||||
dst.JoinTime = src.JoinTime.Unix()
|
dst.JoinTime = int32(src.JoinTime.Unix())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user