Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release

This commit is contained in:
wenxu12345
2022-07-29 15:48:00 +08:00
30 changed files with 713 additions and 373 deletions
+16 -14
View File
@@ -29,10 +29,10 @@ import (
var validate *validator.Validate
func SetOptions(options map[string]bool, value bool) {
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, value)
utils.SetSwitchFromOptions(options, constant.IsHistory, value)
utils.SetSwitchFromOptions(options, constant.IsPersistent, value)
utils.SetSwitchFromOptions(options, constant.IsSenderSync, value)
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, value)
}
func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
@@ -59,10 +59,12 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
if params.IsOnlineOnly {
SetOptions(options, false)
}
if params.ContentType == constant.CustomMsgOnlineOnly {
SetOptions(options, false)
} else if params.ContentType == constant.CustomMsgNotTriggerConversation {
if params.NotOfflinePush {
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
}
if params.ContentType == constant.CustomOnlineOnly {
SetOptions(options, false)
} else if params.ContentType == constant.CustomNotTriggerConversation {
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
}
@@ -146,9 +148,9 @@ func ManagementSendMsg(c *gin.Context) {
case constant.OANotification:
data = OANotificationElem{}
params.SessionType = constant.NotificationChatType
case constant.CustomMsgNotTriggerConversation:
case constant.CustomNotTriggerConversation:
data = CustomElem{}
case constant.CustomMsgOnlineOnly:
case constant.CustomOnlineOnly:
data = CustomElem{}
//case constant.HasReadReceipt:
//case constant.Typing:
@@ -277,9 +279,9 @@ func ManagementBatchSendMsg(c *gin.Context) {
case constant.OANotification:
data = OANotificationElem{}
params.SessionType = constant.NotificationChatType
case constant.CustomMsgNotTriggerConversation:
case constant.CustomNotTriggerConversation:
data = CustomElem{}
case constant.CustomMsgOnlineOnly:
case constant.CustomOnlineOnly:
data = CustomElem{}
//case constant.HasReadReceipt:
//case constant.Typing:
@@ -322,12 +324,11 @@ func ManagementBatchSendMsg(c *gin.Context) {
return
}
client := pbChat.NewMsgClient(etcdConn)
req := &api.ManagementSendMsgReq{
ManagementSendMsg: params.ManagementSendMsg,
}
pbData := newUserSendMsgReq(req)
for _, recvID := range params.RecvIDList {
req := &api.ManagementSendMsgReq{
ManagementSendMsg: params.ManagementSendMsg,
RecvID: recvID,
}
pbData := newUserSendMsgReq(req)
pbData.MsgData.RecvID = recvID
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
@@ -344,10 +345,11 @@ func ManagementBatchSendMsg(c *gin.Context) {
msgSendFailedFlag = true
continue
}
resp.Data.ResultList = append(resp.Data.ResultList, server_api_params.UserSendMsgResp{
resp.Data.ResultList = append(resp.Data.ResultList, &api.SingleReturnResult{
ServerMsgID: rpcResp.ServerMsgID,
ClientMsgID: rpcResp.ClientMsgID,
SendTime: rpcResp.SendTime,
RecvID: recvID,
})
}
if msgSendFailedFlag {
+31 -14
View File
@@ -78,15 +78,18 @@ func DelSuperGroupMsg(c *gin.Context) {
req api.DelSuperGroupMsgReq
resp api.DelSuperGroupMsgResp
)
rpcReq := &rpc.DelSuperGroupMsgReq{}
utils.CopyStructFields(req, &req)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
var ok bool
var errInfo string
ok, rpcReq.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + opUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
errMsg := req.OperationID + " " + rpcReq.OpUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
@@ -137,18 +140,32 @@ func DelSuperGroupMsg(c *gin.Context) {
client := rpc.NewMsgClient(etcdConn)
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
RpcResp, err := client.SendMsg(context.Background(), &pbData)
if err != nil {
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
return
if req.IsAllDelete {
RpcResp, err := client.DelSuperGroupMsg(context.Background(),rpcReq)
if err != nil {
log.NewError(req.OperationID, "call delete DelSuperGroupMsg rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call DelSuperGroupMsg rpc server failed"})
return
}
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
resp.ErrCode = RpcResp.ErrCode
resp.ErrMsg = RpcResp.ErrMsg
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}else{
RpcResp, err := client.SendMsg(context.Background(), &pbData)
if err != nil {
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
return
}
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
resp.ErrCode = RpcResp.ErrCode
resp.ErrMsg = RpcResp.ErrMsg
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
resp.ErrCode = RpcResp.ErrCode
resp.ErrMsg = RpcResp.ErrMsg
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}
// @Summary 清空用户消息
@@ -160,6 +160,7 @@ func MinioStorageCredential(c *gin.Context) {
resp.AccessKeyID = v.AccessKeyID
resp.BucketName = config.Config.Credential.Minio.Bucket
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
resp.StorageTime = config.Config.Credential.Minio.StorageTime
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
}