Merge branch 'modify' of github.com:OpenIMSDK/Open-IM-Server into modify

# Conflicts:
#	pkg/proto/msg/msg.pb.go
pull/329/head
wangchuxiao 2 years ago
commit 112ce9b450

@ -69,7 +69,7 @@ func GetMessageListReactionExtensions(c *gin.Context) {
var (
req api.GetMessageListReactionExtensionsReq
resp api.GetMessageListReactionExtensionsResp
reqPb rpc.OperateMessageListReactionExtensionsReq
reqPb rpc.GetMessageListReactionExtensionsReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
@ -106,8 +106,7 @@ func GetMessageListReactionExtensions(c *gin.Context) {
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
resp.Data.FailedList = respPb.FailedList
resp.Data.SuccessList = respPb.SuccessList
resp.Data = respPb.SingleMessageResult
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}
@ -161,7 +160,7 @@ func DeleteMessageReactionExtensions(c *gin.Context) {
var (
req api.DeleteMessageReactionExtensionsReq
resp api.DeleteMessageReactionExtensionsResp
reqPb rpc.OperateMessageListReactionExtensionsReq
reqPb rpc.DeleteMessageListReactionExtensionsReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})

@ -95,7 +95,6 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, true)
} else {
ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false)
}
log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String())
return &rResp, nil
@ -110,61 +109,41 @@ func setKeyResultInfo(r *msg.SetMessageReactionExtensionsResp, errCode int32, er
_ = db.DB.UnLockMessageTypeKey(clientMsgID, typeKey)
}
func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *msg.OperateMessageListReactionExtensionsReq) (resp *msg.OperateMessageListReactionExtensionsResp, err error) {
//for _, messageValue := range req.MessageReactionKeyList {
// isExists, err := db.DB.JudgeMessageReactionEXISTS(messageValue.ClientMsgID,req.SessionType)
// if err != nil {
//
// }
// var failedList []*msg.ExtendMsgResp
// var successList []*msg.ExtendMsgResp
// var oneExtendMsg msg.ExtendMsg
// oneExtendMsg.ClientMsgID = req.ClientMsgID
// oneFailedReactionExtensionList:=make(map[string]*msg.KeyValueResp)
// oneSuccessReactionExtensionList:=make(map[string]*msg.KeyValueResp)
// if !isExists {
// if !req.IsReact {
// oneExtendMsg.MsgFirstModifyTime = utils.GetCurrentTimestampByMill()
// //redis处理
// for k, v := range req.ReactionExtensionList {
// //抢占分布式锁
// err:=lockMessageTypeKey(req.ClientMsgID,k)
// if err != nil {
// setKeyResultInfo(oneFailedReactionExtensionList,100,err.Error(),req.ClientMsgID,k,v)
// continue
// }
// redisValue,err:=db.DB.GetMessageTypeKeyValue(req.ClientMsgID,req.SessionType,k)
// if err != nil&&err!=go_redis.Nil {
// setKeyResultInfo(oneFailedReactionExtensionList,200,err.Error(),req.ClientMsgID,k,v)
// continue
// }
// temp:=new(server_api_params.KeyValue)
// utils.JsonStringToStruct(redisValue,temp)
// if v.LatestUpdateTime != temp.LatestUpdateTime {
// setKeyResultInfo(oneFailedReactionExtensionList,300,"message have update",req.ClientMsgID,k,temp)
// continue
// }else{
// v.LatestUpdateTime = utils.GetCurrentTimestampByMill()
// newerr:=db.DB.SetMessageTypeKeyValue(req.ClientMsgID,req.SessionType,k,utils.StructToJsonString(v))
// if newerr != nil {
// setKeyResultInfo(oneFailedReactionExtensionList,201,newerr.Error(),req.ClientMsgID,k,temp)
// continue
// }
// setKeyResultInfo(oneSuccessReactionExtensionList,0,"",req.ClientMsgID,k,v)
// }
//
// }
//
// }else{
// //mongo处理
// }
//
// }else{
//
// }
// return
//}
return
func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *msg.GetMessageListReactionExtensionsReq) (resp *msg.GetMessageListReactionExtensionsResp, err error) {
var rResp msg.GetMessageListReactionExtensionsResp
for _, messageValue := range req.MessageReactionKeyList {
var oneMessage msg.SingleMessageExtensionResult
oneMessage.ClientMsgID = messageValue.ClientMsgID
isExists, err := db.DB.JudgeMessageReactionEXISTS(messageValue.ClientMsgID, req.SessionType)
if err != nil {
rResp.ErrCode = 100
rResp.ErrMsg = err.Error()
return &rResp, nil
}
if isExists {
redisValue, err := db.DB.GetOneMessageAllReactionList(messageValue.ClientMsgID, req.SessionType)
if err != nil {
oneMessage.ErrCode = 100
oneMessage.ErrMsg = err.Error()
rResp.SingleMessageResult = append(rResp.SingleMessageResult, &oneMessage)
continue
}
keyMap := make(map[string]*server_api_params.KeyValue)
for k, v := range redisValue {
temp := new(server_api_params.KeyValue)
utils.JsonStringToStruct(v, temp)
keyMap[k] = temp
}
oneMessage.ReactionExtensionList = keyMap
} else {
}
rResp.SingleMessageResult = append(rResp.SingleMessageResult, &oneMessage)
}
return &rResp, nil
}
@ -172,7 +151,7 @@ func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.M
return
}
func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *msg.OperateMessageListReactionExtensionsReq) (resp *msg.OperateMessageListReactionExtensionsResp, err error) {
func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) {
return
}
func lockMessageTypeKey(clientMsgID, typeKey string) (err error) {

@ -76,10 +76,10 @@ type ModifyMessageReactionExtensionsResp struct {
}
type OperateMessageListReactionExtensionsReq struct {
OperationID string `json:"operationID" binding:"required"`
SourceID string `json:"sourceID" binding:"required"`
SessionType string `json:"sessionType" binding:"required"`
MessageReactionKeyList []*msg.OperateMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
SourceID string `json:"sourceID" binding:"required"`
SessionType string `json:"sessionType" binding:"required"`
MessageReactionKeyList []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"`
}
type OperateMessageListReactionExtensionsResp struct {
@ -96,7 +96,10 @@ type SetMessageReactionExtensionsCallbackResp ModifyMessageReactionExtensionsRes
type GetMessageListReactionExtensionsReq OperateMessageListReactionExtensionsReq
type GetMessageListReactionExtensionsResp OperateMessageListReactionExtensionsResp
type GetMessageListReactionExtensionsResp struct {
CommResp
Data []*msg.SingleMessageExtensionResult `json:"data"`
}
type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq

@ -447,6 +447,12 @@ func (d *DataBases) JudgeMessageReactionEXISTS(clientMsgID string, sessionType i
return false, err
}
}
func (d *DataBases) GetOneMessageAllReactionList(clientMsgID string, sessionType int32) (map[string]string, error) {
key := getMessageReactionExPrefix(clientMsgID, sessionType)
return d.RDB.HGetAll(context.Background(), key).Result()
}
func (d *DataBases) SetMessageReactionExpire(clientMsgID string, sessionType int32, expiration time.Duration) (bool, error) {
key := getMessageReactionExPrefix(clientMsgID, sessionType)
return d.RDB.Expire(context.Background(), key, expiration).Result()

File diff suppressed because it is too large Load Diff

@ -189,6 +189,32 @@ message SetMessageReactionExtensionsResp {
repeated KeyValueResp result = 6;
}
message GetMessageListReactionExtensionsReq {
string operationID = 1;
string opUserID = 2;
string sourceID = 3;
int32 sessionType = 4;
message MessageReactionKey {
string clientMsgID = 1;
int64 msgFirstModifyTime = 2;
}
repeated MessageReactionKey messageReactionKeyList = 5;
}
message GetMessageListReactionExtensionsResp{
int32 errCode = 1;
string errMsg = 2;
repeated SingleMessageExtensionResult singleMessageResult =3;
}
message SingleMessageExtensionResult {
int32 errCode = 1;
string errMsg = 2;
map <string, server_api_params.KeyValue>reactionExtensionList = 3;
string clientMsgID = 4;
}
message ModifyMessageReactionExtensionsResp {
int32 errCode = 1;
string errMsg = 2;
@ -196,7 +222,7 @@ message ModifyMessageReactionExtensionsResp {
repeated ExtendMsgResp failedList = 4;
}
message OperateMessageListReactionExtensionsReq {
message DeleteMessageListReactionExtensionsReq {
string operationID = 1;
string opUserID = 2;
string sourceID = 3;
@ -209,7 +235,7 @@ message OperateMessageListReactionExtensionsReq {
repeated MessageReactionKey messageReactionKeyList = 5;
}
message OperateMessageListReactionExtensionsResp {
message DeleteMessageListReactionExtensionsResp {
int32 errCode = 1;
string errMsg = 2;
repeated ExtendMsgResp successList = 3;
@ -258,7 +284,7 @@ service msg {
// modify msg
rpc SetMessageReactionExtensions(SetMessageReactionExtensionsReq) returns(SetMessageReactionExtensionsResp);
rpc GetMessageListReactionExtensions(OperateMessageListReactionExtensionsReq) returns(OperateMessageListReactionExtensionsResp);
rpc GetMessageListReactionExtensions(GetMessageListReactionExtensionsReq) returns(GetMessageListReactionExtensionsResp);
rpc AddMessageReactionExtensions(ModifyMessageReactionExtensionsReq) returns(ModifyMessageReactionExtensionsResp);
rpc DeleteMessageReactionExtensions(OperateMessageListReactionExtensionsReq) returns(OperateMessageListReactionExtensionsResp);
rpc DeleteMessageReactionExtensions(DeleteMessageListReactionExtensionsReq) returns(DeleteMessageListReactionExtensionsResp);
}

Loading…
Cancel
Save