From 85e3a81419e1a59a738ceb5a7b6614d78c308088 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 11 Jan 2023 14:33:33 +0800 Subject: [PATCH 1/8] super group remove unread message --- internal/rpc/group/group.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index fbc2dd188..4bb686364 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -743,6 +743,27 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou resp.ErrMsg = constant.ErrDB.ErrMsg return &resp, nil } + reqPb := pbConversation.ModifyConversationFieldReq{Conversation: &pbConversation.Conversation{}} + reqPb.OperationID = req.OperationID + reqPb.UserIDList = okUserIDList + reqPb.FieldType = constant.FieldUnread + reqPb.Conversation.GroupID = req.GroupID + reqPb.Conversation.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.SuperGroupChatType) + reqPb.Conversation.ConversationType = int32(constant.SuperGroupChatType) + reqPb.Conversation.UpdateUnreadCountTime = utils.GetCurrentTimestampByMill() + etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID) + if etcdConn == nil { + errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil" + log.NewError(req.OperationID, errMsg) + } + client := pbConversation.NewConversationClient(etcdConn) + respPb, err := client.ModifyConversationField(context.Background(), &reqPb) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "ModifyConversationField rpc failed, ", reqPb.String(), err.Error()) + } else { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "ModifyConversationField success", respPb.String()) + } + } if groupInfo.GroupType != constant.SuperGroup { From 08ed131e19ef7994502f1493834460a517e8f846 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 11 Jan 2023 16:00:38 +0800 Subject: [PATCH 2/8] sendKickMsg add operationID --- internal/msg_gateway/gate/relay_rpc_server.go | 2 +- internal/msg_gateway/gate/ws_server.go | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/internal/msg_gateway/gate/relay_rpc_server.go b/internal/msg_gateway/gate/relay_rpc_server.go index 47889ad25..89a63a293 100644 --- a/internal/msg_gateway/gate/relay_rpc_server.go +++ b/internal/msg_gateway/gate/relay_rpc_server.go @@ -376,7 +376,7 @@ func (r *RPCServer) KickUserOffline(_ context.Context, req *pbRelay.KickUserOffl oldConnMap := ws.getUserAllCons(v) if conn, ok := oldConnMap[int(req.PlatformID)]; ok { // user->map[platform->conn] log.NewWarn(req.OperationID, "send kick msg, close connection ", req.PlatformID, v) - ws.sendKickMsg(conn) + ws.sendKickMsg(conn, req.OperationID) conn.Close() } } diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index e442443f9..2e1a33fe5 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -253,7 +253,7 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn] if oldConn, ok := oldConnMap[platformID]; ok { log.NewDebug(operationID, uid, platformID, "kick old conn") - ws.sendKickMsg(oldConn) + ws.sendKickMsg(oldConn, operationID) m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID)) if err != nil && err != go_redis.Nil { log.NewError(operationID, "get token from redis err", err.Error(), uid, constant.PlatformIDToName(platformID)) @@ -302,11 +302,12 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn case constant.WebAndOther: } } -func (ws *WServer) sendKickMsg(oldConn *UserConn) { +func (ws *WServer) sendKickMsg(oldConn *UserConn, operationID string) { mReply := Resp{ ReqIdentifier: constant.WSKickOnlineMsg, ErrCode: constant.ErrTokenInvalid.ErrCode, ErrMsg: constant.ErrTokenInvalid.ErrMsg, + OperationID: operationID, } var b bytes.Buffer enc := gob.NewEncoder(&b) @@ -422,19 +423,19 @@ func (ws *WServer) getUserAllCons(uid string) map[int]*UserConn { return nil } -//func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) { -// rwLock.RLock() -// defer rwLock.RUnlock() +// func (ws *WServer) getUserUid(conn *UserConn) (uid string, platform int) { +// rwLock.RLock() +// defer rwLock.RUnlock() // -// if stringMap, ok := ws.wsConnToUser[conn]; ok { -// for k, v := range stringMap { -// platform = k -// uid = v +// if stringMap, ok := ws.wsConnToUser[conn]; ok { +// for k, v := range stringMap { +// platform = k +// uid = v +// } +// return uid, platform // } -// return uid, platform +// return "", 0 // } -// return "", 0 -//} func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request, operationID string) (isPass, compression bool) { status := http.StatusUnauthorized query := r.URL.Query() From 5e1aa4379352348fa48e0059294c7796f3f6eefc Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 12 Jan 2023 10:59:42 +0800 Subject: [PATCH 3/8] file update --- cmd/Open-IM-SDK-Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index a9f57645a..e7bf4b2a2 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit a9f57645a5edf7e327e711ea49137676b5e0fbe3 +Subproject commit e7bf4b2a2066e8836dccd908d11b4d37c1c6a4ce From 84c7b8827e8354ca023c6610c2be2946caf0e8ad Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 13 Jan 2023 11:32:02 +0800 Subject: [PATCH 4/8] message --- pkg/common/db/rocks_cache/rocks_cache.go | 67 ++++++++++++------------ 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/pkg/common/db/rocks_cache/rocks_cache.go b/pkg/common/db/rocks_cache/rocks_cache.go index 3b054d37f..0e80c94b5 100644 --- a/pkg/common/db/rocks_cache/rocks_cache.go +++ b/pkg/common/db/rocks_cache/rocks_cache.go @@ -145,40 +145,6 @@ func DelJoinedGroupIDListFromCache(userID string) error { return db.DB.Rc.TagAsDeleted(joinedGroupListCache + userID) } -func GetGroupMemberIDListFromCache(groupID string) ([]string, error) { - f := func() (string, error) { - groupInfo, err := GetGroupInfoFromCache(groupID) - if err != nil { - return "", utils.Wrap(err, "GetGroupInfoFromCache failed") - } - var groupMemberIDList []string - if groupInfo.GroupType == constant.SuperGroup { - superGroup, err := db.DB.GetSuperGroup(groupID) - if err != nil { - return "", utils.Wrap(err, "") - } - groupMemberIDList = superGroup.MemberIDList - } else { - groupMemberIDList, err = imdb.GetGroupMemberIDListByGroupID(groupID) - if err != nil { - return "", utils.Wrap(err, "") - } - } - bytes, err := json.Marshal(groupMemberIDList) - if err != nil { - return "", utils.Wrap(err, "") - } - return string(bytes), nil - } - groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f) - if err != nil { - return nil, utils.Wrap(err, "") - } - var groupMemberIDList []string - err = json.Unmarshal([]byte(groupIDListStr), &groupMemberIDList) - return groupMemberIDList, utils.Wrap(err, "") -} - func DelGroupMemberIDListFromCache(groupID string) error { err := db.DB.Rc.TagAsDeleted(groupCache + groupID) return err @@ -458,6 +424,39 @@ func GetGroupMemberListHashFromCache(groupID string) (uint64, error) { hashCodeUint64, err := strconv.Atoi(hashCode) return uint64(hashCodeUint64), err } +func GetGroupMemberIDListFromCache(groupID string) ([]string, error) { + f := func() (string, error) { + groupInfo, err := GetGroupInfoFromCache(groupID) + if err != nil { + return "", utils.Wrap(err, "GetGroupInfoFromCache failed") + } + var groupMemberIDList []string + if groupInfo.GroupType == constant.SuperGroup { + superGroup, err := db.DB.GetSuperGroup(groupID) + if err != nil { + return "", utils.Wrap(err, "") + } + groupMemberIDList = superGroup.MemberIDList + } else { + groupMemberIDList, err = imdb.GetGroupMemberIDListByGroupID(groupID) + if err != nil { + return "", utils.Wrap(err, "") + } + } + bytes, err := json.Marshal(groupMemberIDList) + if err != nil { + return "", utils.Wrap(err, "") + } + return string(bytes), nil + } + groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f) + if err != nil { + return nil, utils.Wrap(err, "") + } + var groupMemberIDList []string + err = json.Unmarshal([]byte(groupIDListStr), &groupMemberIDList) + return groupMemberIDList, utils.Wrap(err, "") +} func DelGroupMemberListHashFromCache(groupID string) error { err := db.DB.Rc.TagAsDeleted(groupMemberListHashCache + groupID) From 1ab7660f0dc8dc91a662ba31874929dc44470ce1 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 13 Jan 2023 13:57:24 +0800 Subject: [PATCH 5/8] remove extend msg limit --- internal/rpc/msg/extend_msg.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/rpc/msg/extend_msg.go b/internal/rpc/msg/extend_msg.go index 30e9d492c..d8c2c9579 100644 --- a/internal/rpc/msg/extend_msg.go +++ b/internal/rpc/msg/extend_msg.go @@ -300,18 +300,18 @@ func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.A } return &rResp, nil } - if !req.IsExternalExtensions { - rResp.ErrCode = 200 - rResp.ErrMsg = "only extenalextensions message can be used" - for _, value := range req.ReactionExtensionList { - temp := new(msg.KeyValueResp) - temp.KeyValue = value - temp.ErrMsg = callbackResp.ErrMsg - temp.ErrCode = 100 - rResp.Result = append(rResp.Result, temp) - } - return &rResp, nil - } + //if !req.IsExternalExtensions { + // rResp.ErrCode = 200 + // rResp.ErrMsg = "only extenalextensions message can be used" + // for _, value := range req.ReactionExtensionList { + // temp := new(msg.KeyValueResp) + // temp.KeyValue = value + // temp.ErrMsg = callbackResp.ErrMsg + // temp.ErrCode = 100 + // rResp.Result = append(rResp.Result, temp) + // } + // return &rResp, nil + //} //if ExternalExtension var isHistory bool if req.IsReact { From f0976c9aded68b398054abc9148bb033e6ef00b8 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 13 Jan 2023 17:04:52 +0800 Subject: [PATCH 6/8] reaction message update --- internal/rpc/msg/extend_msg.go | 2 ++ pkg/call_back_struct/message.go | 1 + 2 files changed, 3 insertions(+) diff --git a/internal/rpc/msg/extend_msg.go b/internal/rpc/msg/extend_msg.go index d8c2c9579..821798477 100644 --- a/internal/rpc/msg/extend_msg.go +++ b/internal/rpc/msg/extend_msg.go @@ -300,6 +300,7 @@ func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.A } return &rResp, nil } + //if !req.IsExternalExtensions { // rResp.ErrCode = 200 // rResp.ErrMsg = "only extenalextensions message can be used" @@ -321,6 +322,7 @@ func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.A } rResp.MsgFirstModifyTime = callbackResp.MsgFirstModifyTime rResp.Result = callbackResp.ResultReactionExtensionList + rResp.IsReact = callbackResp.IsReact ExtendMessageAddedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, isHistory, false) return &rResp, nil } diff --git a/pkg/call_back_struct/message.go b/pkg/call_back_struct/message.go index 6e285a793..2fcb2b3aa 100644 --- a/pkg/call_back_struct/message.go +++ b/pkg/call_back_struct/message.go @@ -128,5 +128,6 @@ type CallbackAddMessageReactionExtReq struct { type CallbackAddMessageReactionExtResp struct { *CommonCallbackResp ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"` + IsReact bool `json:"isReact"` MsgFirstModifyTime int64 `json:"msgFirstModifyTime"` } From 286163ce181c13e0e8db88cf41b7d26a00fa3427 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 13 Jan 2023 17:42:23 +0800 Subject: [PATCH 7/8] reaction message update --- internal/api/msg/extend_msg.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/api/msg/extend_msg.go b/internal/api/msg/extend_msg.go index 9933ce0cf..bb14224b6 100644 --- a/internal/api/msg/extend_msg.go +++ b/internal/api/msg/extend_msg.go @@ -72,7 +72,7 @@ func GetMessageListReactionExtensions(c *gin.Context) { reqPb rpc.GetMessageListReactionExtensionsReq ) if err := c.BindJSON(&req); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) + c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": err.Error()}) return } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req) @@ -86,7 +86,7 @@ func GetMessageListReactionExtensions(c *gin.Context) { if !ok { errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token") log.NewError(req.OperationID, errMsg) - c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg}) + c.JSON(http.StatusOK, gin.H{"errCode": 500, "errMsg": errMsg}) return } From 05ee20613b1b1d8d801281f8c7672cccce320d09 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 13 Jan 2023 18:28:09 +0800 Subject: [PATCH 8/8] reaction message update --- pkg/base_info/msg.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/base_info/msg.go b/pkg/base_info/msg.go index 7df39b585..d3ece59f5 100644 --- a/pkg/base_info/msg.go +++ b/pkg/base_info/msg.go @@ -78,7 +78,7 @@ type ModifyMessageReactionExtensionsResp struct { type OperateMessageListReactionExtensionsReq struct { OperationID string `json:"operationID" binding:"required"` SourceID string `json:"sourceID" binding:"required"` - SessionType string `json:"sessionType" binding:"required"` + SessionType int32 `json:"sessionType" binding:"required"` IsExternalExtensions bool `json:"isExternalExtensions"` TypeKeyList []string `json:"typeKeyList"` MessageReactionKeyList []*msg.GetMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"` @@ -95,6 +95,7 @@ type OperateMessageListReactionExtensionsResp struct { type SetMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq type SetMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp + type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq type AddMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp