From 09c6fbdfe417e4ffa55b3fc3084fb3ddc370d306 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Fri, 10 Feb 2023 19:17:33 +0800 Subject: [PATCH 01/48] group --- internal/common/check/user.go | 30 +++- internal/rpc/group/callback.go | 223 ++++++++++++++------------- internal/rpc/group/g.go | 94 ------------ internal/rpc/group/group.go | 152 ++++++++++++------ internal/rpc/group/utils.go | 13 -- pkg/callbackstruct/group.go | 4 +- pkg/common/constant/errors.go | 1 + pkg/common/db/cache/group.go | 245 ++++++++++++++++-------------- pkg/common/db/controller/group.go | 54 +++---- pkg/utils/utils_v2.go | 13 ++ 10 files changed, 417 insertions(+), 412 deletions(-) delete mode 100644 internal/rpc/group/g.go delete mode 100644 internal/rpc/group/utils.go diff --git a/internal/common/check/user.go b/internal/common/check/user.go index 66f75198f..af5954c91 100644 --- a/internal/common/check/user.go +++ b/internal/common/check/user.go @@ -6,6 +6,32 @@ import ( "errors" ) -func GetUsersInfo(ctx context.Context, args ...interface{}) ([]*sdkws.UserInfo, error) { - return nil, errors.New("TODO:GetUserInfo") +//func GetUsersInfo(ctx context.Context, args ...interface{}) ([]*sdkws.UserInfo, error) { +// return nil, errors.New("TODO:GetUserInfo") +//} + +func NewUserCheck() *UserCheck { + return &UserCheck{} +} + +type UserCheck struct{} + +func (u *UserCheck) GetUsersInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.UserInfo, error) { + return nil, errors.New("todo") +} + +func (u *UserCheck) GetUsersInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.UserInfo, error) { + return nil, errors.New("todo") +} + +func (u *UserCheck) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) { + return nil, errors.New("todo") +} + +func (u *UserCheck) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) { + return nil, errors.New("todo") +} + +func (u *UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) { + return nil, errors.New("todo") } diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index b437e8702..0c174b8bf 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -1,92 +1,105 @@ package group import ( - cbApi "Open_IM/pkg/callback_struct" + "Open_IM/pkg/apistruct" + "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/http" - "Open_IM/pkg/common/log" "Open_IM/pkg/common/tracelog" - pbGroup "Open_IM/pkg/proto/group" + "Open_IM/pkg/proto/group" "Open_IM/pkg/utils" "context" "google.golang.org/protobuf/types/known/wrapperspb" ) -func callbackBeforeCreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (err error) { - defer func() { - tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", req) - }() +func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (err error) { if !config.Config.Callback.CallbackBeforeCreateGroup.Enable { return nil } - log.NewDebug(req.OperationID, utils.GetSelfFuncName(), req.String()) - commonCallbackReq := &cbApi.CallbackBeforeCreateGroupReq{ + defer func() { + tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", req) + }() + operationID := tracelog.GetOperationID(ctx) + commonCallbackReq := &callbackstruct.CallbackBeforeCreateGroupReq{ CallbackCommand: constant.CallbackBeforeCreateGroupCommand, - OperationID: req.OperationID, + OperationID: operationID, GroupInfo: *req.GroupInfo, - InitMemberList: req.InitMemberList, } - callbackResp := cbApi.CommonCallbackResp{OperationID: req.OperationID} - resp := &cbApi.CallbackBeforeCreateGroupResp{ - CommonCallbackResp: &callbackResp, + commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{ + UserID: req.OwnerUserID, + RoleLevel: constant.GroupOwner, + }) + for _, userID := range req.AdminUserIDs { + commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{ + UserID: userID, + RoleLevel: constant.GroupAdmin, + }) + } + for _, userID := range req.AdminUserIDs { + commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{ + UserID: userID, + RoleLevel: constant.GroupOrdinaryUsers, + }) + } + resp := &callbackstruct.CallbackBeforeCreateGroupResp{ + CommonCallbackResp: &callbackstruct.CommonCallbackResp{OperationID: operationID}, + } + err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeCreateGroup) + if err != nil { + return err } - //utils.CopyStructFields(req, msg.MsgData) - defer log.NewDebug(req.OperationID, utils.GetSelfFuncName(), commonCallbackReq, *resp) - err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq, - resp, config.Config.Callback.CallbackBeforeCreateGroup) - if err == nil { - if resp.GroupID != nil { - req.GroupInfo.GroupID = *resp.GroupID - } - if resp.GroupName != nil { - req.GroupInfo.GroupName = *resp.GroupName - } - if resp.Notification != nil { - req.GroupInfo.Notification = *resp.Notification - } - if resp.Introduction != nil { - req.GroupInfo.Introduction = *resp.Introduction - } - if resp.FaceURL != nil { - req.GroupInfo.FaceURL = *resp.FaceURL - } - if resp.OwnerUserID != nil { - req.GroupInfo.OwnerUserID = *resp.OwnerUserID - } - if resp.Ex != nil { - req.GroupInfo.Ex = *resp.Ex - } - if resp.Status != nil { - req.GroupInfo.Status = *resp.Status - } - if resp.CreatorUserID != nil { - req.GroupInfo.CreatorUserID = *resp.CreatorUserID - } - if resp.GroupType != nil { - req.GroupInfo.GroupType = *resp.GroupType - } - if resp.NeedVerification != nil { - req.GroupInfo.NeedVerification = *resp.NeedVerification - } - if resp.LookMemberInfo != nil { - req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo - } + + if resp.GroupID != nil { + req.GroupInfo.GroupID = *resp.GroupID } - return err + if resp.GroupName != nil { + req.GroupInfo.GroupName = *resp.GroupName + } + if resp.Notification != nil { + req.GroupInfo.Notification = *resp.Notification + } + if resp.Introduction != nil { + req.GroupInfo.Introduction = *resp.Introduction + } + if resp.FaceURL != nil { + req.GroupInfo.FaceURL = *resp.FaceURL + } + if resp.OwnerUserID != nil { + req.GroupInfo.OwnerUserID = *resp.OwnerUserID + } + if resp.Ex != nil { + req.GroupInfo.Ex = *resp.Ex + } + if resp.Status != nil { + req.GroupInfo.Status = *resp.Status + } + if resp.CreatorUserID != nil { + req.GroupInfo.CreatorUserID = *resp.CreatorUserID + } + if resp.GroupType != nil { + req.GroupInfo.GroupType = *resp.GroupType + } + if resp.NeedVerification != nil { + req.GroupInfo.NeedVerification = *resp.NeedVerification + } + if resp.LookMemberInfo != nil { + req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo + } + return nil } -func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, groupMember *relation.GroupMemberModel, groupEx string) (err error) { - defer func() { - tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx) - }() - callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +func CallbackBeforeMemberJoinGroup(ctx context.Context, groupMember *relation.GroupMemberModel, groupEx string) (err error) { if !config.Config.Callback.CallbackBeforeMemberJoinGroup.Enable { return nil } - log.NewDebug(operationID, "args: ", *groupMember) - callbackReq := cbApi.CallbackBeforeMemberJoinGroupReq{ + defer func() { + tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx) + }() + operationID := tracelog.GetOperationID(ctx) + callbackResp := callbackstruct.CommonCallbackResp{OperationID: operationID} + callbackReq := callbackstruct.CallbackBeforeMemberJoinGroupReq{ CallbackCommand: constant.CallbackBeforeMemberJoinGroupCommand, OperationID: operationID, GroupID: groupMember.GroupID, @@ -94,42 +107,44 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, grou Ex: groupMember.Ex, GroupEx: groupEx, } - resp := &cbApi.CallbackBeforeMemberJoinGroupResp{ + resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{ CommonCallbackResp: &callbackResp, } err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeMemberJoinGroupCommand, callbackReq, resp, config.Config.Callback.CallbackBeforeMemberJoinGroup) - if err == nil { - if resp.MuteEndTime != nil { - groupMember.MuteEndTime = utils.UnixSecondToTime(*resp.MuteEndTime) - } - if resp.FaceURL != nil { - groupMember.FaceURL = *resp.FaceURL - } - if resp.Ex != nil { - groupMember.Ex = *resp.Ex - } - if resp.NickName != nil { - groupMember.Nickname = *resp.NickName - } - if resp.RoleLevel != nil { - groupMember.RoleLevel = *resp.RoleLevel - } + if err != nil { + return err } - return err + if resp.MuteEndTime != nil { + groupMember.MuteEndTime = utils.UnixSecondToTime(*resp.MuteEndTime) + } + if resp.FaceURL != nil { + groupMember.FaceURL = *resp.FaceURL + } + if resp.Ex != nil { + groupMember.Ex = *resp.Ex + } + if resp.NickName != nil { + groupMember.Nickname = *resp.NickName + } + if resp.RoleLevel != nil { + groupMember.RoleLevel = *resp.RoleLevel + } + return nil } -func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfo) (err error) { - defer func() { - tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req) - }() - callbackResp := cbApi.CommonCallbackResp{OperationID: req.OperationID} +func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMemberInfo) (err error) { if !config.Config.Callback.CallbackBeforeSetGroupMemberInfo.Enable { return nil } - callbackReq := cbApi.CallbackBeforeSetGroupMemberInfoReq{ + defer func() { + tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req) + }() + operationID := tracelog.GetOperationID(ctx) + callbackResp := callbackstruct.CommonCallbackResp{OperationID: operationID} + callbackReq := callbackstruct.CallbackBeforeSetGroupMemberInfoReq{ CallbackCommand: constant.CallbackBeforeSetGroupMemberInfoCommand, - OperationID: req.OperationID, + OperationID: operationID, GroupID: req.GroupID, UserID: req.UserID, } @@ -145,24 +160,24 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroup if req.Ex != nil { callbackReq.Ex = req.Ex.Value } - resp := &cbApi.CallbackBeforeSetGroupMemberInfoResp{ + resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{ CommonCallbackResp: &callbackResp, } - err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetGroupMemberInfoCommand, callbackReq, - resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo.CallbackTimeOut, &config.Config.Callback.CallbackBeforeSetGroupMemberInfo.CallbackFailedContinue) - if err == nil { - if resp.FaceURL != nil { - req.FaceURL = &wrapperspb.StringValue{Value: *resp.FaceURL} - } - if resp.Nickname != nil { - req.Nickname = &wrapperspb.StringValue{Value: *resp.Nickname} - } - if resp.RoleLevel != nil { - req.RoleLevel = &wrapperspb.Int32Value{Value: *resp.RoleLevel} - } - if resp.Ex != nil { - req.Ex = &wrapperspb.StringValue{Value: *resp.Ex} - } + err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetGroupMemberInfoCommand, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo) + if err != nil { + return err + } + if resp.FaceURL != nil { + req.FaceURL = &wrapperspb.StringValue{Value: *resp.FaceURL} + } + if resp.Nickname != nil { + req.Nickname = &wrapperspb.StringValue{Value: *resp.Nickname} + } + if resp.RoleLevel != nil { + req.RoleLevel = &wrapperspb.Int32Value{Value: *resp.RoleLevel} + } + if resp.Ex != nil { + req.Ex = &wrapperspb.StringValue{Value: *resp.Ex} } return err } diff --git a/internal/rpc/group/g.go b/internal/rpc/group/g.go deleted file mode 100644 index 3bbbb4afa..000000000 --- a/internal/rpc/group/g.go +++ /dev/null @@ -1,94 +0,0 @@ -package group - -import ( - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/tracelog" - pbConversation "Open_IM/pkg/proto/conversation" - sdkws "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" - "context" - "errors" - "math/big" - "strconv" - "strings" - "time" -) - -func GetPublicUserInfoOne(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) { - return nil, errors.New("todo") -} - -func GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) { - return nil, errors.New("todo") -} - -func GetUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) { - users, err := GetUsersInfo(ctx, userIDs) - if err != nil { - return nil, err - } - return utils.SliceToMap(users, func(e *sdkws.UserInfo) string { - return e.UserID - }), nil -} - -func GetPublicUserInfo(ctx context.Context, userIDs []string) ([]*sdkws.PublicUserInfo, error) { - return nil, errors.New("todo") -} - -func GetPublicUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.PublicUserInfo, error) { - users, err := GetPublicUserInfo(ctx, userIDs) - if err != nil { - return nil, err - } - return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string { - return e.UserID - }), nil -} - -func GetUsername(ctx context.Context, userIDs []string) (map[string]string, error) { - if len(userIDs) == 0 { - return map[string]string{}, nil - } - users, err := GetPublicUserInfo(ctx, userIDs) - if err != nil { - return nil, err - } - if ids := utils.Single(userIDs, utils.Slice(users, func(e *sdkws.PublicUserInfo) string { - return e.UserID - })); len(ids) > 0 { - return nil, constant.ErrUserIDNotFound.Wrap(strings.Join(ids, ",")) - } - return utils.SliceToMapAny(users, func(e *sdkws.PublicUserInfo) (string, string) { - return e.UserID, e.Nickname - }), nil -} - -func GroupNotification(ctx context.Context, groupID string) { - var conversationReq pbConversation.ModifyConversationFieldReq - conversation := pbConversation.Conversation{ - OwnerUserID: tracelog.GetOpUserID(ctx), - ConversationID: utils.GetConversationIDBySessionType(groupID, constant.GroupChatType), - ConversationType: constant.GroupChatType, - GroupID: groupID, - } - conversationReq.Conversation = &conversation - conversationReq.OperationID = tracelog.GetOperationID(ctx) - conversationReq.FieldType = constant.FieldGroupAtType - conversation.GroupAtType = constant.GroupNotification - conversationReq.UserIDList = cacheResp.UserIDList - - _, err = pbConversation.NewConversationClient(s.etcdConn.GetConn("", config.Config.RpcRegisterName.OpenImConversationName)).ModifyConversationField(ctx, &conversationReq) - tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply) -} - -func genGroupID(ctx context.Context, groupID string) string { - if groupID != "" { - return groupID - } - groupID = utils.Md5(tracelog.GetOperationID(ctx) + strconv.FormatInt(time.Now().UnixNano(), 10)) - bi := big.NewInt(0) - bi.SetString(groupID[0:8], 16) - groupID = bi.String() - return groupID -} diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 9bdb77165..72da66aeb 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -1,6 +1,7 @@ package group import ( + "Open_IM/internal/common/check" "Open_IM/internal/common/network" chat "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" @@ -22,6 +23,9 @@ import ( "context" "fmt" grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "gorm.io/gorm" + "math/big" + "math/rand" "net" "strconv" "strings" @@ -38,6 +42,7 @@ type groupServer struct { zkAddr []string GroupInterface controller.GroupInterface registerCenter discoveryRegistry.SvcDiscoveryRegistry + user *check.UserCheck } func NewGroupServer(port int) *groupServer { @@ -72,8 +77,8 @@ func NewGroupServer(port int) *groupServer { } //conns, err := g.registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName) - g.GroupInterface = controller.NewGroupInterface(mysql.GormConn(), redis.GetClient(), mongo.GetClient()) + g.user = check.NewUserCheck() return &g } @@ -132,6 +137,69 @@ func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error return nil } +func (s *groupServer) GetUsernameMap(ctx context.Context, userIDs []string, complete bool) (map[string]string, error) { + if len(userIDs) == 0 { + return map[string]string{}, nil + } + users, err := s.user.GetPublicUserInfos(ctx, userIDs, complete) + if err != nil { + return nil, err + } + return utils.SliceToMapAny(users, func(e *open_im_sdk.PublicUserInfo) (string, string) { + return e.UserID, e.Nickname + }), nil +} + +func (s *groupServer) GroupNotification(ctx context.Context, groupID string) { + // todo 群公告修改通知 + //var conversationReq pbConversation.ModifyConversationFieldReq + //conversation := pbConversation.Conversation{ + // OwnerUserID: tracelog.GetOpUserID(ctx), + // ConversationID: utils.GetConversationIDBySessionType(groupID, constant.GroupChatType), + // ConversationType: constant.GroupChatType, + // GroupID: groupID, + //} + //conversationReq.Conversation = &conversation + //conversationReq.FieldType = constant.FieldGroupAtType + //conversation.GroupAtType = constant.GroupNotification + //conversationReq.UserIDList = userIDs + //_, err := pbConversation.NewConversationClient(s.etcdConn.GetConn("", config.Config.RpcRegisterName.OpenImConversationName)).ModifyConversationField(ctx, &conversationReq) + //tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply) +} + +func (s *groupServer) IsNotFound(err error) bool { + return utils.Unwrap(err) == gorm.ErrRecordNotFound +} + +func (s *groupServer) GenGroupID(ctx context.Context, groupID *string) error { + if *groupID != "" { + _, err := s.GroupInterface.TakeGroup(ctx, *groupID) + if err == nil { + return constant.ErrGroupIDExisted.Wrap("group id existed " + *groupID) + } else if s.IsNotFound(err) { + return nil + } else { + return err + } + } + for i := 0; i < 10; i++ { + id := utils.Md5(strings.Join([]string{tracelog.GetOperationID(ctx), strconv.FormatInt(time.Now().UnixNano(), 10), strconv.Itoa(rand.Int())}, ",;,")) + bi := big.NewInt(0) + bi.SetString(id[0:8], 16) + id = bi.String() + _, err := s.GroupInterface.TakeGroup(ctx, id) + if err == nil { + continue + } else if s.IsNotFound(err) { + *groupID = id + return nil + } else { + return err + } + } + return constant.ErrData.Wrap("group id gen error") +} + func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (*pbGroup.CreateGroupResp, error) { resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}} if err := tokenverify.CheckAccessV3(ctx, req.OwnerUserID); err != nil { @@ -144,19 +212,18 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if utils.Duplicate(userIDs) { return nil, constant.ErrArgs.Wrap("group member repeated") } - userMap, err := GetUserInfoMap(ctx, userIDs) + userMap, err := s.user.GetUsersInfoMap(ctx, userIDs, true) if err != nil { return nil, err } - if ids := utils.Single(userIDs, utils.Keys(userMap)); len(ids) > 0 { - return nil, constant.ErrUserIDNotFound.Wrap(strings.Join(ids, ",")) - } - if err := callbackBeforeCreateGroup(ctx, req); err != nil { + if err := CallbackBeforeCreateGroup(ctx, req); err != nil { return nil, err } var groupMembers []*relationTb.GroupMemberModel group := PbToDBGroupInfo(req.GroupInfo) - group.GroupID = genGroupID(ctx, req.GroupInfo.GroupID) + if err := s.GenGroupID(ctx, &group.GroupID); err != nil { + return nil, err + } joinGroup := func(userID string, roleLevel int32) error { groupMember := PbToDbGroupMember(userMap[userID]) groupMember.Nickname = "" @@ -165,7 +232,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR groupMember.OperatorUserID = tracelog.GetOpUserID(ctx) groupMember.JoinSource = constant.JoinByInvitation groupMember.InviterUserID = tracelog.GetOpUserID(ctx) - if err := CallbackBeforeMemberJoinGroup(ctx, tracelog.GetOperationID(ctx), groupMember, group.Ex); err != nil { + if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil { return err } groupMembers = append(groupMembers, groupMember) @@ -271,13 +338,10 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if ids := utils.Single(req.InvitedUserIDs, utils.Keys(memberMap)); len(ids) > 0 { return nil, constant.ErrArgs.Wrap("user in group " + strings.Join(ids, ",")) } - userMap, err := GetUserInfoMap(ctx, req.InvitedUserIDs) + userMap, err := s.user.GetUsersInfoMap(ctx, req.InvitedUserIDs, true) if err != nil { return nil, err } - if ids := utils.Single(req.InvitedUserIDs, utils.Keys(userMap)); len(ids) > 0 { - return nil, constant.ErrArgs.Wrap("user not found " + strings.Join(ids, ",")) - } if group.NeedVerification == constant.AllNeedVerification { if !tokenverify.IsAppManagerUid(ctx) { opUserID := tracelog.GetOpUserID(ctx) @@ -328,7 +392,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite member.OperatorUserID = opUserID member.InviterUserID = opUserID member.JoinSource = constant.JoinByInvitation - if err := CallbackBeforeMemberJoinGroup(ctx, tracelog.GetOperationID(ctx), member, group.Ex); err != nil { + if err := CallbackBeforeMemberJoinGroup(ctx, member, group.Ex); err != nil { return nil, err } groupMembers = append(groupMembers, member) @@ -354,9 +418,9 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro if err != nil { return nil, err } - nameMap, err := GetUsername(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { + nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { return e.UserID, e.Nickname == "" - })) + }), true) if err != nil { return nil, err } @@ -376,9 +440,9 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr return nil, err } resp.Total = total - nameMap, err := GetUsername(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { + nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { return e.UserID, e.Nickname == "" - })) + }), true) if err != nil { return nil, err } @@ -470,9 +534,9 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG if err != nil { return nil, err } - nameMap, err := GetUsername(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { + nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { return e.UserID, e.Nickname == "" - })) + }), true) if err != nil { return nil, err } @@ -505,13 +569,10 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup. } userIDs = utils.Distinct(userIDs) groupIDs = utils.Distinct(groupIDs) - userMap, err := GetPublicUserInfoMap(ctx, userIDs) + userMap, err := s.user.GetPublicUserInfoMap(ctx, userIDs, true) if err != nil { return nil, err } - if ids := utils.Single(utils.Keys(userMap), userIDs); len(ids) > 0 { - return nil, constant.ErrUserIDNotFound.Wrap(strings.Join(ids, ",")) - } groups, err := s.GroupInterface.FindGroup(ctx, utils.Distinct(groupIDs)) if err != nil { return nil, err @@ -590,19 +651,18 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup if groupRequest.HandleResult != 0 { return nil, constant.ErrArgs.Wrap("group request already processed") } - if _, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.FromUserID); err != nil { - if !IsNotFound(err) { - return nil, err - } - } else { - return nil, constant.ErrArgs.Wrap("already in group") + var join bool + if _, err = s.GroupInterface.TakeGroupMember(ctx, req.GroupID, req.FromUserID); err == nil { + join = true // 已经在群里了 + } else if !s.IsNotFound(err) { + return nil, err } - user, err := GetPublicUserInfoOne(ctx, req.FromUserID) + user, err := s.user.GetPublicUserInfo(ctx, req.FromUserID) if err != nil { return nil, err } var member *relationTb.GroupMemberModel - if req.HandleResult == constant.GroupResponseAgree { + if (!join) && req.HandleResult == constant.GroupResponseAgree { member = &relationTb.GroupMemberModel{ GroupID: req.GroupID, UserID: user.UserID, @@ -615,25 +675,27 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup OperatorUserID: tracelog.GetOpUserID(ctx), Ex: groupRequest.Ex, } - if err = CallbackBeforeMemberJoinGroup(ctx, tracelog.GetOperationID(ctx), member, group.Ex); err != nil { + if err = CallbackBeforeMemberJoinGroup(ctx, member, group.Ex); err != nil { return nil, err } } if err := s.GroupInterface.HandlerGroupRequest(ctx, req.GroupID, req.FromUserID, req.HandledMsg, req.HandleResult, member); err != nil { return nil, err } - if req.HandleResult == constant.GroupResponseAgree { - chat.GroupApplicationAcceptedNotification(req) - chat.MemberEnterNotification(req) - } else if req.HandleResult == constant.GroupResponseRefuse { - chat.GroupApplicationRejectedNotification(req) + if !join { + if req.HandleResult == constant.GroupResponseAgree { + chat.GroupApplicationAcceptedNotification(req) + chat.MemberEnterNotification(ctx, req) + } else if req.HandleResult == constant.GroupResponseRefuse { + chat.GroupApplicationRejectedNotification(req) + } } return resp, nil } func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (*pbGroup.JoinGroupResp, error) { resp := &pbGroup.JoinGroupResp{} - if _, err := GetPublicUserInfoOne(ctx, tracelog.GetOpUserID(ctx)); err != nil { + if _, err := s.user.GetPublicUserInfo(ctx, tracelog.GetOpUserID(ctx)); err != nil { return nil, err } group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID) @@ -657,7 +719,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) groupMember.OperatorUserID = tracelog.GetOpUserID(ctx) groupMember.JoinSource = constant.JoinByInvitation groupMember.InviterUserID = tracelog.GetOpUserID(ctx) - if err := CallbackBeforeMemberJoinGroup(ctx, tracelog.GetOperationID(ctx), groupMember, group.Ex); err != nil { + if err := CallbackBeforeMemberJoinGroup(ctx, groupMember, group.Ex); err != nil { return nil, err } if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil { @@ -732,7 +794,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf } chat.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) if req.GroupInfoForSet.Notification != "" { - GroupNotification(ctx, group.GroupID) + s.GroupNotification(ctx, group.GroupID) } return resp, nil } @@ -830,9 +892,9 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr return nil, err } resp.Total = total - nameMap, err := GetUsername(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { + nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { return e.UserID, e.Nickname == "" - })) + }), true) if err != nil { return nil, err } @@ -847,7 +909,7 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) { resp := &pbGroup.GetUserReqApplicationListResp{} - user, err := GetPublicUserInfoOne(ctx, req.UserID) + user, err := s.user.GetPublicUserInfo(ctx, req.UserID) if err != nil { return nil, err } @@ -1105,9 +1167,9 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge if err != nil { return nil, err } - nameMap, err := GetUsername(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { + nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { return e.UserID, e.Nickname == "" - })) + }), true) if err != nil { return nil, err } diff --git a/internal/rpc/group/utils.go b/internal/rpc/group/utils.go deleted file mode 100644 index 51a774c04..000000000 --- a/internal/rpc/group/utils.go +++ /dev/null @@ -1,13 +0,0 @@ -package group - -import ( - "Open_IM/pkg/common/tracelog" - "gorm.io/gorm" -) - -func IsNotFound(err error) bool { - if err == nil { - return false - } - return tracelog.Unwrap(err) == gorm.ErrRecordNotFound -} diff --git a/pkg/callbackstruct/group.go b/pkg/callbackstruct/group.go index e504151c1..a84753326 100644 --- a/pkg/callbackstruct/group.go +++ b/pkg/callbackstruct/group.go @@ -1,7 +1,7 @@ package callbackstruct import ( - "Open_IM/pkg/proto/group" + "Open_IM/pkg/apistruct" common "Open_IM/pkg/proto/sdkws" ) @@ -9,7 +9,7 @@ type CallbackBeforeCreateGroupReq struct { CallbackCommand string `json:"callbackCommand"` OperationID string `json:"operationID"` common.GroupInfo - InitMemberList []*group.GroupAddMemberInfo `json:"initMemberList"` + InitMemberList []*apistruct.GroupAddMemberInfo `json:"initMemberList"` } type CallbackBeforeCreateGroupResp struct { diff --git a/pkg/common/constant/errors.go b/pkg/common/constant/errors.go index 8dc933b22..fc5984946 100644 --- a/pkg/common/constant/errors.go +++ b/pkg/common/constant/errors.go @@ -13,6 +13,7 @@ var ( ErrUserIDNotFound = &ErrInfo{UserIDNotFoundError, "UserIDNotFoundError", ""} ErrGroupIDNotFound = &ErrInfo{GroupIDNotFoundError, "GroupIDNotFoundError", ""} + ErrGroupIDExisted = &ErrInfo{GroupIDNotFoundError, "GroupIDExisted", ""} // todo group id 已存在 ErrRecordNotFound = &ErrInfo{RecordNotFoundError, "RecordNotFoundError", ""} diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go index 8376a1d56..0e8322f0d 100644 --- a/pkg/common/db/cache/group.go +++ b/pkg/common/db/cache/group.go @@ -1,17 +1,14 @@ package cache import ( - "Open_IM/pkg/common/db/relation" relationTb "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/common/tracelog" "Open_IM/pkg/utils" "context" - "encoding/json" "github.com/dtm-labs/rockscache" "github.com/go-redis/redis/v8" "math/big" - "strconv" "strings" "time" ) @@ -157,6 +154,27 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin }) } +func (g *GroupCacheRedis) GetGroupMemberHash1(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) { + // todo + mapGroupUserIDs, err := g.groupMember.FindJoinUserID(ctx, groupIDs) + if err != nil { + return nil, err + } + res := make(map[string]*relationTb.GroupSimpleUserID) + for _, groupID := range groupIDs { + userIDs := mapGroupUserIDs[groupID] + users := &relationTb.GroupSimpleUserID{} + if len(userIDs) > 0 { + utils.Sort(userIDs, true) + bi := big.NewInt(0) + bi.SetString(utils.Md5(strings.Join(userIDs, ";"))[0:8], 16) + users.Hash = bi.Uint64() + } + res[groupID] = users + } + return res, nil +} + func (g *GroupCacheRedis) DelGroupMembersHash(ctx context.Context, groupID string) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID) @@ -178,111 +196,104 @@ func (g *GroupCacheRedis) DelGroupMemberIDs(ctx context.Context, groupID string) return g.rcClient.TagAsDeleted(g.getGroupMemberIDsKey(groupID)) } -// JoinedGroups -func (g *GroupCacheRedis) GetJoinedGroupIDs(ctx context.Context, userID string) (joinedGroupIDs []string, err error) { - getJoinedGroupIDList := func() (string, error) { - joinedGroupList, err := relation.GetJoinedGroupIDListByUserID(userID) - if err != nil { - return "", err - } - bytes, err := json.Marshal(joinedGroupList) - if err != nil { - return "", utils.Wrap(err, "") - } - return string(bytes), nil - } - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedGroupIDs", joinedGroupIDs) - }() - joinedGroupIDListStr, err := g.rcClient.Fetch(g.getJoinedGroupsKey(userID), time.Second*30*60, getJoinedGroupIDList) - if err != nil { - return nil, err - } - err = json.Unmarshal([]byte(joinedGroupIDListStr), &joinedGroupIDs) - return joinedGroupIDs, utils.Wrap(err, "") -} - -func (g *GroupCacheRedis) DelJoinedGroupIDs(ctx context.Context, userID string) (err error) { +//// JoinedGroups +//func (g *GroupCacheRedis) GetJoinedGroupIDs(ctx context.Context, userID string) (joinedGroupIDs []string, err error) { +// getJoinedGroupIDList := func() (string, error) { +// joinedGroupList, err := relation.GetJoinedGroupIDListByUserID(userID) +// if err != nil { +// return "", err +// } +// bytes, err := json.Marshal(joinedGroupList) +// if err != nil { +// return "", utils.Wrap(err, "") +// } +// return string(bytes), nil +// } +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedGroupIDs", joinedGroupIDs) +// }() +// joinedGroupIDListStr, err := g.rcClient.Fetch(g.getJoinedGroupsKey(userID), time.Second*30*60, getJoinedGroupIDList) +// if err != nil { +// return nil, err +// } +// err = json.Unmarshal([]byte(joinedGroupIDListStr), &joinedGroupIDs) +// return joinedGroupIDs, utils.Wrap(err, "") +//} + +func (g *GroupCacheRedis) DelJoinedGroupID(ctx context.Context, userID string) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID) }() return g.rcClient.TagAsDeleted(g.getJoinedGroupsKey(userID)) } -// GetGroupMemberInfo -func (g *GroupCacheRedis) GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relation.GroupMember, err error) { - getGroupMemberInfo := func() (string, error) { - groupMemberInfo, err := relation.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID) - if err != nil { - return "", err - } - bytes, err := json.Marshal(groupMemberInfo) - if err != nil { - return "", utils.Wrap(err, "") - } - return string(bytes), nil - } - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember) - }() - groupMemberInfoStr, err := g.rcClient.Fetch(g.getGroupMemberInfoKey(groupID, userID), time.Second*30*60, getGroupMemberInfo) - if err != nil { - return nil, err - } - groupMember = &relation.GroupMember{} - err = json.Unmarshal([]byte(groupMemberInfoStr), groupMember) - return groupMember, utils.Wrap(err, "") -} - -func (g *GroupCacheRedis) GetGroupMembersInfo(ctx context.Context, groupID, userIDs []string) (groupMember *relationTb.GroupMemberModel, err error) { - - return nil, err +//func (g *GroupCacheRedis) DelJoinedGroupIDs(ctx context.Context, userIDs []string) (err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID) +// }() +// for _, userID := range userIDs { +// if err := g.DelJoinedGroupID(ctx, userID); err != nil { +// return err +// } +// } +// return nil +//} + +func (g *GroupCacheRedis) GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relationTb.GroupMemberModel, err error) { + return GetCache(ctx, g.rcClient, g.getGroupMemberInfoKey(groupID, userID), g.expireTime, func(ctx context.Context) (*relationTb.GroupMemberModel, error) { + return g.groupMember.Take(ctx, groupID, userID) + }) } -func (g *GroupCacheRedis) GetGroupMembersInfo(ctx context.Context, count, offset int32, groupID string) (groupMembers []*relation.GroupMember, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "count", count, "offset", offset, "groupID", groupID, "groupMember", groupMembers) - }() - groupMemberIDList, err := g.GetGroupMemberIDs(ctx, groupID) - if err != nil { - return nil, err - } - if count < 0 || offset < 0 { - return nil, nil - } - var groupMemberList []*relation.GroupMember - var start, stop int32 - start = offset - stop = offset + count - l := int32(len(groupMemberIDList)) - if start > stop { - return nil, nil - } - if start >= l { - return nil, nil - } - if count != 0 { - if stop >= l { - stop = l - } - groupMemberIDList = groupMemberIDList[start:stop] - } else { - if l < 1000 { - stop = l - } else { - stop = 1000 - } - groupMemberIDList = groupMemberIDList[start:stop] - } - for _, userID := range groupMemberIDList { - groupMember, err := g.GetGroupMemberInfo(ctx, groupID, userID) - if err != nil { - return - } - groupMembers = append(groupMembers, groupMember) - } - return groupMemberList, nil -} +//func (g *GroupCacheRedis) GetGroupMembersInfo(ctx context.Context, groupID, userIDs []string) (groupMember *relationTb.GroupMemberModel, err error) { +// +// return nil, err +//} + +//func (g *GroupCacheRedis) GetGroupMembersInfo(ctx context.Context, count, offset int32, groupID string) (groupMembers []*relation.GroupMember, err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "count", count, "offset", offset, "groupID", groupID, "groupMember", groupMembers) +// }() +// groupMemberIDList, err := g.GetGroupMemberIDs(ctx, groupID) +// if err != nil { +// return nil, err +// } +// if count < 0 || offset < 0 { +// return nil, nil +// } +// var groupMemberList []*relation.GroupMember +// var start, stop int32 +// start = offset +// stop = offset + count +// l := int32(len(groupMemberIDList)) +// if start > stop { +// return nil, nil +// } +// if start >= l { +// return nil, nil +// } +// if count != 0 { +// if stop >= l { +// stop = l +// } +// groupMemberIDList = groupMemberIDList[start:stop] +// } else { +// if l < 1000 { +// stop = l +// } else { +// stop = 1000 +// } +// groupMemberIDList = groupMemberIDList[start:stop] +// } +// for _, userID := range groupMemberIDList { +// groupMember, err := g.GetGroupMemberInfo(ctx, groupID, userID) +// if err != nil { +// return +// } +// groupMembers = append(groupMembers, groupMember) +// } +// return groupMemberList, nil +//} func (g *GroupCacheRedis) DelGroupMemberInfo(ctx context.Context, groupID, userID string) (err error) { defer func() { @@ -292,23 +303,23 @@ func (g *GroupCacheRedis) DelGroupMemberInfo(ctx context.Context, groupID, userI } // groupMemberNum -func (g *GroupCacheRedis) GetGroupMemberNum(ctx context.Context, groupID string) (num int, err error) { - getGroupMemberNum := func() (string, error) { - num, err := relation.GetGroupMemberNumByGroupID(groupID) - if err != nil { - return "", err - } - return strconv.Itoa(int(num)), nil - } - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "num", num) - }() - groupMember, err := g.rcClient.Fetch(g.getGroupMemberNumKey(groupID), time.Second*30*60, getGroupMemberNum) - if err != nil { - return 0, err - } - return strconv.Atoi(groupMember) -} +//func (g *GroupCacheRedis) GetGroupMemberNum(ctx context.Context, groupID string) (num int, err error) { +// getGroupMemberNum := func() (string, error) { +// num, err := relation.GetGroupMemberNumByGroupID(groupID) +// if err != nil { +// return "", err +// } +// return strconv.Itoa(int(num)), nil +// } +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "num", num) +// }() +// groupMember, err := g.rcClient.Fetch(g.getGroupMemberNumKey(groupID), time.Second*30*60, getGroupMemberNum) +// if err != nil { +// return 0, err +// } +// return strconv.Atoi(groupMember) +//} func (g *GroupCacheRedis) DelGroupMemberNum(ctx context.Context, groupID string) (err error) { defer func() { diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index ba39bb511..8a39442c8 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -15,8 +15,6 @@ import ( "github.com/go-redis/redis/v8" "go.mongodb.org/mongo-driver/mongo" "gorm.io/gorm" - "math/big" - "strings" ) //type GroupInterface GroupDataBaseInterface @@ -248,7 +246,7 @@ type GroupDataBase struct { func (g *GroupDataBase) delGroupMemberCache(ctx context.Context, groupID string, userIDs []string) error { for _, userID := range userIDs { - if err := g.cache.DelJoinedGroupIDs(ctx, userID); err != nil { + if err := g.cache.DelJoinedGroupID(ctx, userID); err != nil { return err } if err := g.cache.DelJoinedSuperGroupIDs(ctx, userID); err != nil { @@ -272,21 +270,24 @@ func (g *GroupDataBase) FindGroupMemberUserID(ctx context.Context, groupID strin } func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error { - if len(groups) > 0 && len(groupMembers) > 0 { - return g.db.Transaction(func(tx *gorm.DB) error { + return g.db.Transaction(func(tx *gorm.DB) error { + if len(groups) > 0 { if err := g.groupDB.Create(ctx, groups, tx); err != nil { return err } - return g.groupMemberDB.Create(ctx, groupMembers, tx) - }) - } - if len(groups) > 0 { - return g.groupDB.Create(ctx, groups) - } - if len(groupMembers) > 0 { - return g.groupMemberDB.Create(ctx, groupMembers) - } - return nil + } + if len(groupMembers) > 0 { + if err := g.groupMemberDB.Create(ctx, groupMembers, tx); err != nil { + return err + } + //if err := g.cache.DelJoinedGroupIDs(ctx, utils.Slice(groupMembers, func(e *relationTb.GroupMemberModel) string { + // return e.UserID + //})); err != nil { + // return err + //} + } + return nil + }) } func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) { @@ -337,12 +338,11 @@ func (g *GroupDataBase) TakeGroupMember(ctx context.Context, groupID string, use } func (g *GroupDataBase) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) { - return g.groupMemberDB.TakeOwner(ctx, groupID) + return g.groupMemberDB.TakeOwner(ctx, groupID) // todo cache group owner } func (g *GroupDataBase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) { - //g.cache.GetGroupMembersInfo() - return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels) + return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels) // todo cache group find } func (g *GroupDataBase) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) { @@ -383,23 +383,7 @@ func (g *GroupDataBase) DeleteGroupMember(ctx context.Context, groupID string, u } func (g *GroupDataBase) MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) { - mapGroupUserIDs, err := g.groupMemberDB.FindJoinUserID(ctx, groupIDs) - if err != nil { - return nil, err - } - res := make(map[string]*relationTb.GroupSimpleUserID) - for _, groupID := range groupIDs { - userIDs := mapGroupUserIDs[groupID] - users := &relationTb.GroupSimpleUserID{} - if len(userIDs) > 0 { - utils.Sort(userIDs, true) - bi := big.NewInt(0) - bi.SetString(utils.Md5(strings.Join(userIDs, ";"))[0:8], 16) - users.Hash = bi.Uint64() - } - res[groupID] = users - } - return res, nil + return g.cache.GetGroupMemberHash1(ctx, groupIDs) } func (g *GroupDataBase) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) { diff --git a/pkg/utils/utils_v2.go b/pkg/utils/utils_v2.go index 91c8fecd9..bd2959845 100644 --- a/pkg/utils/utils_v2.go +++ b/pkg/utils/utils_v2.go @@ -412,3 +412,16 @@ func (o *sortSlice[E]) Swap(i, j int) { type Ordered interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string } + +func Unwrap(err error) error { + for err != nil { + unwrap, ok := err.(interface { + Unwrap() error + }) + if !ok { + break + } + err = unwrap.Unwrap() + } + return err +} From a3593379f6b3bb5166efc14484acf74c4c0cabb4 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Fri, 10 Feb 2023 20:57:45 +0800 Subject: [PATCH 02/48] conversation update --- internal/rpc/conversation/conversaion.go | 31 +-- internal/rpc/msg/conversation_notification.go | 4 +- pkg/common/db/cache/conversation.go | 44 +++- pkg/common/db/controller/conversation.go | 241 ++++++++++++++++-- .../db/relation/conversation_model_g.go | 71 ++++-- 5 files changed, 316 insertions(+), 75 deletions(-) diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go index 54d5a0380..4cfb99cbe 100644 --- a/internal/rpc/conversation/conversaion.go +++ b/internal/rpc/conversation/conversaion.go @@ -7,7 +7,7 @@ import ( "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/controller" "Open_IM/pkg/common/db/relation" - "Open_IM/pkg/common/db/table" + tableRelation "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/common/log" promePkg "Open_IM/pkg/common/prometheus" @@ -50,7 +50,7 @@ func NewConversationServer(port int) *conversationServer { var cCache cache.ConversationCache //mysql init var mysql relation.Mysql - err := mysql.InitConn().AutoMigrateModel(&table.ConversationModel{}) + err := mysql.InitConn().AutoMigrateModel(&tableRelation.ConversationModel{}) if err != nil { panic("db init err:" + err.Error()) } @@ -173,7 +173,7 @@ func (c *conversationServer) GetConversations(ctx context.Context, req *pbConver func (c *conversationServer) BatchSetConversations(ctx context.Context, req *pbConversation.BatchSetConversationsReq) (*pbConversation.BatchSetConversationsResp, error) { resp := &pbConversation.BatchSetConversationsResp{} - var conversations []*table.ConversationModel + var conversations []*tableRelation.ConversationModel if err := utils.CopyStructFields(&conversations, req.Conversations); err != nil { return nil, err } @@ -206,16 +206,16 @@ func (c *conversationServer) ModifyConversationField(ctx context.Context, req *p return nil, err } } - var conversation table.ConversationModel + var conversation tableRelation.ConversationModel if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil { return nil, err } if req.FieldType == constant.FieldIsPrivateChat { - err := c.ConversationInterface.SyncPeerUserPrivateConversationTx(ctx, req.Conversation) + err := c.ConversationInterface.SyncPeerUserPrivateConversationTx(ctx, &conversation) if err != nil { return nil, err } - chat.ConversationSetPrivateNotification(req.OperationID, req.Conversation.OwnerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat) + chat.ConversationSetPrivateNotification(ctx, req.Conversation.OwnerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat) return resp, nil } //haveUserID, err := c.ConversationInterface.GetUserIDExistConversation(ctx, req.UserIDList, req.Conversation.ConversationID) @@ -242,29 +242,18 @@ func (c *conversationServer) ModifyConversationField(ctx context.Context, req *p case constant.FieldBurnDuration: filedMap["burn_duration"] = req.Conversation.BurnDuration } - c.ConversationInterface.SetUsersConversationFiledTx(ctx, req.UserIDList, &conversation, filedMap) - err = c.ConversationInterface.UpdateUsersConversationFiled(ctx, haveUserID, req.Conversation.ConversationID, filedMap) - if err != nil { - return nil, err - } - var conversations []*pbConversation.Conversation - for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) { - temp := new(pbConversation.Conversation) - _ = utils.CopyStructFields(temp, req.Conversation) - temp.OwnerUserID = v - conversations = append(conversations, temp) - } - err = c.ConversationInterface.CreateConversation(ctx, conversations) + err = c.ConversationInterface.SetUsersConversationFiledTx(ctx, req.UserIDList, &conversation, filedMap) if err != nil { return nil, err } + if isSyncConversation { for _, v := range req.UserIDList { - chat.ConversationChangeNotification(req.OperationID, v) + chat.ConversationChangeNotification(ctx, v) } } else { for _, v := range req.UserIDList { - chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID, req.Conversation.UpdateUnreadCountTime) + chat.ConversationUnreadChangeNotification(ctx, v, req.Conversation.ConversationID, req.Conversation.UpdateUnreadCountTime) } } return resp, nil diff --git a/internal/rpc/msg/conversation_notification.go b/internal/rpc/msg/conversation_notification.go index 2b90809e7..4efc4e4d1 100644 --- a/internal/rpc/msg/conversation_notification.go +++ b/internal/rpc/msg/conversation_notification.go @@ -41,7 +41,7 @@ func SetConversationNotification(operationID, sendID, recvID string, contentType } // SetPrivate调用 -func ConversationSetPrivateNotification(operationID, sendID, recvID string, isPrivateChat bool) { +func ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) { log.NewInfo(operationID, utils.GetSelfFuncName()) conversationSetPrivateTips := &open_im_sdk.ConversationSetPrivateTips{ RecvID: recvID, @@ -71,7 +71,7 @@ func ConversationChangeNotification(ctx context.Context, userID string) { } //会话未读数同步 -func ConversationUnreadChangeNotification(operationID, userID, conversationID string, updateUnreadCountTime int64) { +func ConversationUnreadChangeNotification(context context.Context, userID, conversationID string, updateUnreadCountTime int64) { log.NewInfo(operationID, utils.GetSelfFuncName()) ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{ UserID: userID, diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go index 844e9b937..53e73a7f1 100644 --- a/pkg/common/db/cache/conversation.go +++ b/pkg/common/db/cache/conversation.go @@ -20,21 +20,25 @@ const ( superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:" conversationExpireTime = time.Second * 60 * 60 * 12 ) +type FuncDB func() (string, error) // args fn will exec when no data in cache type ConversationCache interface { // get user's conversationIDs from cache - GetUserConversationIDs(ctx context.Context, userID string, fn func(ctx context.Context, userID string) ([]string, error)) ([]string, error) + GetUserConversationIDs(ctx context.Context, userID string, fn FuncDB) ([]string, error) // del user's conversationIDs from cache, call when a user add or reduce a conversation DelUserConversationIDs(ctx context.Context, userID string) error + DelUsersConversationIDs(ctx context.Context,userIDList []string)error // get one conversation from cache - GetConversation(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID, conversationID string) (*relationTb.ConversationModel, error)) (*relationTb.ConversationModel, error) + GetConversation(ctx context.Context, ownerUserID, conversationID string, fn FuncDB) (*relationTb.ConversationModel, error) // get one conversation from cache - GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn func(ctx context.Context, ownerUserID, conversationIDs []string) ([]*relationTb.ConversationModel, error)) ([]*relationTb.ConversationModel, error) + GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB)([]*relationTb.ConversationModel, error) // get one user's all conversations from cache - GetUserAllConversations(ctx context.Context, ownerUserID string, fn func(ctx context.Context, ownerUserIDs string) ([]*relationTb.ConversationModel, error)) ([]*relationTb.ConversationModel, error) + GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB ) ([]*relationTb.ConversationModel, error) // del one conversation from cache, call when one user's conversation Info changed DelConversation(ctx context.Context, ownerUserID, conversationID string) error + DelUserConversations(ctx context.Context, ownerUserID string, conversationIDList []string) error + DelUsersConversation(ctx context.Context, ownerUserIDList []string, conversationID string) error // get user conversation recv msg from cache GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)) (opt int, err error) // del user recv msg opt from cache, call when user's conversation recv msg opt changed @@ -51,6 +55,38 @@ type ConversationRedis struct { rcClient *rockscache.Client } +func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, userID string, fn func(ctx context.Context, userID string) ([]string, error)) ([]string, error) { + panic("implement me") +} + +func (c *ConversationRedis) DelUsersConversationIDs(ctx context.Context, userIDList []string) error { + panic("implement me") +} + +func (c *ConversationRedis) GetConversation(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error)) (*relationTb.ConversationModel, error) { + panic("implement me") +} + +func (c *ConversationRedis) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn FuncDB) ([]*relationTb.ConversationModel, error) { + panic("implement me") +} + +func (c *ConversationRedis) GetUserAllConversations(ctx context.Context, ownerUserID string, fn FuncDB) ([]*relationTb.ConversationModel, error) { + panic("implement me") +} + +func (c *ConversationRedis) DelUsersConversation(ctx context.Context, ownerUserIDList []string, conversationID string) error { + panic("implement me") +} + +func (c *ConversationRedis) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID string, conversationID string) (opt int, err error)) (opt int, err error) { + panic("implement me") +} + +func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string, fn func(ctx context.Context, groupID string) (userIDs []string, err error)) (userIDs []string, err error) { + panic("implement me") +} + func NewConversationRedis(rcClient *rockscache.Client) *ConversationRedis { return &ConversationRedis{rcClient: rcClient} } diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index c5fe8bc3b..093249940 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -1,32 +1,42 @@ package controller import ( + "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/relation" relationTb "Open_IM/pkg/common/db/table/relation" + "Open_IM/pkg/utils" "context" + "encoding/json" + "gorm.io/gorm" ) type ConversationInterface interface { //GetUserIDExistConversation 获取拥有该会话的的用户ID列表 GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) //UpdateUserConversationFiled 更新用户该会话的属性信息 - UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error + UpdateUsersConversationFiled(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}) error //CreateConversation 创建一批新的会话 CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error //SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作 SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error //FindConversations 根据会话ID获取某个用户的多个会话 - FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error) + FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) //GetUserAllConversation 获取一个用户在服务器上所有的会话 GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) //SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性 SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error + //SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作 + SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error } type ConversationController struct { database ConversationDataBaseInterface } +func (c *ConversationController) SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error { + return c.database.SetUsersConversationFiledTx(ctx, userIDList, conversation, filedMap) +} + func NewConversationController(database ConversationDataBaseInterface) *ConversationController { return &ConversationController{database: database} } @@ -36,26 +46,26 @@ func (c *ConversationController) GetUserIDExistConversation(ctx context.Context, } func (c ConversationController) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error { - panic("implement me") + return c.database.UpdateUsersConversationFiled(ctx, UserIDList, conversationID, args) } func (c ConversationController) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error { - panic("implement me") + return c.database.CreateConversation(ctx, conversations) } func (c ConversationController) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error { - panic("implement me") + return c.database.SyncPeerUserPrivateConversationTx(ctx, conversation) } -func (c ConversationController) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error) { - panic("implement me") +func (c ConversationController) FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) { + return c.database.FindConversations(ctx, ownerUserID, conversationIDs) } func (c ConversationController) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) { - panic("implement me") + return c.database.GetUserAllConversation(ctx, ownerUserID) } func (c ConversationController) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error { - panic("implement me") + return c.database.SetUserConversations(ctx, ownerUserID, conversations) } var _ ConversationInterface = (*ConversationController)(nil) @@ -70,19 +80,69 @@ type ConversationDataBaseInterface interface { //SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作 SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error //FindConversations 根据会话ID获取某个用户的多个会话 - FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error) + FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) //GetUserAllConversation 获取一个用户在服务器上所有的会话 GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) //SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性 SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error + //SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作 + SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error } + +var _ ConversationDataBaseInterface = (*ConversationDataBase)(nil) + type ConversationDataBase struct { - db relation.Conversation - cache cache.ConversationCache + conversationDB relation.Conversation + cache cache.ConversationCache + db *gorm.DB +} + +func (c ConversationDataBase) SetUsersConversationFiledTx(ctx context.Context, userIDList []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error { + return c.db.Transaction(func(tx *gorm.DB) error { + haveUserID, err := c.conversationDB.FindUserID(ctx, userIDList, conversation.ConversationID, tx) + if err != nil { + return err + } + if len(haveUserID) > 0 { + err = c.conversationDB.UpdateByMap(ctx, haveUserID, conversation.ConversationID, filedMap, tx) + if err != nil { + return err + } + } + NotUserID := utils.DifferenceString(haveUserID, userIDList) + var cList []*relationTb.ConversationModel + for _, v := range NotUserID { + temp := new(relationTb.ConversationModel) + if err := utils.CopyStructFields(temp, conversation); err != nil { + return err + } + temp.OwnerUserID = v + cList = append(cList, temp) + } + err = c.conversationDB.Create(ctx, cList) + if err != nil { + return err + } + if len(NotUserID) > 0 { + err = c.cache.DelUsersConversationIDs(ctx, NotUserID) + if err != nil { + return err + } + } + err = c.cache.DelUsersConversation(ctx, haveUserID, conversation.ConversationID) + if err != nil { + return err + } + return nil + }) +} + +func NewConversationDataBase(db relation.Conversation, cache cache.ConversationCache) *ConversationDataBase { + return &ConversationDataBase{conversationDB: db, cache: cache} } func (c ConversationDataBase) GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) { - panic("implement me") + } func (c ConversationDataBase) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error { @@ -94,26 +154,155 @@ func (c ConversationDataBase) CreateConversation(ctx context.Context, conversati } func (c ConversationDataBase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error { - panic("implement me") + return c.db.Transaction(func(tx *gorm.DB) error { + userIDList := []string{conversation.OwnerUserID, conversation.UserID} + haveUserID, err := c.conversationDB.FindUserID(ctx, userIDList, conversation.ConversationID, tx) + if err != nil { + return err + } + filedMap := map[string]interface{}{"is_private_chat": conversation.IsPrivateChat} + if len(haveUserID) > 0 { + err = c.conversationDB.UpdateByMap(ctx, haveUserID, conversation.ConversationID, filedMap, tx) + if err != nil { + return err + } + } + + NotUserID := utils.DifferenceString(haveUserID, userIDList) + var cList []*relationTb.ConversationModel + for _, v := range NotUserID { + temp := new(relationTb.ConversationModel) + if v == conversation.UserID { + temp.OwnerUserID = conversation.UserID + temp.ConversationID = utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType) + temp.ConversationType = constant.SingleChatType + temp.UserID = conversation.OwnerUserID + temp.IsPrivateChat = conversation.IsPrivateChat + } else { + if err := utils.CopyStructFields(temp, conversation); err != nil { + return err + } + temp.OwnerUserID = v + } + cList = append(cList, temp) + } + if len(NotUserID) > 0 { + err = c.conversationDB.Create(ctx, cList) + if err != nil { + return err + } + } + err = c.cache.DelUsersConversationIDs(ctx, NotUserID) + if err != nil { + return err + } + err = c.cache.DelUsersConversation(ctx, haveUserID, conversation.ConversationID) + if err != nil { + return err + } + return nil + }) } -func (c ConversationDataBase) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error) { - panic("implement me") +func (c ConversationDataBase) FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) { + getConversation := func() (string, error) { + conversationList, err := c.conversationDB.Find(ctx, ownerUserID, conversationIDs) + if err != nil { + return "", utils.Wrap(err, "get failed") + } + bytes, err := json.Marshal(conversationList) + if err != nil { + return "", utils.Wrap(err, "Marshal failed") + } + return string(bytes), nil + } + return c.cache.GetConversations(ctx, ownerUserID, conversationIDs, getConversation) +} + +func (c ConversationDataBase) GetConversation(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error) { + getConversation := func() (string, error) { + conversationList, err := c.conversationDB.Take(ctx, ownerUserID, conversationID) + if err != nil { + return "", utils.Wrap(err, "get failed") + } + bytes, err := json.Marshal(conversationList) + if err != nil { + return "", utils.Wrap(err, "Marshal failed") + } + return string(bytes), nil + } + return c.cache.GetConversation(ctx, ownerUserID, conversationID, getConversation) } func (c ConversationDataBase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) { - panic("implement me") + getConversationIDList := func() (string, error) { + conversationIDList, err := c.conversationDB.FindUserIDAllConversationID(ctx, ownerUserID) + if err != nil { + return "", utils.Wrap(err, "getConversationIDList failed") + } + bytes, err := json.Marshal(conversationIDList) + if err != nil { + return "", utils.Wrap(err, "") + } + return string(bytes), nil + } + conversationIDList, err := c.cache.GetUserConversationIDs(ctx, ownerUserID, getConversationIDList) + if err != nil { + return nil, err + } + var conversations []*relationTb.ConversationModel + for _, conversationID := range conversationIDList { + conversation, tErr := c.GetConversation(ctx, ownerUserID, conversationID) + if tErr != nil { + return nil, utils.Wrap(tErr, "GetConversation failed") + } + conversations = append(conversations, conversation) + } + return conversations, nil } func (c ConversationDataBase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error { - panic("implement me") -} + return c.db.Transaction(func(tx *gorm.DB) error { + var conversationIDList []string + for _, conversation := range conversations { + conversationIDList = append(conversationIDList, conversation.ConversationID) + } + haveConversations, err := c.conversationDB.Find(ctx, ownerUserID, conversationIDList, tx) + if err != nil { + return err + } + if len(haveConversations) > 0 { + err = c.conversationDB.Update(ctx, conversations, tx) + if err != nil { + return err + } + } + var haveConversationID []string + for _, conversation := range haveConversations { + haveConversationID = append(haveConversationID, conversation.ConversationID) + } -func NewConversationDataBase(db relation.Conversation, cache cache.ConversationCache) *ConversationDataBase { - return &ConversationDataBase{db: db, cache: cache} + NotConversationID := utils.DifferenceString(haveConversationID, conversationIDList) + var NotConversations []*relationTb.ConversationModel + for _, conversation := range conversations { + if !utils.IsContain(conversation.ConversationID, haveConversationID) { + NotConversations = append(NotConversations, conversation) + } + } + if len(NotConversations) > 0 { + err = c.conversationDB.Create(ctx, NotConversations) + if err != nil { + return err + } + } + err = c.cache.DelUsersConversationIDs(ctx, NotConversationID) + if err != nil { + return err + } + err = c.cache.DelUserConversations(ctx, ownerUserID, haveConversationID) + if err != nil { + return err + } + return nil + }) } - -//func NewConversationController(db *gorm.DB, rdb redis.UniversalClient) ConversationInterface { -// groupController := &ConversationController{database: newGroupDatabase(db, rdb, mgoClient)} -// return groupController -//} diff --git a/pkg/common/db/relation/conversation_model_g.go b/pkg/common/db/relation/conversation_model_g.go index 37882940d..e45af0154 100644 --- a/pkg/common/db/relation/conversation_model_g.go +++ b/pkg/common/db/relation/conversation_model_g.go @@ -1,7 +1,7 @@ package relation import ( - "Open_IM/pkg/common/db/table" + "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/tracelog" "Open_IM/pkg/utils" "context" @@ -10,12 +10,15 @@ import ( type Conversation interface { TableName() string - Create(ctx context.Context, conversations []*table.ConversationModel) (err error) + Create(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error) Delete(ctx context.Context, groupIDs []string) (err error) - UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error) - Update(ctx context.Context, groups []*table.ConversationModel) (err error) - Find(ctx context.Context, groupIDs []string) (groups []*table.ConversationModel, err error) - Take(ctx context.Context, groupID string) (group *table.ConversationModel, err error) + UpdateByMap(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}, tx ...any) (err error) + Update(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error) + Find(ctx context.Context, ownerUserID string, conversationIDs []string, tx ...any) (conversations []*relation.ConversationModel, err error) + FindUserID(ctx context.Context, userIDList []string, conversationID string, tx ...any) ([]string, error) + FindUserIDAllConversationID(ctx context.Context, userID string, tx ...any) ([]string, error) + Take(ctx context.Context, userID, conversationID string, tx ...any) (conversation *relation.ConversationModel, err error) + FindConversationID(ctx context.Context, userID string, conversationIDList []string, tx ...any) (existConversationID []string, err error) } type ConversationGorm struct { DB *gorm.DB @@ -29,45 +32,69 @@ func NewConversationGorm(DB *gorm.DB) Conversation { return &ConversationGorm{DB: DB} } -func (c *ConversationGorm) Create(ctx context.Context, conversations []*table.ConversationModel) (err error) { +func (c *ConversationGorm) Create(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "conversations", conversations) }() - return utils.Wrap(getDBConn(g.DB, tx).Create(&conversations).Error, "") + return utils.Wrap(getDBConn(c.DB, tx).Create(&conversations).Error, "") } func (c *ConversationGorm) Delete(ctx context.Context, groupIDs []string) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs) }() - return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&table.ConversationModel{}).Error, "") + return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.ConversationModel{}).Error, "") } -func (c *ConversationGorm) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error) { +func (c *ConversationGorm) UpdateByMap(ctx context.Context, userIDList []string, conversationID string, args map[string]interface{}, tx ...any) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userIDList", userIDList, "conversationID", conversationID) }() - return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(g).Updates(args).Error, "") + return utils.Wrap(getDBConn(c.DB, tx).Model(&relation.ConversationModel{}).Where("owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Updates(args).Error, "") } -func (c *ConversationGorm) Update(ctx context.Context, groups []*table.ConversationModel) (err error) { +func (c *ConversationGorm) Update(ctx context.Context, conversations []*relation.ConversationModel, tx ...any) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "conversations", conversations) }() - return utils.Wrap(getDBConn(g.DB, tx).Updates(&groups).Error, "") + return utils.Wrap(getDBConn(c.DB, tx).Updates(&conversations).Error, "") } -func (c *ConversationGorm) Find(ctx context.Context, groupIDs []string) (groups []*table.ConversationModel, err error) { +func (c *ConversationGorm) Find(ctx context.Context, ownerUserID string, conversationIDs []string, tx ...any) (conversations []*relation.ConversationModel, err error) { + var newConversations []relation.ConversationModel defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "groups", conversations) }() - return groups, utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "") + err = utils.Wrap(getDBConn(c.DB, tx).Where("owner_user_id=? and conversation_id IN (?)", ownerUserID, conversationIDs).Find(&newConversations).Error, "") + for _, v := range newConversations { + v1 := v + conversations = append(conversations, &v1) + } + return conversations, err } -func (c *ConversationGorm) Take(ctx context.Context, groupID string) (group *table.ConversationModel, err error) { - group = &Group{} +func (c *ConversationGorm) Take(ctx context.Context, userID, conversationID string, tx ...any) (conversation *relation.ConversationModel, err error) { + cc := &relation.ConversationModel{} + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversation", *conversation) + }() + return cc, utils.Wrap(getDBConn(c.DB, tx).Where("conversation_id = ? And owner_user_id = ?", conversationID, userID).Take(cc).Error, "") +} +func (c *ConversationGorm) FindUserID(ctx context.Context, userIDList []string, conversationID string, tx ...any) (existUserID []string, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userIDList, "existUserID", existUserID) + }() + return existUserID, utils.Wrap(getDBConn(c.DB, tx).Where(" owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Pluck("owner_user_id", &existUserID).Error, "") +} +func (c *ConversationGorm) FindConversationID(ctx context.Context, userID string, conversationIDList []string, tx ...any) (existConversationID []string, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "existConversationIDList", existConversationID) + }() + return existConversationID, utils.Wrap(getDBConn(c.DB, tx).Where(" conversation_id IN (?) and owner_user_id=?", conversationIDList, userID).Pluck("conversation_id", &existConversationID).Error, "") +} +func (c *ConversationGorm) FindUserIDAllConversationID(ctx context.Context, userID string, tx ...any) (conversationIDList []string, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversationIDList", conversationIDList) }() - return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "") + return conversationIDList, utils.Wrap(getDBConn(c.DB, tx).Model(&relation.ConversationModel{}).Where("owner_user_id=?", userID).Pluck("conversation_id", &conversationIDList).Error, "") } From cba70e31962d4889ed24c059974af7c3a5143415 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 10 Feb 2023 21:04:22 +0800 Subject: [PATCH 03/48] Error code standardization --- go.mod | 91 +- go.sum | 77 -- .../conversation_notification.go | 9 +- .../notification}/extend_msg.notification.go | 4 +- .../notification}/extend_msg_callback.go | 2 +- .../notification}/friend_notification.go | 7 +- .../notification}/group_notification.go | 7 +- .../notification}/msg_notification.go | 7 +- .../notification}/super_group_notification.go | 7 +- .../work_moments_notification.go | 7 +- internal/rpc/auth/auth.go | 2 +- internal/rpc/conversation/conversaion.go | 5 +- internal/rpc/friend/black.go | 2 +- internal/rpc/friend/callback.go | 14 +- internal/rpc/friend/friend.go | 4 +- internal/rpc/group/callback.go | 2 +- internal/rpc/group/group.go | 46 +- internal/rpc/msg/callback.go | 65 +- internal/rpc/msg/extend_msg.go | 17 +- internal/rpc/msg/rpc_chat.go | 3 +- internal/rpc/office/office.go | 10 +- internal/rpc/user/user.go | 4 +- pkg/common/http/http_client.go | 4 +- pkg/proto/msg/msg.pb.go | 811 ++++++------------ pkg/proto/msg/msg.proto | 66 +- pkg/proto/sdkws/ws.proto | 12 +- 26 files changed, 498 insertions(+), 787 deletions(-) rename internal/{rpc/msg => common/notification}/conversation_notification.go (96%) rename internal/{rpc/msg => common/notification}/extend_msg.notification.go (98%) rename internal/{rpc/msg => common/notification}/extend_msg_callback.go (99%) rename internal/{rpc/msg => common/notification}/friend_notification.go (98%) rename internal/{rpc/msg => common/notification}/group_notification.go (99%) rename internal/{rpc/msg => common/notification}/msg_notification.go (93%) rename internal/{rpc/msg => common/notification}/super_group_notification.go (84%) rename internal/{rpc/msg => common/notification}/work_moments_notification.go (92%) diff --git a/go.mod b/go.mod index ea7280cec..5781ef0f5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module Open_IM -go 1.16 +go 1.18 require ( firebase.google.com/go v3.13.0+incompatible @@ -58,19 +58,108 @@ require ( ) require ( + cloud.google.com/go v0.105.0 // indirect + cloud.google.com/go/compute v1.13.0 // indirect + cloud.google.com/go/compute/metadata v0.2.1 // indirect + cloud.google.com/go/firestore v1.9.0 // indirect + cloud.google.com/go/iam v0.8.0 // indirect + cloud.google.com/go/longrunning v0.3.0 // indirect + cloud.google.com/go/storage v1.27.0 // indirect + github.com/KyleBanks/depth v1.2.1 // indirect + github.com/OpenIMSDK/open_log v1.0.0 // indirect + github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect + github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect + github.com/alibabacloud-go/openapi-util v0.0.9 // indirect + github.com/alibabacloud-go/tea-utils v1.3.9 // indirect + github.com/aliyun/credentials-go v1.1.2 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.11.12 // indirect + github.com/aws/smithy-go v1.12.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/eapache/go-resiliency v1.2.0 // indirect + github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect + github.com/eapache/queue v1.1.0 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/spec v0.20.6 // indirect github.com/go-openapi/swag v0.21.1 // indirect github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-sql-driver/mysql v1.6.0 // indirect + github.com/go-stack/stack v1.8.0 // indirect + github.com/go-zookeeper/zk v1.0.3 // indirect github.com/goccy/go-json v0.10.0 // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/snappy v0.0.3 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect + github.com/googleapis/gax-go/v2 v2.7.0 // indirect + github.com/hashicorp/go-uuid v1.0.2 // indirect + github.com/jcmturner/aescts/v2 v2.0.0 // indirect + github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect + github.com/jcmturner/gofork v1.0.0 // indirect + github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect + github.com/jcmturner/rpc/v2 v2.0.3 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.13.6 // indirect + github.com/klauspost/cpuid v1.3.1 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/lestrrat-go/strftime v1.0.6 // indirect + github.com/lithammer/shortuuid v3.0.0+incompatible // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-isatty v0.0.17 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/minio/md5-simd v1.1.0 // indirect + github.com/minio/sha256-simd v0.1.1 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.0.6 // indirect + github.com/pierrec/lz4 v2.6.0+incompatible // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.37.0 // indirect + github.com/prometheus/procfs v0.8.0 // indirect + github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/rs/xid v1.2.1 // indirect + github.com/tjfoc/gmsm v1.3.2 // indirect github.com/ugorji/go/codec v1.2.8 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.0.2 // indirect + github.com/xdg-go/stringprep v1.0.2 // indirect + github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect + go.etcd.io/etcd/api/v3 v3.5.6 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect + go.opencensus.io v0.24.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.5.0 // indirect + golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.4.0 // indirect + golang.org/x/text v0.6.0 // indirect + golang.org/x/time v0.1.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect gopkg.in/ini.v1 v1.66.2 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) replace github.com/Shopify/sarama => github.com/Shopify/sarama v1.29.0 diff --git a/go.sum b/go.sum index f2231afbb..436b4f460 100644 --- a/go.sum +++ b/go.sum @@ -26,7 +26,6 @@ cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+Y cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.1/go.mod h1:fs4QogzfH5n2pBXBP9vRiU+eCny7lD2vmFZy79Iuw1U= cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= @@ -39,7 +38,6 @@ cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp cloud.google.com/go/accesscontextmanager v1.4.0/go.mod h1:/Kjh7BBu/Gh83sv+K60vN9QE5NJcd80sU33vIe2IFPE= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= -cloud.google.com/go/aiplatform v1.27.0/go.mod h1:Bvxqtl40l0WImSb04d0hXFU7gDOiq9jQmorivIiWcKg= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4= cloud.google.com/go/apigateway v1.3.0/go.mod h1:89Z8Bhpmxu6AmUxuVRg/ECRGReEdiP3vQtk4Z1J9rJk= @@ -82,7 +80,6 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA= cloud.google.com/go/bigquery v1.43.0/go.mod h1:ZMQcXHsl+xmU1z36G2jNGZmKp9zNY5BUua5wDgmNCfw= -cloud.google.com/go/bigquery v1.44.0/go.mod h1:0Y33VqXTEsbamHJvJHdFmtqHvMIY28aK1+dFsvaChGc= cloud.google.com/go/billing v1.4.0/go.mod h1:g9IdKBEFlItS8bTtlrZdVLWSSdSyFUZKXNS02zKMOZY= cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s= cloud.google.com/go/billing v1.6.0/go.mod h1:WoXzguj+BeHXPbKfNWkqVtDdzORazmCjraY+vrxcyvI= @@ -145,7 +142,6 @@ cloud.google.com/go/dataqna v0.5.0/go.mod h1:90Hyk596ft3zUQ8NkFfvICSIfHFh1Bc7C4c cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/datastore v1.10.0/go.mod h1:PC5UzAmDEkAmkfaknstTYbNpgE49HAgW2J1gcgUfmdM= cloud.google.com/go/datastream v1.2.0/go.mod h1:i/uTP8/fZwgATHS/XFu0TcNUhuA0twZxxQ3EyCUQMwo= cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ= cloud.google.com/go/datastream v1.4.0/go.mod h1:h9dpzScPhDTs5noEMQVWP8Wx8AFBRyS0s8KWPx/9r0g= @@ -167,7 +163,6 @@ cloud.google.com/go/domains v0.6.0/go.mod h1:T9Rz3GasrpYk6mEGHh4rymIhjlnIuB4ofT1 cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg= cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk= cloud.google.com/go/edgecontainer v0.2.0/go.mod h1:RTmLijy+lGpQ7BXuTDa4C4ssxyXT34NIuHIgKuP4s5w= -cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU= cloud.google.com/go/essentialcontacts v1.3.0/go.mod h1:r+OnHa5jfj90qIfZDO/VztSFqbQan7HV75p8sA+mdGI= cloud.google.com/go/essentialcontacts v1.4.0/go.mod h1:8tRldvHYsmnBCHdFpvU+GL75oWiBKl80BiqlFh9tp+8= cloud.google.com/go/eventarc v1.7.0/go.mod h1:6ctpF3zTnaQCxUjHUdcfgcA1A2T309+omHZth7gDfmc= @@ -195,7 +190,6 @@ cloud.google.com/go/gkemulticloud v0.4.0/go.mod h1:E9gxVBnseLWCk24ch+P9+B2CoDFJZ cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= cloud.google.com/go/gsuiteaddons v1.3.0/go.mod h1:EUNK/J1lZEZO8yPtykKxLXI6JSVN2rg9bN8SXOa0bgM= cloud.google.com/go/gsuiteaddons v1.4.0/go.mod h1:rZK5I8hht7u7HxFQcFei0+AtfS9uSushomRlg+3ua1o= -cloud.google.com/go/iam v0.1.0/go.mod h1:vcUNEa0pEm0qRVpmWepWaFMIAI8/hjB9mO8rNCJtF6c= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHDMFMc= @@ -208,7 +202,6 @@ cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+ cloud.google.com/go/ids v1.2.0/go.mod h1:5WXvp4n25S0rA/mQWAg1YEEBBq6/s+7ml1RDCW1IrcY= cloud.google.com/go/iot v1.3.0/go.mod h1:r7RGh2B61+B8oz0AGE+J72AhA0G7tdXItODWsaA2oLs= cloud.google.com/go/iot v1.4.0/go.mod h1:dIDxPOn0UvNDUMD8Ger7FIaTuvMkj+aGk94RPP0iV+g= -cloud.google.com/go/kms v1.4.0/go.mod h1:fajBHndQ+6ubNw6Ss2sSd+SWvjL26RNo/dr7uxsnnOA= cloud.google.com/go/kms v1.5.0/go.mod h1:QJS2YY0eJGBg3mnDfuaCyLauWwBJiHRboYxJ++1xJNg= cloud.google.com/go/kms v1.6.0/go.mod h1:Jjy850yySiasBUDi6KFUwUv2n1+o7QZFyuUJg6OgjA0= cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= @@ -217,13 +210,11 @@ cloud.google.com/go/language v1.7.0/go.mod h1:DJ6dYN/W+SQOjF8e1hLQXMF21AkH2w9wiP cloud.google.com/go/language v1.8.0/go.mod h1:qYPVHf7SPoNNiCL2Dr0FfEFNil1qi3pQEyygwpgVKB8= cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= -cloud.google.com/go/logging v1.6.1/go.mod h1:5ZO0mHHbvm8gEmeEUHrmDlTDSu5imF6MUP9OfilNXBw= cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs= cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc= cloud.google.com/go/managedidentities v1.3.0/go.mod h1:UzlW3cBOiPrzucO5qWkNkh0w33KFtBJU281hacNvsdE= cloud.google.com/go/managedidentities v1.4.0/go.mod h1:NWSBYbEMgqmbZsLIyKvxrYbtqOsxY1ZrGM+9RgDqInM= -cloud.google.com/go/maps v0.1.0/go.mod h1:BQM97WGyfw9FWEmQMpZ5T6cpovXXSd1cGmFma94eubI= cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= @@ -272,9 +263,6 @@ cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2k cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/pubsub v1.26.0/go.mod h1:QgBH3U/jdJy/ftjPhTkyXNj543Tin1pRYcdcPRnFIRI= -cloud.google.com/go/pubsub v1.27.1/go.mod h1:hQN39ymbV9geqBnfQq6Xf63yNhUAhv9CZhzp5O6qsW0= -cloud.google.com/go/pubsublite v1.5.0/go.mod h1:xapqNQ1CuLfGi23Yda/9l4bBCKz/wC3KIJ5gKcxveZg= cloud.google.com/go/recaptchaenterprise v1.3.1/go.mod h1:OdD+q+y4XGeAlxRaMn1Y7/GveP6zmq76byL6tjPE7d4= cloud.google.com/go/recaptchaenterprise/v2 v2.1.0/go.mod h1:w9yVqajwroDNTfGuhmOjPDN//rZGySaf6PtFVcSCa7o= cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk= @@ -329,7 +317,6 @@ cloud.google.com/go/serviceusage v1.3.0/go.mod h1:Hya1cozXM4SeSKTAgGXgj97GlqUvF5 cloud.google.com/go/serviceusage v1.4.0/go.mod h1:SB4yxXSaYVuUBYUml6qklyONXNLt83U0Rb+CXyhjEeU= cloud.google.com/go/shell v1.3.0/go.mod h1:VZ9HmRjZBsjLGXusm7K5Q5lzzByZmJHf1d0IWHEN5X4= cloud.google.com/go/shell v1.4.0/go.mod h1:HDxPzZf3GkDdhExzD/gs8Grqk+dmYcEjGShZgYa9URw= -cloud.google.com/go/spanner v1.41.0/go.mod h1:MLYDBJR/dY4Wt7ZaMIQ7rXOTLjYrmxLE/5ve9vFfWos= cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM= cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ= cloud.google.com/go/speech v1.8.0/go.mod h1:9bYIl1/tjsAnMgKGHKmBZzXKEkGgtU+MpdDPTE9f7y0= @@ -370,7 +357,6 @@ cloud.google.com/go/vision/v2 v2.4.0/go.mod h1:VtI579ll9RpVTrdKdkMzckdnwMyX2JILb cloud.google.com/go/vision/v2 v2.5.0/go.mod h1:MmaezXOOE+IWa+cS7OhRRLK2cNv1ZL98zhqFFZaaH2E= cloud.google.com/go/vmmigration v1.2.0/go.mod h1:IRf0o7myyWFSmVR1ItrBSFLFD/rJkfDCUTO4vLlJvsE= cloud.google.com/go/vmmigration v1.3.0/go.mod h1:oGJ6ZgGPQOFdjHuocGcLqX4lc98YQ7Ygq8YQwHh9A7g= -cloud.google.com/go/vmwareengine v0.1.0/go.mod h1:RsdNEf/8UDvKllXhMz5J40XxDrNJNN4sagiox+OI208= cloud.google.com/go/vpcaccess v1.4.0/go.mod h1:aQHVbTWDYUR1EbTApSVvMq1EnT57ppDmQzZ3imqIk4w= cloud.google.com/go/vpcaccess v1.5.0/go.mod h1:drmg4HLk9NkZpGfCmZ3Tz0Bwnm2+DKqViEpeEpOq0m8= cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE= @@ -397,7 +383,6 @@ github.com/OpenIMSDK/openKeeper v0.9.7 h1:oWPAsXAHpMpZh8NPB9B8FktVfxk1Ec8tQPdxhz github.com/OpenIMSDK/openKeeper v0.9.7/go.mod h1:RvyRXEcvWbonkmHLtT8KxGSCNlXY7OfDohhu53E6INU= github.com/OpenIMSDK/open_log v1.0.0 h1:ZQ908aWgPqfHOfkQ/oFSV20AZdRwPw+sZjC/sAPd5cA= github.com/OpenIMSDK/open_log v1.0.0/go.mod h1:qWvqF4iT2qBAP1eGGbinc0aAng1Y25X8A9Si1WS3oB4= -github.com/OpenIMSDK/open_utils v1.0.1/go.mod h1:PPRayByXnfu8PR5Xv9wzUMBrm1BV3y7s29GGg8ae47s= github.com/OpenIMSDK/open_utils v1.0.8 h1:IopxWgJwEF5ZAPsRuiZZOfcxNOQOCt/p8VDENcHN9r4= github.com/OpenIMSDK/open_utils v1.0.8/go.mod h1:FLoaQblWUVKQgqt2LrNzfSZLT6D3DICBn1kcOMDLUOI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -464,7 +449,6 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.16.9/go.mod h1:O1IvkYxr+39hRf960Us6j github.com/aws/smithy-go v1.12.0 h1:gXpeZel/jPoWQ7OEmLIgCUnhkFftqNfwWUwAHSlp1v0= github.com/aws/smithy-go v1.12.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -472,8 +456,6 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= @@ -529,9 +511,7 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/gzip v0.0.5 h1:mhnVU32YnnBh2LPH2iqRqsA/eR7SAqRaD388jL2s/j0= github.com/gin-contrib/gzip v0.0.5/go.mod h1:OPIK6HR0Um2vNmBUTlayD7qle4yVVRZT0PyhdUigrKk= @@ -539,7 +519,6 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= -github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY= github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -576,7 +555,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= @@ -586,11 +564,8 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-zookeeper/zk v1.0.3 h1:7M2kwOsc//9VeeFiPtf+uSJlVpU66x9Ba5+8XK7/TDg= github.com/go-zookeeper/zk v1.0.3/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= -github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -670,12 +645,10 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -708,7 +681,6 @@ github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2I github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= @@ -733,7 +705,6 @@ github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= -github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -751,7 +722,6 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= @@ -785,8 +755,6 @@ github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= @@ -814,29 +782,17 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/olivere/elastic/v7 v7.0.23 h1:b7tjMogDMhf2CisGI+L02LXLVa0ZyE82Z15XfW1e8t8= github.com/olivere/elastic/v7 v7.0.23/go.mod h1:OuWmD2DiuYhddWegBKPWQuelVKBLrW0fa/VUYgxuGTY= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= -github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= @@ -893,7 +849,6 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= @@ -932,10 +887,7 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV github.com/tjfoc/gmsm v1.3.2 h1:7JVkAn5bvUJ7HtU08iW6UiD+UTmJTIToHCfeFzkcCxM= github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= -github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0= github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= @@ -956,15 +908,11 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.etcd.io/etcd/api/v3 v3.5.5/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8= go.etcd.io/etcd/api/v3 v3.5.6 h1:Cy2qx3npLcYqTKqGJzMypnMv2tiRyifZJ17BlWIWA7A= go.etcd.io/etcd/api/v3 v3.5.6/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8= -go.etcd.io/etcd/client/pkg/v3 v3.5.5/go.mod h1:ggrwbk069qxpKPq8/FKkQ3Xq9y39kbFR4LnKszpRXeQ= go.etcd.io/etcd/client/pkg/v3 v3.5.6 h1:TXQWYceBKqLp4sa87rcPs11SXxUA/mHwH975v+BDvLU= go.etcd.io/etcd/client/pkg/v3 v3.5.6/go.mod h1:ggrwbk069qxpKPq8/FKkQ3Xq9y39kbFR4LnKszpRXeQ= -go.etcd.io/etcd/client/v3 v3.5.5/go.mod h1:aApjR4WGlSumpnJ2kloS75h6aHUmAyaPLjHMxpc7E7c= go.etcd.io/etcd/client/v3 v3.5.6 h1:coLs69PWCXE9G4FKquzNaSHrRyMCAXwF+IX1tAPVO8E= go.etcd.io/etcd/client/v3 v3.5.6/go.mod h1:f6GRinRMCsFVv9Ht42EyY7nfsVGwrNO0WEoS2pRKzQk= go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4= @@ -983,7 +931,6 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= @@ -1001,7 +948,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= @@ -1018,7 +964,6 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY= golang.org/x/image v0.3.0 h1:HTDXbdK9bjfSWkPzDJIw89W8CAtfFGduujWs33NLLsg= golang.org/x/image v0.3.0/go.mod h1:fXd9211C/0VTlYuAcOhW8dY/RtEJqODXOWBDpmYBf+A= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1044,12 +989,10 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1072,7 +1015,6 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -1087,11 +1029,9 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -1152,7 +1092,6 @@ golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1163,11 +1102,8 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1193,7 +1129,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1215,7 +1150,6 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1242,7 +1176,6 @@ golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXR golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= -golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1260,7 +1193,6 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1311,7 +1243,6 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= @@ -1321,7 +1252,6 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1496,10 +1426,7 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz google.golang.org/genproto v0.0.0-20221024153911-1573dae28c9c/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= -google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221117204609-8f9c96812029/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1538,7 +1465,6 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.52.3 h1:pf7sOysg4LdgBqduXveGKrcEwbStiK2rtfghdzlUYDQ= google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1566,15 +1492,12 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/rpc/msg/conversation_notification.go b/internal/common/notification/conversation_notification.go similarity index 96% rename from internal/rpc/msg/conversation_notification.go rename to internal/common/notification/conversation_notification.go index 2b90809e7..4d0a615ad 100644 --- a/internal/rpc/msg/conversation_notification.go +++ b/internal/common/notification/conversation_notification.go @@ -1,6 +1,7 @@ -package msg +package notification import ( + "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" @@ -25,7 +26,7 @@ func SetConversationNotification(operationID, sendID, recvID string, contentType EmitDefaults: false, } tips.JsonDetail, _ = marshaler.MarshalToString(m) - var n NotificationMsg + var n msg.NotificationMsg n.SendID = sendID n.RecvID = recvID n.ContentType = int32(contentType) @@ -37,7 +38,7 @@ func SetConversationNotification(operationID, sendID, recvID string, contentType log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + msg.Notification(&n) } // SetPrivate调用 @@ -70,7 +71,7 @@ func ConversationChangeNotification(ctx context.Context, userID string) { SetConversationNotification(operationID, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) } -//会话未读数同步 +// 会话未读数同步 func ConversationUnreadChangeNotification(operationID, userID, conversationID string, updateUnreadCountTime int64) { log.NewInfo(operationID, utils.GetSelfFuncName()) ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{ diff --git a/internal/rpc/msg/extend_msg.notification.go b/internal/common/notification/extend_msg.notification.go similarity index 98% rename from internal/rpc/msg/extend_msg.notification.go rename to internal/common/notification/extend_msg.notification.go index 7f5fe30dd..03e47f1be 100644 --- a/internal/rpc/msg/extend_msg.notification.go +++ b/internal/common/notification/extend_msg.notification.go @@ -1,11 +1,9 @@ -package msg +package notification import ( - "Open_IM/pkg/api_struct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" - "Open_IM/pkg/getcdv3" "Open_IM/pkg/proto/msg" open_im_sdk "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" diff --git a/internal/rpc/msg/extend_msg_callback.go b/internal/common/notification/extend_msg_callback.go similarity index 99% rename from internal/rpc/msg/extend_msg_callback.go rename to internal/common/notification/extend_msg_callback.go index ceb65c3fc..39958e4f0 100644 --- a/internal/rpc/msg/extend_msg_callback.go +++ b/internal/common/notification/extend_msg_callback.go @@ -1,4 +1,4 @@ -package msg +package notification import ( cbApi "Open_IM/pkg/callback_struct" diff --git a/internal/rpc/msg/friend_notification.go b/internal/common/notification/friend_notification.go similarity index 98% rename from internal/rpc/msg/friend_notification.go rename to internal/common/notification/friend_notification.go index 684e277ed..0dd4736c4 100644 --- a/internal/rpc/msg/friend_notification.go +++ b/internal/common/notification/friend_notification.go @@ -1,7 +1,8 @@ -package msg +package notification import ( "Open_IM/internal/common/check" + "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" @@ -76,7 +77,7 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in return } - var n NotificationMsg + var n msg.NotificationMsg n.SendID = fromUserID n.RecvID = toUserID n.ContentType = contentType @@ -88,7 +89,7 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + msg.Notification(&n) } func FriendApplicationAddNotification(ctx context.Context, req *pbFriend.AddFriendReq) { diff --git a/internal/rpc/msg/group_notification.go b/internal/common/notification/group_notification.go similarity index 99% rename from internal/rpc/msg/group_notification.go rename to internal/common/notification/group_notification.go index 5915f8916..30cd5f5f0 100644 --- a/internal/rpc/msg/group_notification.go +++ b/internal/common/notification/group_notification.go @@ -1,6 +1,7 @@ -package msg +package notification import ( + "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" @@ -181,7 +182,7 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv return } - var n NotificationMsg + var n msg.NotificationMsg n.SendID = sendID if groupID != "" { n.RecvID = groupID @@ -206,7 +207,7 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + msg.Notification(&n) } // 创建群后调用 diff --git a/internal/rpc/msg/msg_notification.go b/internal/common/notification/msg_notification.go similarity index 93% rename from internal/rpc/msg/msg_notification.go rename to internal/common/notification/msg_notification.go index 212fc4ff9..f6e0a77f4 100644 --- a/internal/rpc/msg/msg_notification.go +++ b/internal/common/notification/msg_notification.go @@ -1,6 +1,7 @@ -package msg +package notification import ( + "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" open_im_sdk "Open_IM/pkg/proto/sdkws" @@ -31,7 +32,7 @@ func MessageNotification(operationID, sendID, recvID string, contentType int32, } tips.JsonDetail, _ = marshaler.MarshalToString(m) - var n NotificationMsg + var n msg.NotificationMsg n.SendID = sendID n.RecvID = recvID n.ContentType = contentType @@ -43,5 +44,5 @@ func MessageNotification(operationID, sendID, recvID string, contentType int32, log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + msg.Notification(&n) } diff --git a/internal/rpc/msg/super_group_notification.go b/internal/common/notification/super_group_notification.go similarity index 84% rename from internal/rpc/msg/super_group_notification.go rename to internal/common/notification/super_group_notification.go index 062b44e47..19d08dd98 100644 --- a/internal/rpc/msg/super_group_notification.go +++ b/internal/common/notification/super_group_notification.go @@ -1,6 +1,7 @@ -package msg +package notification import ( + "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" //sdk "Open_IM/pkg/proto/sdkws" @@ -10,7 +11,7 @@ import ( ) func SuperGroupNotification(operationID, sendID, recvID string) { - n := &NotificationMsg{ + n := &msg.NotificationMsg{ SendID: sendID, RecvID: recvID, MsgFrom: constant.SysMsgType, @@ -19,5 +20,5 @@ func SuperGroupNotification(operationID, sendID, recvID string) { OperationID: operationID, } log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content)) - Notification(n) + msg.Notification(n) } diff --git a/internal/rpc/msg/work_moments_notification.go b/internal/common/notification/work_moments_notification.go similarity index 92% rename from internal/rpc/msg/work_moments_notification.go rename to internal/common/notification/work_moments_notification.go index 8af00c217..271fe23e6 100644 --- a/internal/rpc/msg/work_moments_notification.go +++ b/internal/common/notification/work_moments_notification.go @@ -1,6 +1,7 @@ -package msg +package notification import ( + "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" pbOffice "Open_IM/pkg/proto/office" @@ -24,7 +25,7 @@ func WorkMomentNotification(operationID, sendID, recvID string, m proto.Message) EmitDefaults: false, } tips.JsonDetail, _ = marshaler.MarshalToString(m) - n := &NotificationMsg{ + n := &msg.NotificationMsg{ SendID: sendID, RecvID: recvID, MsgFrom: constant.UserMsgType, @@ -38,5 +39,5 @@ func WorkMomentNotification(operationID, sendID, recvID string, m proto.Message) return } log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content)) - Notification(n) + msg.Notification(n) } diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index c6df00f05..dc6dd128e 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -2,7 +2,7 @@ package auth import ( "Open_IM/internal/common/check" - "Open_IM/internal/common/rpc_server" + "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go index 54d5a0380..51cb3b736 100644 --- a/internal/rpc/conversation/conversaion.go +++ b/internal/rpc/conversation/conversaion.go @@ -2,18 +2,15 @@ package conversation import ( "Open_IM/internal/common/check" - chat "Open_IM/internal/rpc/msg" + chat "Open_IM/internal/common/notification" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/controller" "Open_IM/pkg/common/db/relation" "Open_IM/pkg/common/db/table" - "Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/common/log" promePkg "Open_IM/pkg/common/prometheus" - "Open_IM/pkg/getcdv3" pbConversation "Open_IM/pkg/proto/conversation" - pbUser "Open_IM/pkg/proto/user" "Open_IM/pkg/utils" "context" "github.com/dtm-labs/rockscache" diff --git a/internal/rpc/friend/black.go b/internal/rpc/friend/black.go index 5d99b8f71..37485e854 100644 --- a/internal/rpc/friend/black.go +++ b/internal/rpc/friend/black.go @@ -3,7 +3,7 @@ package friend import ( "Open_IM/internal/common/check" "Open_IM/internal/common/convert" - chat "Open_IM/internal/rpc/msg" + chat "Open_IM/internal/common/notification" "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" diff --git a/internal/rpc/friend/callback.go b/internal/rpc/friend/callback.go index 983a5da54..a894b1ddb 100644 --- a/internal/rpc/friend/callback.go +++ b/internal/rpc/friend/callback.go @@ -1,13 +1,13 @@ package friend import ( - cbApi "Open_IM/pkg/callback_struct" + cbapi "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" "Open_IM/pkg/common/log" "Open_IM/pkg/common/tracelog" - pbFriend "Open_IM/pkg/proto/friend" + pbfriend "Open_IM/pkg/proto/friend" "context" //"Open_IM/pkg/proto/msg" @@ -15,7 +15,7 @@ import ( http2 "net/http" ) -func callbackBeforeAddFriendV1(ctx context.Context, req *pbFriend.AddFriendReq) error { +func callbackBeforeAddFriendV1(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error { resp := callbackBeforeAddFriend(ctx, req) if resp.ErrCode != 0 { return (&constant.ErrInfo{ @@ -26,20 +26,20 @@ func callbackBeforeAddFriendV1(ctx context.Context, req *pbFriend.AddFriendReq) return nil } -func callbackBeforeAddFriend(ctx context.Context, req *pbFriend.AddFriendReq) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: tracelog.GetOperationID(ctx)} +func callbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) cbapi.CommonCallbackResp { + callbackResp := cbapi.CommonCallbackResp{OperationID: tracelog.GetOperationID(ctx)} if !config.Config.Callback.CallbackBeforeAddFriend.Enable { return callbackResp } - commonCallbackReq := &cbApi.CallbackBeforeAddFriendReq{ + commonCallbackReq := &cbapi.CallbackBeforeAddFriendReq{ CallbackCommand: constant.CallbackBeforeAddFriendCommand, FromUserID: req.FromUserID, ToUserID: req.ToUserID, ReqMsg: req.ReqMsg, OperationID: tracelog.GetOperationID(ctx), } - resp := &cbApi.CallbackBeforeAddFriendResp{ + resp := &cbapi.CallbackBeforeAddFriendResp{ CommonCallbackResp: &callbackResp, } //utils.CopyStructFields(req, msg.MsgData) diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 00704381e..218ed13a7 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -3,8 +3,8 @@ package friend import ( "Open_IM/internal/common/check" "Open_IM/internal/common/convert" - "Open_IM/internal/common/rpc_server" - chat "Open_IM/internal/rpc/msg" + chat "Open_IM/internal/common/notification" + "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/controller" diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index b437e8702..e47c00bd6 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -1,7 +1,7 @@ package group import ( - cbApi "Open_IM/pkg/callback_struct" + cbApi "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/table/relation" diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 9bdb77165..ce949c4d4 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -2,7 +2,7 @@ package group import ( "Open_IM/internal/common/network" - chat "Open_IM/internal/rpc/msg" + "Open_IM/internal/common/notification" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" @@ -198,11 +198,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if req.GroupInfo.GroupType == constant.SuperGroup { go func() { for _, userID := range userIDs { - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } }() } else { - chat.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs) + notification.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs) } return resp, nil } @@ -299,7 +299,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, request := range requests { - chat.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ + notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ GroupID: request.GroupID, ReqMessage: request.ReqMsg, JoinSource: request.JoinSource, @@ -315,7 +315,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, userID := range req.InvitedUserIDs { - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } } else { opUserID := tracelog.GetOpUserID(ctx) @@ -336,7 +336,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil { return nil, err } - chat.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) + notification.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) } return resp, nil } @@ -413,7 +413,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou } go func() { for _, userID := range req.KickedUserIDs { - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } }() } else { @@ -453,7 +453,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou if err := s.GroupInterface.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil { return nil, err } - chat.MemberKickedNotification(req, req.KickedUserIDs) + notification.MemberKickedNotification(req, req.KickedUserIDs) } return resp, nil } @@ -623,10 +623,10 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup return nil, err } if req.HandleResult == constant.GroupResponseAgree { - chat.GroupApplicationAcceptedNotification(req) - chat.MemberEnterNotification(req) + notification.GroupApplicationAcceptedNotification(req) + notification.MemberEnterNotification(req) } else if req.HandleResult == constant.GroupResponseRefuse { - chat.GroupApplicationRejectedNotification(req) + notification.GroupApplicationRejectedNotification(req) } return resp, nil } @@ -663,7 +663,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil { return nil, err } - chat.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) + notification.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) return resp, nil } groupRequest := relationTb.GroupRequestModel{ @@ -676,7 +676,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil { return nil, err } - chat.JoinGroupApplicationNotification(ctx, req) + notification.JoinGroupApplicationNotification(ctx, req) return resp, nil } @@ -690,13 +690,13 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil { return nil, err } - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) } else { _, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx)) if err != nil { return nil, err } - chat.MemberQuitNotification(req) + notification.MemberQuitNotification(req) } return resp, nil } @@ -730,7 +730,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf if err != nil { return nil, err } - chat.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) + notification.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) if req.GroupInfoForSet.Notification != "" { GroupNotification(ctx, group.GroupID) } @@ -780,7 +780,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans if err := s.GroupInterface.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID, newOwner.RoleLevel); err != nil { return nil, err } - chat.GroupOwnerTransferredNotification(req) + notification.GroupOwnerTransferredNotification(req) return resp, nil } @@ -912,7 +912,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou return nil, err } } else { - chat.GroupDismissedNotification(req) + notification.GroupDismissedNotification(req) } return resp, nil } @@ -936,7 +936,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - chat.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds) + notification.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds) return resp, nil } @@ -959,7 +959,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - chat.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID) + notification.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID) return resp, nil } @@ -971,7 +971,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil { return nil, err } - chat.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + notification.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) return resp, nil } @@ -983,7 +983,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil { return nil, err } - chat.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + notification.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) return resp, nil } @@ -1060,7 +1060,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr return nil, err } for _, member := range req.Members { - chat.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID) + notification.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID) } return resp, nil } diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index ea742e189..3ebddc9ef 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -1,8 +1,7 @@ package msg import ( - cbApi "Open_IM/pkg/callback_struct" - "Open_IM/pkg/common/callback" + cbapi "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" @@ -12,8 +11,8 @@ import ( http2 "net/http" ) -func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq { - req := cbApi.CommonCallbackReq{ +func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbapi.CommonCallbackReq { + req := cbapi.CommonCallbackReq{ SendID: msg.MsgData.SendID, ServerMsgID: msg.MsgData.ServerMsgID, ClientMsgID: msg.MsgData.ClientMsgID, @@ -27,35 +26,35 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq CreateTime: msg.MsgData.CreateTime, AtUserIDList: msg.MsgData.AtUserIDList, SenderFaceURL: msg.MsgData.SenderFaceURL, - Content: callback.GetContent(msg.MsgData), + Content: utils.GetContent(msg.MsgData), Seq: msg.MsgData.Seq, Ex: msg.MsgData.Ex, } return req } -func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID} +func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { + callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable { return callbackResp } log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) commonCallbackReq := copyCallbackCommonReqStruct(msg) commonCallbackReq.CallbackCommand = constant.CallbackBeforeSendSingleMsgCommand - req := cbApi.CallbackBeforeSendSingleMsgReq{ + req := cbapi.CallbackBeforeSendSingleMsgReq{ CommonCallbackReq: commonCallbackReq, RecvID: msg.MsgData.RecvID, } - resp := &cbApi.CallbackBeforeSendSingleMsgResp{ + resp := &cbapi.CallbackBeforeSendSingleMsgResp{ CommonCallbackResp: &callbackResp, } //utils.CopyStructFields(req, msg.MsgData) defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSendSingleMsgCommand, - req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackTimeOut, &config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackFailedContinue); err != nil { + req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrMsg = err.Error() - if !config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackFailedContinue { + if !*config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackFailedContinue { callbackResp.ActionCode = constant.ActionForbidden return callbackResp } else { @@ -66,22 +65,22 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackRes return callbackResp } -func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID} +func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { + callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable { return callbackResp } log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) commonCallbackReq := copyCallbackCommonReqStruct(msg) commonCallbackReq.CallbackCommand = constant.CallbackAfterSendSingleMsgCommand - req := cbApi.CallbackAfterSendSingleMsgReq{ + req := cbapi.CallbackAfterSendSingleMsgReq{ CommonCallbackReq: commonCallbackReq, RecvID: msg.MsgData.RecvID, } - resp := &cbApi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: &callbackResp} + resp := &cbapi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: &callbackResp} defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendSingleMsgCommand, - req, resp, config.Config.Callback.CallbackAfterSendSingleMsg.CallbackTimeOut, &config.Config.Callback.CallbackAfterSendSingleMsg.CallbackFailedContinue); err != nil { + req, resp, config.Config.Callback.CallbackAfterSendSingleMsg); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrMsg = err.Error() return callbackResp @@ -89,25 +88,25 @@ func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp return callbackResp } -func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID} +func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { + callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackBeforeSendGroupMsg.Enable { return callbackResp } log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) commonCallbackReq := copyCallbackCommonReqStruct(msg) commonCallbackReq.CallbackCommand = constant.CallbackBeforeSendGroupMsgCommand - req := cbApi.CallbackAfterSendGroupMsgReq{ + req := cbapi.CallbackAfterSendGroupMsgReq{ CommonCallbackReq: commonCallbackReq, GroupID: msg.MsgData.GroupID, } - resp := &cbApi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: &callbackResp} + resp := &cbapi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: &callbackResp} defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSendGroupMsgCommand, - req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackTimeOut, &config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue); err != nil { + req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrMsg = err.Error() - if !config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue { + if !*config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue { callbackResp.ActionCode = constant.ActionForbidden return callbackResp } else { @@ -118,22 +117,22 @@ func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp return callbackResp } -func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID} +func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { + callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable { return callbackResp } log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) commonCallbackReq := copyCallbackCommonReqStruct(msg) commonCallbackReq.CallbackCommand = constant.CallbackAfterSendGroupMsgCommand - req := cbApi.CallbackAfterSendGroupMsgReq{ + req := cbapi.CallbackAfterSendGroupMsgReq{ CommonCallbackReq: commonCallbackReq, GroupID: msg.MsgData.GroupID, } - resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: &callbackResp} + resp := &cbapi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: &callbackResp} defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendGroupMsgCommand, req, resp, - config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut, nil); err != nil { + config.Config.Callback.CallbackAfterSendGroupMsg); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrMsg = err.Error() return callbackResp @@ -141,24 +140,24 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp return callbackResp } -func callbackMsgModify(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp { +func callbackMsgModify(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) - callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID} + callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackMsgModify.Enable || msg.MsgData.ContentType != constant.Text { return callbackResp } commonCallbackReq := copyCallbackCommonReqStruct(msg) commonCallbackReq.CallbackCommand = constant.CallbackMsgModifyCommand - req := cbApi.CallbackMsgModifyCommandReq{ + req := cbapi.CallbackMsgModifyCommandReq{ CommonCallbackReq: commonCallbackReq, } - resp := &cbApi.CallbackMsgModifyCommandResp{CommonCallbackResp: &callbackResp} + resp := &cbapi.CallbackMsgModifyCommandResp{CommonCallbackResp: &callbackResp} defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackMsgModifyCommand, req, resp, - config.Config.Callback.CallbackMsgModify.CallbackTimeOut, &config.Config.Callback.CallbackMsgModify.CallbackFailedContinue); err != nil { + config.Config.Callback.CallbackMsgModify); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrMsg = err.Error() - if !config.Config.Callback.CallbackMsgModify.CallbackFailedContinue { + if !*config.Config.Callback.CallbackMsgModify.CallbackFailedContinue { callbackResp.ActionCode = constant.ActionForbidden return callbackResp } else { diff --git a/internal/rpc/msg/extend_msg.go b/internal/rpc/msg/extend_msg.go index 2bb249650..043ff67b7 100644 --- a/internal/rpc/msg/extend_msg.go +++ b/internal/rpc/msg/extend_msg.go @@ -1,6 +1,7 @@ package msg import ( + "Open_IM/internal/common/notification" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db" "Open_IM/pkg/common/log" @@ -18,7 +19,7 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S var rResp msg.SetMessageReactionExtensionsResp rResp.ClientMsgID = req.ClientMsgID rResp.MsgFirstModifyTime = req.MsgFirstModifyTime - callbackResp := callbackSetMessageReactionExtensions(req) + callbackResp := notification.callbackSetMessageReactionExtensions(req) if callbackResp.ActionCode != constant.ActionAllow || callbackResp.ErrCode != 0 { rResp.ErrCode = int32(callbackResp.ErrCode) rResp.ErrMsg = callbackResp.ErrMsg @@ -41,7 +42,7 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S } rResp.MsgFirstModifyTime = callbackResp.MsgFirstModifyTime rResp.Result = callbackResp.ResultReactionExtensionList - ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, isHistory, false) + notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, isHistory, false) return &rResp, nil } for _, v := range callbackResp.ResultReactionExtensionList { @@ -187,12 +188,12 @@ func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.S } if !isExists { if !req.IsReact { - ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, true, true) + notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, true, true) } else { - ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, false) + notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, false) } } else { - ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, true) + notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, true) } log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String()) return &rResp, nil @@ -278,7 +279,7 @@ func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.M func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) { log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String()) var rResp msg.DeleteMessageListReactionExtensionsResp - callbackResp := callbackDeleteMessageReactionExtensions(req) + callbackResp := notification.callbackDeleteMessageReactionExtensions(req) if callbackResp.ActionCode != constant.ActionAllow || callbackResp.ErrCode != 0 { rResp.ErrCode = int32(callbackResp.ErrCode) rResp.ErrMsg = callbackResp.ErrMsg @@ -294,7 +295,7 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms //if ExternalExtension if req.IsExternalExtensions { rResp.Result = callbackResp.ResultReactionExtensionList - ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, false) + notification.ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, false) return &rResp, nil } @@ -418,7 +419,7 @@ func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *ms } } - ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, isExists) + notification.ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, isExists) log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String()) return &rResp, nil } diff --git a/internal/rpc/msg/rpc_chat.go b/internal/rpc/msg/rpc_chat.go index 699f539a5..6f65ca1ed 100644 --- a/internal/rpc/msg/rpc_chat.go +++ b/internal/rpc/msg/rpc_chat.go @@ -1,6 +1,7 @@ package msg import ( + "Open_IM/internal/common/notification" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db" @@ -152,7 +153,7 @@ func (rpc *rpcChat) runCh() { continue } if len(unexistSeqList) > 0 { - DeleteMessageNotification(msg.OpUserID, msg.UserID, unexistSeqList, msg.OperationID) + notification.DeleteMessageNotification(msg.OpUserID, msg.UserID, unexistSeqList, msg.OperationID) } } } diff --git a/internal/rpc/office/office.go b/internal/rpc/office/office.go index 0f51d2c79..b4421e573 100644 --- a/internal/rpc/office/office.go +++ b/internal/rpc/office/office.go @@ -1,11 +1,11 @@ package office import ( + "Open_IM/internal/common/notification" "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db" - "Open_IM/pkg/common/db/mongo" "Open_IM/pkg/common/db/mysql_model/im_mysql_model" imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" rocksCache "Open_IM/pkg/common/db/rocks_cache" @@ -437,7 +437,7 @@ func (s *officeServer) CreateOneWorkMoment(_ context.Context, req *pbOffice.Crea UserName: createUser.Nickname, CreateTime: workMoment.CreateTime, } - msg.WorkMomentSendNotification(req.OperationID, atUser.UserID, workMomentNotificationMsg) + notification.WorkMomentSendNotification(req.OperationID, atUser.UserID, workMomentNotificationMsg) } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil @@ -546,7 +546,7 @@ func (s *officeServer) LikeOneWorkMoment(_ context.Context, req *pbOffice.LikeOn } // send notification if like && workMoment.UserID != req.UserID { - msg.WorkMomentSendNotification(req.OperationID, workMoment.UserID, workMomentNotificationMsg) + notification.WorkMomentSendNotification(req.OperationID, workMoment.UserID, workMomentNotificationMsg) } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil @@ -599,10 +599,10 @@ func (s *officeServer) CommentOneWorkMoment(_ context.Context, req *pbOffice.Com } log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "msg: ", *workMomentNotificationMsg) if req.UserID != workMoment.UserID { - msg.WorkMomentSendNotification(req.OperationID, workMoment.UserID, workMomentNotificationMsg) + notification.WorkMomentSendNotification(req.OperationID, workMoment.UserID, workMomentNotificationMsg) } if req.ReplyUserID != "" && req.ReplyUserID != workMoment.UserID && req.ReplyUserID != req.UserID { - msg.WorkMomentSendNotification(req.OperationID, req.ReplyUserID, workMomentNotificationMsg) + notification.WorkMomentSendNotification(req.OperationID, req.ReplyUserID, workMomentNotificationMsg) } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index a7c50d823..5fd12da67 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -2,8 +2,8 @@ package user import ( "Open_IM/internal/common/convert" - "Open_IM/internal/common/rpc_server" - chat "Open_IM/internal/rpc/msg" + chat "Open_IM/internal/common/notification" + "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/controller" diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index 5d75fe54f..dcf3de0d5 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -7,7 +7,7 @@ package http import ( - cbApi "Open_IM/pkg/callback_struct" + cbapi "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "bytes" @@ -59,7 +59,7 @@ func Post(url string, data interface{}, timeOutSecond int) (content []byte, err return result, nil } -func CallBackPostReturn(url, callbackCommand string, input interface{}, output cbApi.CallbackResp, callbackConfig config.CallBackConfig) error { +func CallBackPostReturn(url, callbackCommand string, input interface{}, output cbapi.CallbackResp, callbackConfig config.CallBackConfig) error { v := urlLib.Values{} v.Set("callbackCommand", callbackCommand) url = url + "?" + v.Encode() diff --git a/pkg/proto/msg/msg.pb.go b/pkg/proto/msg/msg.pb.go index 60eb493e3..bb5fa819c 100644 --- a/pkg/proto/msg/msg.pb.go +++ b/pkg/proto/msg/msg.pb.go @@ -6,7 +6,7 @@ package msg // import "Open_IM/pkg/proto/msg" import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import sdkws "Open_IM/pkg/proto/sdkws" +import sdk_ws "Open_IM/pkg/proto/sdk_ws" import wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" import ( @@ -26,19 +26,19 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type MsgDataToMQ struct { - Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` - MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"` + OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` + MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *MsgDataToMQ) Reset() { *m = MsgDataToMQ{} } func (m *MsgDataToMQ) String() string { return proto.CompactTextString(m) } func (*MsgDataToMQ) ProtoMessage() {} func (*MsgDataToMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{0} + return fileDescriptor_msg_69316330d19ec9fa, []int{0} } func (m *MsgDataToMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToMQ.Unmarshal(m, b) @@ -72,7 +72,7 @@ func (m *MsgDataToMQ) GetOperationID() string { return "" } -func (m *MsgDataToMQ) GetMsgData() *sdkws.MsgData { +func (m *MsgDataToMQ) GetMsgData() *sdk_ws.MsgData { if m != nil { return m.MsgData } @@ -80,18 +80,18 @@ func (m *MsgDataToMQ) GetMsgData() *sdkws.MsgData { } type MsgDataToDB struct { - MsgData *sdkws.MsgData `protobuf:"bytes,1,opt,name=msgData" json:"msgData,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + MsgData *sdk_ws.MsgData `protobuf:"bytes,1,opt,name=msgData" json:"msgData,omitempty"` + OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *MsgDataToDB) Reset() { *m = MsgDataToDB{} } func (m *MsgDataToDB) String() string { return proto.CompactTextString(m) } func (*MsgDataToDB) ProtoMessage() {} func (*MsgDataToDB) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{1} + return fileDescriptor_msg_69316330d19ec9fa, []int{1} } func (m *MsgDataToDB) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToDB.Unmarshal(m, b) @@ -111,7 +111,7 @@ func (m *MsgDataToDB) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDataToDB proto.InternalMessageInfo -func (m *MsgDataToDB) GetMsgData() *sdkws.MsgData { +func (m *MsgDataToDB) GetMsgData() *sdk_ws.MsgData { if m != nil { return m.MsgData } @@ -126,19 +126,19 @@ func (m *MsgDataToDB) GetOperationID() string { } type PushMsgDataToMQ struct { - OperationID string `protobuf:"bytes,1,opt,name=OperationID" json:"OperationID,omitempty"` - MsgData *sdkws.MsgData `protobuf:"bytes,2,opt,name=msgData" json:"msgData,omitempty"` - PushToUserID string `protobuf:"bytes,3,opt,name=pushToUserID" json:"pushToUserID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=OperationID" json:"OperationID,omitempty"` + MsgData *sdk_ws.MsgData `protobuf:"bytes,2,opt,name=msgData" json:"msgData,omitempty"` + PushToUserID string `protobuf:"bytes,3,opt,name=pushToUserID" json:"pushToUserID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *PushMsgDataToMQ) Reset() { *m = PushMsgDataToMQ{} } func (m *PushMsgDataToMQ) String() string { return proto.CompactTextString(m) } func (*PushMsgDataToMQ) ProtoMessage() {} func (*PushMsgDataToMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{2} + return fileDescriptor_msg_69316330d19ec9fa, []int{2} } func (m *PushMsgDataToMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PushMsgDataToMQ.Unmarshal(m, b) @@ -165,7 +165,7 @@ func (m *PushMsgDataToMQ) GetOperationID() string { return "" } -func (m *PushMsgDataToMQ) GetMsgData() *sdkws.MsgData { +func (m *PushMsgDataToMQ) GetMsgData() *sdk_ws.MsgData { if m != nil { return m.MsgData } @@ -193,7 +193,7 @@ func (m *MsgDataToMongoByMQ) Reset() { *m = MsgDataToMongoByMQ{} } func (m *MsgDataToMongoByMQ) String() string { return proto.CompactTextString(m) } func (*MsgDataToMongoByMQ) ProtoMessage() {} func (*MsgDataToMongoByMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{3} + return fileDescriptor_msg_69316330d19ec9fa, []int{3} } func (m *MsgDataToMongoByMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToMongoByMQ.Unmarshal(m, b) @@ -241,26 +241,6 @@ func (m *MsgDataToMongoByMQ) GetTriggerID() string { return "" } -// message PullMessageReq { -// string UserID = 1; -// int64 SeqBegin = 2; -// int64 SeqEnd = 3; -// string OperationID = 4; -// } -// -// message PullMessageResp { -// int32 ErrCode = 1; -// string ErrMsg = 2; -// int64 MaxSeq = 3; -// int64 MinSeq = 4; -// repeated GatherFormat SingleUserMsg = 5; -// repeated GatherFormat GroupUserMsg = 6; -// } -// message PullMessageBySeqListReq{ -// string UserID = 1; -// string OperationID = 2; -// repeated int64 seqList =3; -// } type GetMaxAndMinSeqReq struct { UserID string `protobuf:"bytes,1,opt,name=UserID" json:"UserID,omitempty"` OperationID string `protobuf:"bytes,2,opt,name=OperationID" json:"OperationID,omitempty"` @@ -273,7 +253,7 @@ func (m *GetMaxAndMinSeqReq) Reset() { *m = GetMaxAndMinSeqReq{} } func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqReq) ProtoMessage() {} func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{4} + return fileDescriptor_msg_69316330d19ec9fa, []int{4} } func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b) @@ -321,7 +301,7 @@ func (m *GetMaxAndMinSeqResp) Reset() { *m = GetMaxAndMinSeqResp{} } func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqResp) ProtoMessage() {} func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{5} + return fileDescriptor_msg_69316330d19ec9fa, []int{5} } func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b) @@ -370,19 +350,17 @@ func (m *GetMaxAndMinSeqResp) GetMinSeq() uint32 { } type SendMsgReq struct { - Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` - MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SendMsgReq) Reset() { *m = SendMsgReq{} } func (m *SendMsgReq) String() string { return proto.CompactTextString(m) } func (*SendMsgReq) ProtoMessage() {} func (*SendMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{6} + return fileDescriptor_msg_69316330d19ec9fa, []int{6} } func (m *SendMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SendMsgReq.Unmarshal(m, b) @@ -402,21 +380,7 @@ func (m *SendMsgReq) XXX_DiscardUnknown() { var xxx_messageInfo_SendMsgReq proto.InternalMessageInfo -func (m *SendMsgReq) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -func (m *SendMsgReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - -func (m *SendMsgReq) GetMsgData() *sdkws.MsgData { +func (m *SendMsgReq) GetMsgData() *sdk_ws.MsgData { if m != nil { return m.MsgData } @@ -424,8 +388,6 @@ func (m *SendMsgReq) GetMsgData() *sdkws.MsgData { } type SendMsgResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` ServerMsgID string `protobuf:"bytes,4,opt,name=serverMsgID" json:"serverMsgID,omitempty"` ClientMsgID string `protobuf:"bytes,5,opt,name=clientMsgID" json:"clientMsgID,omitempty"` SendTime int64 `protobuf:"varint,6,opt,name=sendTime" json:"sendTime,omitempty"` @@ -438,7 +400,7 @@ func (m *SendMsgResp) Reset() { *m = SendMsgResp{} } func (m *SendMsgResp) String() string { return proto.CompactTextString(m) } func (*SendMsgResp) ProtoMessage() {} func (*SendMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{7} + return fileDescriptor_msg_69316330d19ec9fa, []int{7} } func (m *SendMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SendMsgResp.Unmarshal(m, b) @@ -458,20 +420,6 @@ func (m *SendMsgResp) XXX_DiscardUnknown() { var xxx_messageInfo_SendMsgResp proto.InternalMessageInfo -func (m *SendMsgResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *SendMsgResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - func (m *SendMsgResp) GetServerMsgID() string { if m != nil { return m.ServerMsgID @@ -495,8 +443,6 @@ func (m *SendMsgResp) GetSendTime() int64 { type ClearMsgReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` - OpUserID string `protobuf:"bytes,2,opt,name=opUserID" json:"opUserID,omitempty"` - OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -506,7 +452,7 @@ func (m *ClearMsgReq) Reset() { *m = ClearMsgReq{} } func (m *ClearMsgReq) String() string { return proto.CompactTextString(m) } func (*ClearMsgReq) ProtoMessage() {} func (*ClearMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{8} + return fileDescriptor_msg_69316330d19ec9fa, []int{8} } func (m *ClearMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ClearMsgReq.Unmarshal(m, b) @@ -533,23 +479,7 @@ func (m *ClearMsgReq) GetUserID() string { return "" } -func (m *ClearMsgReq) GetOpUserID() string { - if m != nil { - return m.OpUserID - } - return "" -} - -func (m *ClearMsgReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - type ClearMsgResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -559,7 +489,7 @@ func (m *ClearMsgResp) Reset() { *m = ClearMsgResp{} } func (m *ClearMsgResp) String() string { return proto.CompactTextString(m) } func (*ClearMsgResp) ProtoMessage() {} func (*ClearMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{9} + return fileDescriptor_msg_69316330d19ec9fa, []int{9} } func (m *ClearMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ClearMsgResp.Unmarshal(m, b) @@ -579,26 +509,10 @@ func (m *ClearMsgResp) XXX_DiscardUnknown() { var xxx_messageInfo_ClearMsgResp proto.InternalMessageInfo -func (m *ClearMsgResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *ClearMsgResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - type SetMsgMinSeqReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` GroupID string `protobuf:"bytes,2,opt,name=groupID" json:"groupID,omitempty"` MinSeq uint32 `protobuf:"varint,3,opt,name=minSeq" json:"minSeq,omitempty"` - OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"` - OpUserID string `protobuf:"bytes,5,opt,name=opUserID" json:"opUserID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -608,7 +522,7 @@ func (m *SetMsgMinSeqReq) Reset() { *m = SetMsgMinSeqReq{} } func (m *SetMsgMinSeqReq) String() string { return proto.CompactTextString(m) } func (*SetMsgMinSeqReq) ProtoMessage() {} func (*SetMsgMinSeqReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{10} + return fileDescriptor_msg_69316330d19ec9fa, []int{10} } func (m *SetMsgMinSeqReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMsgMinSeqReq.Unmarshal(m, b) @@ -649,23 +563,7 @@ func (m *SetMsgMinSeqReq) GetMinSeq() uint32 { return 0 } -func (m *SetMsgMinSeqReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - -func (m *SetMsgMinSeqReq) GetOpUserID() string { - if m != nil { - return m.OpUserID - } - return "" -} - type SetMsgMinSeqResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -675,7 +573,7 @@ func (m *SetMsgMinSeqResp) Reset() { *m = SetMsgMinSeqResp{} } func (m *SetMsgMinSeqResp) String() string { return proto.CompactTextString(m) } func (*SetMsgMinSeqResp) ProtoMessage() {} func (*SetMsgMinSeqResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{11} + return fileDescriptor_msg_69316330d19ec9fa, []int{11} } func (m *SetMsgMinSeqResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMsgMinSeqResp.Unmarshal(m, b) @@ -695,22 +593,7 @@ func (m *SetMsgMinSeqResp) XXX_DiscardUnknown() { var xxx_messageInfo_SetMsgMinSeqResp proto.InternalMessageInfo -func (m *SetMsgMinSeqResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *SetMsgMinSeqResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - type SetSendMsgStatusReq struct { - OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` Status int32 `protobuf:"varint,2,opt,name=status" json:"status,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -721,7 +604,7 @@ func (m *SetSendMsgStatusReq) Reset() { *m = SetSendMsgStatusReq{} } func (m *SetSendMsgStatusReq) String() string { return proto.CompactTextString(m) } func (*SetSendMsgStatusReq) ProtoMessage() {} func (*SetSendMsgStatusReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{12} + return fileDescriptor_msg_69316330d19ec9fa, []int{12} } func (m *SetSendMsgStatusReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetSendMsgStatusReq.Unmarshal(m, b) @@ -741,13 +624,6 @@ func (m *SetSendMsgStatusReq) XXX_DiscardUnknown() { var xxx_messageInfo_SetSendMsgStatusReq proto.InternalMessageInfo -func (m *SetSendMsgStatusReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - func (m *SetSendMsgStatusReq) GetStatus() int32 { if m != nil { return m.Status @@ -756,8 +632,6 @@ func (m *SetSendMsgStatusReq) GetStatus() int32 { } type SetSendMsgStatusResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -767,7 +641,7 @@ func (m *SetSendMsgStatusResp) Reset() { *m = SetSendMsgStatusResp{} } func (m *SetSendMsgStatusResp) String() string { return proto.CompactTextString(m) } func (*SetSendMsgStatusResp) ProtoMessage() {} func (*SetSendMsgStatusResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{13} + return fileDescriptor_msg_69316330d19ec9fa, []int{13} } func (m *SetSendMsgStatusResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetSendMsgStatusResp.Unmarshal(m, b) @@ -787,20 +661,6 @@ func (m *SetSendMsgStatusResp) XXX_DiscardUnknown() { var xxx_messageInfo_SetSendMsgStatusResp proto.InternalMessageInfo -func (m *SetSendMsgStatusResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *SetSendMsgStatusResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - type GetSendMsgStatusReq struct { OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -812,7 +672,7 @@ func (m *GetSendMsgStatusReq) Reset() { *m = GetSendMsgStatusReq{} } func (m *GetSendMsgStatusReq) String() string { return proto.CompactTextString(m) } func (*GetSendMsgStatusReq) ProtoMessage() {} func (*GetSendMsgStatusReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{14} + return fileDescriptor_msg_69316330d19ec9fa, []int{14} } func (m *GetSendMsgStatusReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSendMsgStatusReq.Unmarshal(m, b) @@ -852,7 +712,7 @@ func (m *GetSendMsgStatusResp) Reset() { *m = GetSendMsgStatusResp{} } func (m *GetSendMsgStatusResp) String() string { return proto.CompactTextString(m) } func (*GetSendMsgStatusResp) ProtoMessage() {} func (*GetSendMsgStatusResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{15} + return fileDescriptor_msg_69316330d19ec9fa, []int{15} } func (m *GetSendMsgStatusResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSendMsgStatusResp.Unmarshal(m, b) @@ -894,10 +754,8 @@ func (m *GetSendMsgStatusResp) GetStatus() int32 { } type DelSuperGroupMsgReq struct { - OpUserID string `protobuf:"bytes,1,opt,name=opUserID" json:"opUserID,omitempty"` UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` GroupID string `protobuf:"bytes,3,opt,name=groupID" json:"groupID,omitempty"` - OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -907,7 +765,7 @@ func (m *DelSuperGroupMsgReq) Reset() { *m = DelSuperGroupMsgReq{} } func (m *DelSuperGroupMsgReq) String() string { return proto.CompactTextString(m) } func (*DelSuperGroupMsgReq) ProtoMessage() {} func (*DelSuperGroupMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{16} + return fileDescriptor_msg_69316330d19ec9fa, []int{16} } func (m *DelSuperGroupMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DelSuperGroupMsgReq.Unmarshal(m, b) @@ -927,13 +785,6 @@ func (m *DelSuperGroupMsgReq) XXX_DiscardUnknown() { var xxx_messageInfo_DelSuperGroupMsgReq proto.InternalMessageInfo -func (m *DelSuperGroupMsgReq) GetOpUserID() string { - if m != nil { - return m.OpUserID - } - return "" -} - func (m *DelSuperGroupMsgReq) GetUserID() string { if m != nil { return m.UserID @@ -948,16 +799,7 @@ func (m *DelSuperGroupMsgReq) GetGroupID() string { return "" } -func (m *DelSuperGroupMsgReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - type DelSuperGroupMsgResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -967,7 +809,7 @@ func (m *DelSuperGroupMsgResp) Reset() { *m = DelSuperGroupMsgResp{} } func (m *DelSuperGroupMsgResp) String() string { return proto.CompactTextString(m) } func (*DelSuperGroupMsgResp) ProtoMessage() {} func (*DelSuperGroupMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{17} + return fileDescriptor_msg_69316330d19ec9fa, []int{17} } func (m *DelSuperGroupMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DelSuperGroupMsgResp.Unmarshal(m, b) @@ -987,20 +829,6 @@ func (m *DelSuperGroupMsgResp) XXX_DiscardUnknown() { var xxx_messageInfo_DelSuperGroupMsgResp proto.InternalMessageInfo -func (m *DelSuperGroupMsgResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *DelSuperGroupMsgResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - type GetSuperGroupMsgReq struct { OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` Seq uint32 `protobuf:"varint,2,opt,name=Seq" json:"Seq,omitempty"` @@ -1014,7 +842,7 @@ func (m *GetSuperGroupMsgReq) Reset() { *m = GetSuperGroupMsgReq{} } func (m *GetSuperGroupMsgReq) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupMsgReq) ProtoMessage() {} func (*GetSuperGroupMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{18} + return fileDescriptor_msg_69316330d19ec9fa, []int{18} } func (m *GetSuperGroupMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupMsgReq.Unmarshal(m, b) @@ -1056,19 +884,19 @@ func (m *GetSuperGroupMsgReq) GetGroupID() string { } type GetSuperGroupMsgResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` - MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` + MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *GetSuperGroupMsgResp) Reset() { *m = GetSuperGroupMsgResp{} } func (m *GetSuperGroupMsgResp) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupMsgResp) ProtoMessage() {} func (*GetSuperGroupMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{19} + return fileDescriptor_msg_69316330d19ec9fa, []int{19} } func (m *GetSuperGroupMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupMsgResp.Unmarshal(m, b) @@ -1102,7 +930,7 @@ func (m *GetSuperGroupMsgResp) GetErrMsg() string { return "" } -func (m *GetSuperGroupMsgResp) GetMsgData() *sdkws.MsgData { +func (m *GetSuperGroupMsgResp) GetMsgData() *sdk_ws.MsgData { if m != nil { return m.MsgData } @@ -1121,7 +949,7 @@ func (m *GetWriteDiffMsgReq) Reset() { *m = GetWriteDiffMsgReq{} } func (m *GetWriteDiffMsgReq) String() string { return proto.CompactTextString(m) } func (*GetWriteDiffMsgReq) ProtoMessage() {} func (*GetWriteDiffMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{20} + return fileDescriptor_msg_69316330d19ec9fa, []int{20} } func (m *GetWriteDiffMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetWriteDiffMsgReq.Unmarshal(m, b) @@ -1156,19 +984,19 @@ func (m *GetWriteDiffMsgReq) GetSeq() uint32 { } type GetWriteDiffMsgResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` - MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` + MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *GetWriteDiffMsgResp) Reset() { *m = GetWriteDiffMsgResp{} } func (m *GetWriteDiffMsgResp) String() string { return proto.CompactTextString(m) } func (*GetWriteDiffMsgResp) ProtoMessage() {} func (*GetWriteDiffMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{21} + return fileDescriptor_msg_69316330d19ec9fa, []int{21} } func (m *GetWriteDiffMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetWriteDiffMsgResp.Unmarshal(m, b) @@ -1202,7 +1030,7 @@ func (m *GetWriteDiffMsgResp) GetErrMsg() string { return "" } -func (m *GetWriteDiffMsgResp) GetMsgData() *sdkws.MsgData { +func (m *GetWriteDiffMsgResp) GetMsgData() *sdk_ws.MsgData { if m != nil { return m.MsgData } @@ -1210,27 +1038,27 @@ func (m *GetWriteDiffMsgResp) GetMsgData() *sdkws.MsgData { } type ModifyMessageReactionExtensionsReq struct { - OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` - SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` - OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` - SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` - ReactionExtensionList map[string]*sdkws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` - AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` - IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` - IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` - MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` + SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` + OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` + SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` + ReactionExtensionList map[string]*sdk_ws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` + AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` + IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` + IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` + MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ModifyMessageReactionExtensionsReq) Reset() { *m = ModifyMessageReactionExtensionsReq{} } func (m *ModifyMessageReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*ModifyMessageReactionExtensionsReq) ProtoMessage() {} func (*ModifyMessageReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{22} + return fileDescriptor_msg_69316330d19ec9fa, []int{22} } func (m *ModifyMessageReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ModifyMessageReactionExtensionsReq.Unmarshal(m, b) @@ -1278,7 +1106,7 @@ func (m *ModifyMessageReactionExtensionsReq) GetSessionType() int32 { return 0 } -func (m *ModifyMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdkws.KeyValue { +func (m *ModifyMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdk_ws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1328,27 +1156,27 @@ func (m *ModifyMessageReactionExtensionsReq) GetMsgFirstModifyTime() int64 { } type SetMessageReactionExtensionsReq struct { - OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` - SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` - OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` - SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` - ReactionExtensionList map[string]*sdkws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` - AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` - IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` - IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` - MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` + SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` + OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` + SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` + ReactionExtensionList map[string]*sdk_ws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` + AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` + IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` + IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` + MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SetMessageReactionExtensionsReq) Reset() { *m = SetMessageReactionExtensionsReq{} } func (m *SetMessageReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*SetMessageReactionExtensionsReq) ProtoMessage() {} func (*SetMessageReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{23} + return fileDescriptor_msg_69316330d19ec9fa, []int{23} } func (m *SetMessageReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMessageReactionExtensionsReq.Unmarshal(m, b) @@ -1396,7 +1224,7 @@ func (m *SetMessageReactionExtensionsReq) GetSessionType() int32 { return 0 } -func (m *SetMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdkws.KeyValue { +func (m *SetMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdk_ws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1461,7 +1289,7 @@ func (m *SetMessageReactionExtensionsResp) Reset() { *m = SetMessageReac func (m *SetMessageReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*SetMessageReactionExtensionsResp) ProtoMessage() {} func (*SetMessageReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{24} + return fileDescriptor_msg_69316330d19ec9fa, []int{24} } func (m *SetMessageReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMessageReactionExtensionsResp.Unmarshal(m, b) @@ -1538,7 +1366,7 @@ func (m *GetMessageListReactionExtensionsReq) Reset() { *m = GetMessageL func (m *GetMessageListReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*GetMessageListReactionExtensionsReq) ProtoMessage() {} func (*GetMessageListReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{25} + return fileDescriptor_msg_69316330d19ec9fa, []int{25} } func (m *GetMessageListReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMessageListReactionExtensionsReq.Unmarshal(m, b) @@ -1609,7 +1437,7 @@ func (m *GetMessageListReactionExtensionsReq_MessageReactionKey) String() string } func (*GetMessageListReactionExtensionsReq_MessageReactionKey) ProtoMessage() {} func (*GetMessageListReactionExtensionsReq_MessageReactionKey) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{25, 0} + return fileDescriptor_msg_69316330d19ec9fa, []int{25, 0} } func (m *GetMessageListReactionExtensionsReq_MessageReactionKey) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMessageListReactionExtensionsReq_MessageReactionKey.Unmarshal(m, b) @@ -1656,7 +1484,7 @@ func (m *GetMessageListReactionExtensionsResp) Reset() { *m = GetMessage func (m *GetMessageListReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*GetMessageListReactionExtensionsResp) ProtoMessage() {} func (*GetMessageListReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{26} + return fileDescriptor_msg_69316330d19ec9fa, []int{26} } func (m *GetMessageListReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMessageListReactionExtensionsResp.Unmarshal(m, b) @@ -1698,20 +1526,20 @@ func (m *GetMessageListReactionExtensionsResp) GetSingleMessageResult() []*Singl } type SingleMessageExtensionResult struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` - ReactionExtensionList map[string]*sdkws.KeyValue `protobuf:"bytes,3,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - ClientMsgID string `protobuf:"bytes,4,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` + ReactionExtensionList map[string]*sdk_ws.KeyValue `protobuf:"bytes,3,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ClientMsgID string `protobuf:"bytes,4,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SingleMessageExtensionResult) Reset() { *m = SingleMessageExtensionResult{} } func (m *SingleMessageExtensionResult) String() string { return proto.CompactTextString(m) } func (*SingleMessageExtensionResult) ProtoMessage() {} func (*SingleMessageExtensionResult) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{27} + return fileDescriptor_msg_69316330d19ec9fa, []int{27} } func (m *SingleMessageExtensionResult) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SingleMessageExtensionResult.Unmarshal(m, b) @@ -1745,7 +1573,7 @@ func (m *SingleMessageExtensionResult) GetErrMsg() string { return "" } -func (m *SingleMessageExtensionResult) GetReactionExtensionList() map[string]*sdkws.KeyValue { +func (m *SingleMessageExtensionResult) GetReactionExtensionList() map[string]*sdk_ws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1773,7 +1601,7 @@ func (m *ModifyMessageReactionExtensionsResp) Reset() { *m = ModifyMessa func (m *ModifyMessageReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*ModifyMessageReactionExtensionsResp) ProtoMessage() {} func (*ModifyMessageReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{28} + return fileDescriptor_msg_69316330d19ec9fa, []int{28} } func (m *ModifyMessageReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ModifyMessageReactionExtensionsResp.Unmarshal(m, b) @@ -1822,17 +1650,17 @@ func (m *ModifyMessageReactionExtensionsResp) GetFailedList() []*ExtendMsgResp { } type DeleteMessageListReactionExtensionsReq struct { - OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` - OpUserID string `protobuf:"bytes,2,opt,name=opUserID" json:"opUserID,omitempty"` - SourceID string `protobuf:"bytes,3,opt,name=sourceID" json:"sourceID,omitempty"` - SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` - ClientMsgID string `protobuf:"bytes,5,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - IsExternalExtensions bool `protobuf:"varint,6,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` - MsgFirstModifyTime int64 `protobuf:"varint,7,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` - ReactionExtensionList []*sdkws.KeyValue `protobuf:"bytes,8,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` + OpUserID string `protobuf:"bytes,2,opt,name=opUserID" json:"opUserID,omitempty"` + SourceID string `protobuf:"bytes,3,opt,name=sourceID" json:"sourceID,omitempty"` + SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` + ClientMsgID string `protobuf:"bytes,5,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + IsExternalExtensions bool `protobuf:"varint,6,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` + MsgFirstModifyTime int64 `protobuf:"varint,7,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` + ReactionExtensionList []*sdk_ws.KeyValue `protobuf:"bytes,8,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *DeleteMessageListReactionExtensionsReq) Reset() { @@ -1841,7 +1669,7 @@ func (m *DeleteMessageListReactionExtensionsReq) Reset() { func (m *DeleteMessageListReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*DeleteMessageListReactionExtensionsReq) ProtoMessage() {} func (*DeleteMessageListReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{29} + return fileDescriptor_msg_69316330d19ec9fa, []int{29} } func (m *DeleteMessageListReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteMessageListReactionExtensionsReq.Unmarshal(m, b) @@ -1910,7 +1738,7 @@ func (m *DeleteMessageListReactionExtensionsReq) GetMsgFirstModifyTime() int64 { return 0 } -func (m *DeleteMessageListReactionExtensionsReq) GetReactionExtensionList() []*sdkws.KeyValue { +func (m *DeleteMessageListReactionExtensionsReq) GetReactionExtensionList() []*sdk_ws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1932,7 +1760,7 @@ func (m *DeleteMessageListReactionExtensionsResp) Reset() { func (m *DeleteMessageListReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*DeleteMessageListReactionExtensionsResp) ProtoMessage() {} func (*DeleteMessageListReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{30} + return fileDescriptor_msg_69316330d19ec9fa, []int{30} } func (m *DeleteMessageListReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteMessageListReactionExtensionsResp.Unmarshal(m, b) @@ -1986,7 +1814,7 @@ func (m *ExtendMsgResp) Reset() { *m = ExtendMsgResp{} } func (m *ExtendMsgResp) String() string { return proto.CompactTextString(m) } func (*ExtendMsgResp) ProtoMessage() {} func (*ExtendMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{31} + return fileDescriptor_msg_69316330d19ec9fa, []int{31} } func (m *ExtendMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExtendMsgResp.Unmarshal(m, b) @@ -2042,7 +1870,7 @@ func (m *ExtendMsg) Reset() { *m = ExtendMsg{} } func (m *ExtendMsg) String() string { return proto.CompactTextString(m) } func (*ExtendMsg) ProtoMessage() {} func (*ExtendMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{32} + return fileDescriptor_msg_69316330d19ec9fa, []int{32} } func (m *ExtendMsg) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExtendMsg.Unmarshal(m, b) @@ -2098,19 +1926,19 @@ func (m *ExtendMsg) GetEx() string { } type KeyValueResp struct { - KeyValue *sdkws.KeyValue `protobuf:"bytes,1,opt,name=keyValue" json:"keyValue,omitempty"` - ErrCode int32 `protobuf:"varint,2,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,3,opt,name=errMsg" json:"errMsg,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + KeyValue *sdk_ws.KeyValue `protobuf:"bytes,1,opt,name=keyValue" json:"keyValue,omitempty"` + ErrCode int32 `protobuf:"varint,2,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,3,opt,name=errMsg" json:"errMsg,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *KeyValueResp) Reset() { *m = KeyValueResp{} } func (m *KeyValueResp) String() string { return proto.CompactTextString(m) } func (*KeyValueResp) ProtoMessage() {} func (*KeyValueResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{33} + return fileDescriptor_msg_69316330d19ec9fa, []int{33} } func (m *KeyValueResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KeyValueResp.Unmarshal(m, b) @@ -2130,7 +1958,7 @@ func (m *KeyValueResp) XXX_DiscardUnknown() { var xxx_messageInfo_KeyValueResp proto.InternalMessageInfo -func (m *KeyValueResp) GetKeyValue() *sdkws.KeyValue { +func (m *KeyValueResp) GetKeyValue() *sdk_ws.KeyValue { if m != nil { return m.KeyValue } @@ -2164,7 +1992,7 @@ func (m *MsgDataToModifyByMQ) Reset() { *m = MsgDataToModifyByMQ{} } func (m *MsgDataToModifyByMQ) String() string { return proto.CompactTextString(m) } func (*MsgDataToModifyByMQ) ProtoMessage() {} func (*MsgDataToModifyByMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_4f5a59ae8be91efc, []int{34} + return fileDescriptor_msg_69316330d19ec9fa, []int{34} } func (m *MsgDataToModifyByMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToModifyByMQ.Unmarshal(m, b) @@ -2229,15 +2057,15 @@ func init() { proto.RegisterType((*GetWriteDiffMsgReq)(nil), "msg.GetWriteDiffMsgReq") proto.RegisterType((*GetWriteDiffMsgResp)(nil), "msg.GetWriteDiffMsgResp") proto.RegisterType((*ModifyMessageReactionExtensionsReq)(nil), "msg.ModifyMessageReactionExtensionsReq") - proto.RegisterMapType((map[string]*sdkws.KeyValue)(nil), "msg.ModifyMessageReactionExtensionsReq.ReactionExtensionListEntry") + proto.RegisterMapType((map[string]*sdk_ws.KeyValue)(nil), "msg.ModifyMessageReactionExtensionsReq.ReactionExtensionListEntry") proto.RegisterType((*SetMessageReactionExtensionsReq)(nil), "msg.SetMessageReactionExtensionsReq") - proto.RegisterMapType((map[string]*sdkws.KeyValue)(nil), "msg.SetMessageReactionExtensionsReq.ReactionExtensionListEntry") + proto.RegisterMapType((map[string]*sdk_ws.KeyValue)(nil), "msg.SetMessageReactionExtensionsReq.ReactionExtensionListEntry") proto.RegisterType((*SetMessageReactionExtensionsResp)(nil), "msg.SetMessageReactionExtensionsResp") proto.RegisterType((*GetMessageListReactionExtensionsReq)(nil), "msg.GetMessageListReactionExtensionsReq") proto.RegisterType((*GetMessageListReactionExtensionsReq_MessageReactionKey)(nil), "msg.GetMessageListReactionExtensionsReq.MessageReactionKey") proto.RegisterType((*GetMessageListReactionExtensionsResp)(nil), "msg.GetMessageListReactionExtensionsResp") proto.RegisterType((*SingleMessageExtensionResult)(nil), "msg.SingleMessageExtensionResult") - proto.RegisterMapType((map[string]*sdkws.KeyValue)(nil), "msg.SingleMessageExtensionResult.ReactionExtensionListEntry") + proto.RegisterMapType((map[string]*sdk_ws.KeyValue)(nil), "msg.SingleMessageExtensionResult.ReactionExtensionListEntry") proto.RegisterType((*ModifyMessageReactionExtensionsResp)(nil), "msg.ModifyMessageReactionExtensionsResp") proto.RegisterType((*DeleteMessageListReactionExtensionsReq)(nil), "msg.DeleteMessageListReactionExtensionsReq") proto.RegisterType((*DeleteMessageListReactionExtensionsResp)(nil), "msg.DeleteMessageListReactionExtensionsResp") @@ -2259,18 +2087,23 @@ const _ = grpc.SupportPackageIsVersion4 // Client API for Msg service type MsgClient interface { - GetMaxAndMinSeq(ctx context.Context, in *sdkws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdkws.GetMaxAndMinSeqResp, error) - PullMessageBySeqList(ctx context.Context, in *sdkws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdkws.PullMessageBySeqListResp, error) + // 获取最小最大seq(包括用户的,以及指定群组的) + GetMaxAndMinSeq(ctx context.Context, in *sdk_ws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdk_ws.GetMaxAndMinSeqResp, error) + // 拉取历史消息(包括用户的,以及指定群组的) + PullMessageBySeqList(ctx context.Context, in *sdk_ws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdk_ws.PullMessageBySeqListResp, error) + // 发送消息 SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgResp, error) - DelMsgList(ctx context.Context, in *sdkws.DelMsgListReq, opts ...grpc.CallOption) (*sdkws.DelMsgListResp, error) + // 删除某人消息 + DelMsgList(ctx context.Context, in *sdk_ws.DelMsgListReq, opts ...grpc.CallOption) (*sdk_ws.DelMsgListResp, error) + // 删除某个用户某个大群消息 DelSuperGroupMsg(ctx context.Context, in *DelSuperGroupMsgReq, opts ...grpc.CallOption) (*DelSuperGroupMsgResp, error) + // 清空某人所有消息 ClearMsg(ctx context.Context, in *ClearMsgReq, opts ...grpc.CallOption) (*ClearMsgResp, error) - SetMsgMinSeq(ctx context.Context, in *SetMsgMinSeqReq, opts ...grpc.CallOption) (*SetMsgMinSeqResp, error) + // 设置消息是否发送成功-针对api发送的消息 SetSendMsgStatus(ctx context.Context, in *SetSendMsgStatusReq, opts ...grpc.CallOption) (*SetSendMsgStatusResp, error) + // 获取消息发送状态 GetSendMsgStatus(ctx context.Context, in *GetSendMsgStatusReq, opts ...grpc.CallOption) (*GetSendMsgStatusResp, error) - GetSuperGroupMsg(ctx context.Context, in *GetSuperGroupMsgReq, opts ...grpc.CallOption) (*GetSuperGroupMsgResp, error) - GetWriteDiffMsg(ctx context.Context, in *GetWriteDiffMsgReq, opts ...grpc.CallOption) (*GetWriteDiffMsgResp, error) - // modify msg + // 修改消息 SetMessageReactionExtensions(ctx context.Context, in *SetMessageReactionExtensionsReq, opts ...grpc.CallOption) (*SetMessageReactionExtensionsResp, error) GetMessageListReactionExtensions(ctx context.Context, in *GetMessageListReactionExtensionsReq, opts ...grpc.CallOption) (*GetMessageListReactionExtensionsResp, error) AddMessageReactionExtensions(ctx context.Context, in *ModifyMessageReactionExtensionsReq, opts ...grpc.CallOption) (*ModifyMessageReactionExtensionsResp, error) @@ -2285,8 +2118,8 @@ func NewMsgClient(cc *grpc.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) GetMaxAndMinSeq(ctx context.Context, in *sdkws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdkws.GetMaxAndMinSeqResp, error) { - out := new(sdkws.GetMaxAndMinSeqResp) +func (c *msgClient) GetMaxAndMinSeq(ctx context.Context, in *sdk_ws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdk_ws.GetMaxAndMinSeqResp, error) { + out := new(sdk_ws.GetMaxAndMinSeqResp) err := grpc.Invoke(ctx, "/msg.msg/GetMaxAndMinSeq", in, out, c.cc, opts...) if err != nil { return nil, err @@ -2294,8 +2127,8 @@ func (c *msgClient) GetMaxAndMinSeq(ctx context.Context, in *sdkws.GetMaxAndMinS return out, nil } -func (c *msgClient) PullMessageBySeqList(ctx context.Context, in *sdkws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdkws.PullMessageBySeqListResp, error) { - out := new(sdkws.PullMessageBySeqListResp) +func (c *msgClient) PullMessageBySeqList(ctx context.Context, in *sdk_ws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdk_ws.PullMessageBySeqListResp, error) { + out := new(sdk_ws.PullMessageBySeqListResp) err := grpc.Invoke(ctx, "/msg.msg/PullMessageBySeqList", in, out, c.cc, opts...) if err != nil { return nil, err @@ -2312,8 +2145,8 @@ func (c *msgClient) SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.Ca return out, nil } -func (c *msgClient) DelMsgList(ctx context.Context, in *sdkws.DelMsgListReq, opts ...grpc.CallOption) (*sdkws.DelMsgListResp, error) { - out := new(sdkws.DelMsgListResp) +func (c *msgClient) DelMsgList(ctx context.Context, in *sdk_ws.DelMsgListReq, opts ...grpc.CallOption) (*sdk_ws.DelMsgListResp, error) { + out := new(sdk_ws.DelMsgListResp) err := grpc.Invoke(ctx, "/msg.msg/DelMsgList", in, out, c.cc, opts...) if err != nil { return nil, err @@ -2339,15 +2172,6 @@ func (c *msgClient) ClearMsg(ctx context.Context, in *ClearMsgReq, opts ...grpc. return out, nil } -func (c *msgClient) SetMsgMinSeq(ctx context.Context, in *SetMsgMinSeqReq, opts ...grpc.CallOption) (*SetMsgMinSeqResp, error) { - out := new(SetMsgMinSeqResp) - err := grpc.Invoke(ctx, "/msg.msg/SetMsgMinSeq", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) SetSendMsgStatus(ctx context.Context, in *SetSendMsgStatusReq, opts ...grpc.CallOption) (*SetSendMsgStatusResp, error) { out := new(SetSendMsgStatusResp) err := grpc.Invoke(ctx, "/msg.msg/SetSendMsgStatus", in, out, c.cc, opts...) @@ -2366,24 +2190,6 @@ func (c *msgClient) GetSendMsgStatus(ctx context.Context, in *GetSendMsgStatusRe return out, nil } -func (c *msgClient) GetSuperGroupMsg(ctx context.Context, in *GetSuperGroupMsgReq, opts ...grpc.CallOption) (*GetSuperGroupMsgResp, error) { - out := new(GetSuperGroupMsgResp) - err := grpc.Invoke(ctx, "/msg.msg/GetSuperGroupMsg", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) GetWriteDiffMsg(ctx context.Context, in *GetWriteDiffMsgReq, opts ...grpc.CallOption) (*GetWriteDiffMsgResp, error) { - out := new(GetWriteDiffMsgResp) - err := grpc.Invoke(ctx, "/msg.msg/GetWriteDiffMsg", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) SetMessageReactionExtensions(ctx context.Context, in *SetMessageReactionExtensionsReq, opts ...grpc.CallOption) (*SetMessageReactionExtensionsResp, error) { out := new(SetMessageReactionExtensionsResp) err := grpc.Invoke(ctx, "/msg.msg/SetMessageReactionExtensions", in, out, c.cc, opts...) @@ -2423,18 +2229,23 @@ func (c *msgClient) DeleteMessageReactionExtensions(ctx context.Context, in *Del // Server API for Msg service type MsgServer interface { - GetMaxAndMinSeq(context.Context, *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) - PullMessageBySeqList(context.Context, *sdkws.PullMessageBySeqListReq) (*sdkws.PullMessageBySeqListResp, error) + // 获取最小最大seq(包括用户的,以及指定群组的) + GetMaxAndMinSeq(context.Context, *sdk_ws.GetMaxAndMinSeqReq) (*sdk_ws.GetMaxAndMinSeqResp, error) + // 拉取历史消息(包括用户的,以及指定群组的) + PullMessageBySeqList(context.Context, *sdk_ws.PullMessageBySeqListReq) (*sdk_ws.PullMessageBySeqListResp, error) + // 发送消息 SendMsg(context.Context, *SendMsgReq) (*SendMsgResp, error) - DelMsgList(context.Context, *sdkws.DelMsgListReq) (*sdkws.DelMsgListResp, error) + // 删除某人消息 + DelMsgList(context.Context, *sdk_ws.DelMsgListReq) (*sdk_ws.DelMsgListResp, error) + // 删除某个用户某个大群消息 DelSuperGroupMsg(context.Context, *DelSuperGroupMsgReq) (*DelSuperGroupMsgResp, error) + // 清空某人所有消息 ClearMsg(context.Context, *ClearMsgReq) (*ClearMsgResp, error) - SetMsgMinSeq(context.Context, *SetMsgMinSeqReq) (*SetMsgMinSeqResp, error) + // 设置消息是否发送成功-针对api发送的消息 SetSendMsgStatus(context.Context, *SetSendMsgStatusReq) (*SetSendMsgStatusResp, error) + // 获取消息发送状态 GetSendMsgStatus(context.Context, *GetSendMsgStatusReq) (*GetSendMsgStatusResp, error) - GetSuperGroupMsg(context.Context, *GetSuperGroupMsgReq) (*GetSuperGroupMsgResp, error) - GetWriteDiffMsg(context.Context, *GetWriteDiffMsgReq) (*GetWriteDiffMsgResp, error) - // modify msg + // 修改消息 SetMessageReactionExtensions(context.Context, *SetMessageReactionExtensionsReq) (*SetMessageReactionExtensionsResp, error) GetMessageListReactionExtensions(context.Context, *GetMessageListReactionExtensionsReq) (*GetMessageListReactionExtensionsResp, error) AddMessageReactionExtensions(context.Context, *ModifyMessageReactionExtensionsReq) (*ModifyMessageReactionExtensionsResp, error) @@ -2446,7 +2257,7 @@ func RegisterMsgServer(s *grpc.Server, srv MsgServer) { } func _Msg_GetMaxAndMinSeq_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(sdkws.GetMaxAndMinSeqReq) + in := new(sdk_ws.GetMaxAndMinSeqReq) if err := dec(in); err != nil { return nil, err } @@ -2458,13 +2269,13 @@ func _Msg_GetMaxAndMinSeq_Handler(srv interface{}, ctx context.Context, dec func FullMethod: "/msg.msg/GetMaxAndMinSeq", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).GetMaxAndMinSeq(ctx, req.(*sdkws.GetMaxAndMinSeqReq)) + return srv.(MsgServer).GetMaxAndMinSeq(ctx, req.(*sdk_ws.GetMaxAndMinSeqReq)) } return interceptor(ctx, in, info, handler) } func _Msg_PullMessageBySeqList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(sdkws.PullMessageBySeqListReq) + in := new(sdk_ws.PullMessageBySeqListReq) if err := dec(in); err != nil { return nil, err } @@ -2476,7 +2287,7 @@ func _Msg_PullMessageBySeqList_Handler(srv interface{}, ctx context.Context, dec FullMethod: "/msg.msg/PullMessageBySeqList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).PullMessageBySeqList(ctx, req.(*sdkws.PullMessageBySeqListReq)) + return srv.(MsgServer).PullMessageBySeqList(ctx, req.(*sdk_ws.PullMessageBySeqListReq)) } return interceptor(ctx, in, info, handler) } @@ -2500,7 +2311,7 @@ func _Msg_SendMsg_Handler(srv interface{}, ctx context.Context, dec func(interfa } func _Msg_DelMsgList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(sdkws.DelMsgListReq) + in := new(sdk_ws.DelMsgListReq) if err := dec(in); err != nil { return nil, err } @@ -2512,7 +2323,7 @@ func _Msg_DelMsgList_Handler(srv interface{}, ctx context.Context, dec func(inte FullMethod: "/msg.msg/DelMsgList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DelMsgList(ctx, req.(*sdkws.DelMsgListReq)) + return srv.(MsgServer).DelMsgList(ctx, req.(*sdk_ws.DelMsgListReq)) } return interceptor(ctx, in, info, handler) } @@ -2553,24 +2364,6 @@ func _Msg_ClearMsg_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Msg_SetMsgMinSeq_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetMsgMinSeqReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SetMsgMinSeq(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/msg.msg/SetMsgMinSeq", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetMsgMinSeq(ctx, req.(*SetMsgMinSeqReq)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_SetSendMsgStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SetSendMsgStatusReq) if err := dec(in); err != nil { @@ -2607,42 +2400,6 @@ func _Msg_GetSendMsgStatus_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Msg_GetSuperGroupMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetSuperGroupMsgReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).GetSuperGroupMsg(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/msg.msg/GetSuperGroupMsg", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).GetSuperGroupMsg(ctx, req.(*GetSuperGroupMsgReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_GetWriteDiffMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetWriteDiffMsgReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).GetWriteDiffMsg(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/msg.msg/GetWriteDiffMsg", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).GetWriteDiffMsg(ctx, req.(*GetWriteDiffMsgReq)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_SetMessageReactionExtensions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SetMessageReactionExtensionsReq) if err := dec(in); err != nil { @@ -2743,10 +2500,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ClearMsg", Handler: _Msg_ClearMsg_Handler, }, - { - MethodName: "SetMsgMinSeq", - Handler: _Msg_SetMsgMinSeq_Handler, - }, { MethodName: "SetSendMsgStatus", Handler: _Msg_SetSendMsgStatus_Handler, @@ -2755,14 +2508,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "GetSendMsgStatus", Handler: _Msg_GetSendMsgStatus_Handler, }, - { - MethodName: "GetSuperGroupMsg", - Handler: _Msg_GetSuperGroupMsg_Handler, - }, - { - MethodName: "GetWriteDiffMsg", - Handler: _Msg_GetWriteDiffMsg_Handler, - }, { MethodName: "SetMessageReactionExtensions", Handler: _Msg_SetMessageReactionExtensions_Handler, @@ -2784,113 +2529,107 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "msg/msg.proto", } -func init() { proto.RegisterFile("msg/msg.proto", fileDescriptor_msg_4f5a59ae8be91efc) } - -var fileDescriptor_msg_4f5a59ae8be91efc = []byte{ - // 1672 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xcd, 0x6e, 0xdb, 0xc6, - 0x16, 0x06, 0x49, 0x4b, 0xb6, 0x8f, 0xec, 0xd8, 0x19, 0x3b, 0xbe, 0x0a, 0x63, 0x20, 0x0a, 0xf3, - 0xa7, 0xdc, 0x24, 0x32, 0xae, 0xef, 0x05, 0x72, 0xd1, 0x14, 0x68, 0xe2, 0xc8, 0x55, 0x8c, 0x94, - 0x75, 0x4c, 0xb9, 0x2d, 0xd0, 0x2e, 0x1c, 0x46, 0x1a, 0x33, 0x84, 0x25, 0x92, 0xe6, 0x50, 0xb1, - 0xd5, 0xbf, 0x5d, 0x8b, 0x02, 0x45, 0x16, 0x5d, 0x76, 0xd5, 0x5d, 0x77, 0x7d, 0x88, 0x3e, 0x40, - 0xd1, 0x07, 0xe9, 0x33, 0xb4, 0x28, 0x66, 0x86, 0x92, 0x86, 0x7f, 0x16, 0x2d, 0x17, 0x41, 0x0a, - 0x74, 0xa7, 0x99, 0x39, 0x73, 0xe6, 0xfb, 0xce, 0xf9, 0xe6, 0x87, 0x47, 0x30, 0xdf, 0x25, 0xd6, - 0x5a, 0x97, 0x58, 0x35, 0xcf, 0x77, 0x03, 0x17, 0x29, 0x5d, 0x62, 0xa9, 0xd5, 0x6d, 0x0f, 0x3b, - 0x77, 0xb7, 0xf4, 0xbb, 0x4d, 0xec, 0xbf, 0xc4, 0xfe, 0x9a, 0x77, 0x60, 0xad, 0xb1, 0xe1, 0x35, - 0xd2, 0x3e, 0xd8, 0x3b, 0x22, 0x6b, 0x47, 0x84, 0x9b, 0xab, 0xb5, 0xb1, 0x96, 0xbe, 0xe9, 0x79, - 0xd8, 0x0f, 0xed, 0xb5, 0xcf, 0xa0, 0xa4, 0x13, 0xab, 0x6e, 0x06, 0xe6, 0xae, 0xab, 0xef, 0xa0, - 0x65, 0x28, 0x04, 0xee, 0x01, 0x76, 0xca, 0x52, 0x45, 0xaa, 0xce, 0x1a, 0xbc, 0x81, 0x2a, 0x50, - 0x72, 0x3d, 0xec, 0x9b, 0x81, 0xed, 0x3a, 0x5b, 0xf5, 0xb2, 0xcc, 0xc6, 0xc4, 0x2e, 0xf4, 0x3f, - 0x98, 0xee, 0x72, 0x37, 0x65, 0xa5, 0x22, 0x55, 0x4b, 0xeb, 0x6a, 0x8d, 0x30, 0x00, 0x7b, 0xa6, - 0x67, 0xef, 0x79, 0xa6, 0x6f, 0x76, 0x49, 0x2d, 0x5c, 0xc8, 0x18, 0x98, 0x6a, 0x58, 0x58, 0xbc, - 0xbe, 0x21, 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, - 0x85, 0x86, 0xb0, 0x53, 0x8b, 0x9a, 0x0d, 0x58, 0x6c, 0xa4, 0x3b, 0x6a, 0x64, 0x3a, 0x6a, 0x9c, - 0xe0, 0x28, 0x25, 0x90, 0x29, 0x55, 0x39, 0xc1, 0x51, 0x22, 0x90, 0x75, 0xa6, 0x72, 0xb1, 0x30, - 0x85, 0xfe, 0x35, 0xb0, 0x8e, 0x15, 0xbe, 0xd4, 0x72, 0xfa, 0x00, 0xf1, 0xd0, 0x01, 0xac, 0x9e, - 0xf4, 0xf1, 0x84, 0xae, 0xe5, 0xf9, 0x58, 0x56, 0xaf, 0xe7, 0xb0, 0x22, 0x1e, 0x3a, 0x82, 0xca, - 0xb8, 0xa7, 0x33, 0xaa, 0xe6, 0xfd, 0x38, 0x50, 0x6f, 0xe5, 0xb4, 0x24, 0x1e, 0x3a, 0x84, 0xd5, - 0x87, 0xed, 0x76, 0x36, 0xcb, 0x9b, 0x39, 0x6b, 0x54, 0x6a, 0x35, 0x9f, 0x21, 0xf1, 0xd0, 0xe7, - 0x70, 0x39, 0x72, 0xc5, 0xa7, 0xac, 0x7a, 0x7b, 0xb0, 0x4b, 0x72, 0x3c, 0xc4, 0xd4, 0x3b, 0xf9, - 0x8d, 0x89, 0xb7, 0x71, 0xe9, 0xe3, 0x8b, 0xdb, 0x1e, 0x76, 0xf6, 0xb6, 0x74, 0xe1, 0x4f, 0xda, - 0x2e, 0xb1, 0xee, 0x77, 0x89, 0xf5, 0xbc, 0xc8, 0x9a, 0xff, 0xfd, 0x33, 0x00, 0x00, 0xff, 0xff, - 0xd4, 0xae, 0xa9, 0xee, 0x0d, 0x1e, 0x00, 0x00, +func init() { proto.RegisterFile("msg/msg.proto", fileDescriptor_msg_69316330d19ec9fa) } + +var fileDescriptor_msg_69316330d19ec9fa = []byte{ + // 1572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xc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, 0x14, 0xa7, 0xd2, 0x69, 0x14, 0x33, 0x69, 0x54, + 0x4e, 0x61, 0x23, 0xa3, 0x8f, 0x78, 0x34, 0xf0, 0x7d, 0xdf, 0xbf, 0xeb, 0xf6, 0x30, 0xd3, 0x58, + 0xd1, 0xc6, 0x24, 0x35, 0xb5, 0xef, 0xfb, 0x2a, 0x31, 0xb8, 0x36, 0x4e, 0x51, 0xbe, 0xaa, 0x0f, + 0x69, 0xa6, 0x68, 0x7e, 0x57, 0x35, 0x4e, 0x31, 0x3e, 0xd3, 0xcb, 0x62, 0xa1, 0x7c, 0x46, 0x29, + 0x1f, 0x01, 0x74, 0xb1, 0xd3, 0x53, 0x89, 0x41, 0x03, 0x28, 0x0f, 0x44, 0x1b, 0x6a, 0xd1, 0x3d, + 0xe2, 0xd1, 0x08, 0x09, 0x6b, 0x19, 0x95, 0x18, 0x51, 0xbe, 0xe2, 0x2c, 0x2a, 0x71, 0x64, 0x99, + 0xd8, 0x09, 0x42, 0x89, 0x4a, 0x28, 0x11, 0x63, 0x21, 0x19, 0x96, 0x08, 0x76, 0x7a, 0x87, 0xa6, + 0x8d, 0xeb, 0xd5, 0x86, 0xd0, 0x94, 0xb4, 0x88, 0x56, 0xae, 0x42, 0xed, 0xae, 0x85, 0x75, 0x9f, + 0xfb, 0xb9, 0x05, 0xd5, 0x41, 0x22, 0xd1, 0x21, 0xa5, 0x9c, 0x83, 0x95, 0x89, 0x18, 0xf1, 0x94, + 0xa7, 0xb0, 0xd6, 0xc5, 0x54, 0x7d, 0xa2, 0x46, 0x79, 0x57, 0x69, 0xaa, 0x0d, 0xdf, 0x1d, 0x78, + 0x51, 0x7d, 0xc6, 0x24, 0xbd, 0x61, 0x87, 0xa9, 0xe3, 0x29, 0x0d, 0x29, 0x05, 0xc1, 0x7a, 0x52, + 0x39, 0xf1, 0x94, 0x5b, 0xb0, 0xd1, 0xc5, 0x01, 0xcf, 0x4c, 0x37, 0xd0, 0x83, 0x01, 0xe1, 0x46, + 0x09, 0x23, 0x98, 0xee, 0x8a, 0xc6, 0x29, 0x65, 0x0b, 0x36, 0xb3, 0xe2, 0xc4, 0x53, 0x3e, 0x66, + 0x70, 0xc8, 0xa8, 0x49, 0x35, 0xb1, 0x90, 0x6d, 0xe2, 0x1f, 0x60, 0xb3, 0x93, 0xa3, 0x90, 0x46, + 0x87, 0x93, 0x40, 0xc2, 0x13, 0x20, 0xe1, 0x04, 0x90, 0x70, 0x04, 0x24, 0xee, 0xb2, 0x94, 0x70, + 0xb9, 0x03, 0x1b, 0x6d, 0x6c, 0x75, 0x07, 0x1e, 0xf6, 0x3b, 0x34, 0x41, 0x99, 0x8a, 0x88, 0x45, + 0x69, 0x95, 0x12, 0x69, 0xa5, 0xb1, 0x67, 0x15, 0x11, 0x4f, 0x39, 0x0a, 0x63, 0x4f, 0x1b, 0x98, + 0x19, 0x3b, 0x5a, 0x07, 0x89, 0x16, 0x49, 0x64, 0x45, 0xa2, 0x7f, 0x4e, 0x31, 0xee, 0x87, 0x79, + 0x4a, 0x1b, 0x9f, 0x23, 0x4f, 0xe5, 0x5b, 0xe6, 0x1e, 0x9b, 0x19, 0x8f, 0x7d, 0x33, 0xc0, 0x6d, + 0xf3, 0xf8, 0x78, 0xfe, 0xb8, 0x94, 0x13, 0x96, 0xa2, 0xa4, 0xa6, 0x37, 0xec, 0xfc, 0xcf, 0x15, + 0x50, 0x54, 0xb7, 0x67, 0x1e, 0x8f, 0xd4, 0x70, 0x48, 0x6a, 0x58, 0x3f, 0xa2, 0x0e, 0xee, 0x0f, + 0x03, 0xec, 0x10, 0xd3, 0x75, 0xca, 0x21, 0x94, 0x75, 0xb9, 0x3b, 0xf0, 0x8f, 0x70, 0x04, 0x95, + 0x88, 0xa6, 0x67, 0xae, 0x97, 0xf8, 0x79, 0x88, 0xe8, 0x70, 0xc2, 0x10, 0x6a, 0xe8, 0x70, 0xe4, + 0x61, 0x36, 0x61, 0x2a, 0x5a, 0x9c, 0x85, 0x86, 0x70, 0xc1, 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0x87, 0xca, 0x5c, 0x25, 0xff, 0x10, 0x6a, 0x64, 0x70, 0x74, + 0x84, 0x09, 0x89, 0x25, 0x10, 0xb1, 0x04, 0x32, 0xdd, 0xe3, 0x0f, 0x3a, 0x2d, 0x2e, 0x86, 0x76, + 0x01, 0x8e, 0x75, 0xd3, 0xc2, 0x3d, 0x76, 0x69, 0xa1, 0xf0, 0x52, 0x4c, 0x4a, 0xf9, 0x4b, 0x84, + 0xf7, 0xdb, 0xd8, 0xc2, 0x01, 0x7e, 0xab, 0x67, 0xc7, 0xec, 0xcf, 0xd2, 0xa2, 0x9f, 0xab, 0xea, + 0x99, 0x7f, 0xae, 0x16, 0x0b, 0x47, 0xf5, 0x7e, 0x11, 0xc2, 0x97, 0x58, 0xae, 0x33, 0x58, 0xc9, + 0x97, 0x56, 0x7e, 0x11, 0xe0, 0x5a, 0xa9, 0x9c, 0xcf, 0x85, 0x9d, 0x33, 0xfc, 0x6a, 0xb8, 0xb0, + 0x9a, 0x40, 0x06, 0xba, 0x09, 0xcb, 0x78, 0xcc, 0x88, 0x56, 0x55, 0x49, 0x00, 0x4d, 0x04, 0xe2, + 0xbe, 0x89, 0x45, 0xbe, 0x49, 0x71, 0xdf, 0x94, 0x3f, 0x44, 0x58, 0x8e, 0x54, 0xa1, 0x67, 0x45, + 0xe9, 0x14, 0x98, 0xe3, 0xd7, 0x93, 0x96, 0x5f, 0x7f, 0x3a, 0x88, 0x65, 0xc7, 0xbc, 0x54, 0x88, + 0x00, 0x25, 0xf5, 0xe0, 0x0a, 0x07, 0x4e, 0xf2, 0x49, 0x75, 0x8e, 0x3d, 0xe1, 0x42, 0x88, 0x8a, + 0x78, 0x28, 0x3f, 0x3d, 0xe3, 0x04, 0xba, 0x96, 0x9c, 0x40, 0x39, 0xf5, 0x8b, 0xcd, 0x20, 0x1b, + 0x56, 0xe2, 0x47, 0xe8, 0x06, 0x2c, 0xf5, 0x39, 0xcd, 0x0b, 0x98, 0x41, 0x65, 0x24, 0x30, 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f9, 0x6a, 0x09, 0x29, 0xe2, 0xa1, 0x53, 0x68, 0xcc, 0x7a, 0x02, 0xa2, 0x66, + 0xd9, 0x47, 0xae, 0x7c, 0xbd, 0xa4, 0x24, 0xf1, 0xd0, 0x09, 0x6c, 0xdf, 0xe9, 0xf5, 0x8a, 0xa3, + 0xbc, 0x56, 0x72, 0xa7, 0x22, 0x37, 0xcb, 0x09, 0x12, 0x0f, 0xfd, 0x08, 0x97, 0x12, 0x3f, 0x61, + 0x39, 0x56, 0x6f, 0x8c, 0x91, 0x55, 0xe2, 0x71, 0x21, 0xdf, 0x2c, 0x2f, 0x4c, 0xbc, 0xbd, 0x77, + 0xbe, 0xbf, 0xf8, 0xc0, 0xc3, 0xce, 0xb3, 0x03, 0x35, 0xf6, 0xbf, 0x1f, 0x9b, 0x18, 0xb7, 0x6d, + 0x62, 0x3c, 0xaf, 0x32, 0xf2, 0x83, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x01, 0x9d, 0x0b, 0x79, + 0x64, 0x1a, 0x00, 0x00, } diff --git a/pkg/proto/msg/msg.proto b/pkg/proto/msg/msg.proto index c6952d2a8..f4cac8ccc 100644 --- a/pkg/proto/msg/msg.proto +++ b/pkg/proto/msg/msg.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "Open-IM-Server/pkg/proto/sdkws/ws.proto"; -import "Open-IM-Server/pkg/proto/sdkws/wrappers.proto"; +import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto"; +import "Open-IM-Server/pkg/proto/sdk_ws/wrappers.proto"; option go_package = "Open_IM/pkg/proto/msg;msg"; package msg; @@ -30,26 +30,6 @@ message MsgDataToMongoByMQ{ } -//message PullMessageReq { -// string UserID = 1; -// int64 SeqBegin = 2; -// int64 SeqEnd = 3; -// string OperationID = 4; -//} -// -//message PullMessageResp { -// int32 ErrCode = 1; -// string ErrMsg = 2; -// int64 MaxSeq = 3; -// int64 MinSeq = 4; -// repeated GatherFormat SingleUserMsg = 5; -// repeated GatherFormat GroupUserMsg = 6; -//} -//message PullMessageBySeqListReq{ -// string UserID = 1; -// string OperationID = 2; -// repeated int64 seqList =3; -//} message GetMaxAndMinSeqReq { string UserID = 1; string OperationID = 2; @@ -62,17 +42,10 @@ message GetMaxAndMinSeqResp { } message SendMsgReq { - -string token =1; -string operationID = 2; -sdkws.MsgData msgData = 3; - - + sdkws.MsgData msgData = 3; } message SendMsgResp { - int32 errCode = 1; - string errMsg = 2; string serverMsgID = 4; string clientMsgID = 5; int64 sendTime = 6; @@ -80,37 +53,26 @@ message SendMsgResp { message ClearMsgReq{ - string userID = 1; - string opUserID = 2; - string operationID = 3; + string userID = 1; } message ClearMsgResp{ - int32 errCode = 1; - string errMsg = 2; } message SetMsgMinSeqReq{ string userID = 1; string groupID = 2; uint32 minSeq = 3; - string operationID = 4; - string opUserID = 5; } message SetMsgMinSeqResp{ - int32 errCode = 1; - string errMsg = 2; } message SetSendMsgStatusReq{ - string operationID = 1; int32 status = 2; } message SetSendMsgStatusResp{ - int32 errCode = 1; - string errMsg = 2; } message GetSendMsgStatusReq{ @@ -123,14 +85,10 @@ message GetSendMsgStatusResp{ int32 status = 3; } message DelSuperGroupMsgReq{ - string opUserID = 1; string userID = 2; string groupID = 3; - string operationID = 4; } message DelSuperGroupMsgResp{ - int32 errCode = 1; - string errMsg = 2; } message GetSuperGroupMsgReq{ string operationID = 1; @@ -267,19 +225,27 @@ message MsgDataToModifyByMQ{ service msg { + //获取最小最大seq(包括用户的,以及指定群组的) rpc GetMaxAndMinSeq(sdkws.GetMaxAndMinSeqReq) returns(sdkws.GetMaxAndMinSeqResp); + //拉取历史消息(包括用户的,以及指定群组的) rpc PullMessageBySeqList(sdkws.PullMessageBySeqListReq) returns(sdkws.PullMessageBySeqListResp); + //发送消息 rpc SendMsg(SendMsgReq) returns(SendMsgResp); + //删除某人消息 rpc DelMsgList(sdkws.DelMsgListReq) returns(sdkws.DelMsgListResp); + //删除某个用户某个大群消息 rpc DelSuperGroupMsg(DelSuperGroupMsgReq) returns(DelSuperGroupMsgResp); + //清空某人所有消息 rpc ClearMsg(ClearMsgReq) returns(ClearMsgResp); - rpc SetMsgMinSeq(SetMsgMinSeqReq) returns(SetMsgMinSeqResp); + + //设置消息是否发送成功-针对api发送的消息 rpc SetSendMsgStatus(SetSendMsgStatusReq) returns(SetSendMsgStatusResp); + //获取消息发送状态 rpc GetSendMsgStatus(GetSendMsgStatusReq) returns(GetSendMsgStatusResp); - rpc GetSuperGroupMsg(GetSuperGroupMsgReq) returns(GetSuperGroupMsgResp); - rpc GetWriteDiffMsg(GetWriteDiffMsgReq) returns(GetWriteDiffMsgResp); - // modify msg + + + // 修改消息 rpc SetMessageReactionExtensions(SetMessageReactionExtensionsReq) returns(SetMessageReactionExtensionsResp); rpc GetMessageListReactionExtensions(GetMessageListReactionExtensionsReq) returns(GetMessageListReactionExtensionsResp); rpc AddMessageReactionExtensions(ModifyMessageReactionExtensionsReq) returns(ModifyMessageReactionExtensionsResp); diff --git a/pkg/proto/sdkws/ws.proto b/pkg/proto/sdkws/ws.proto index bc1122e4b..6f1c6a5fe 100644 --- a/pkg/proto/sdkws/ws.proto +++ b/pkg/proto/sdkws/ws.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "Open-IM-Server/pkg/proto/sdkws/wrappers.proto"; -option go_package = "Open_IM/pkg/proto/sdkws;sdkws"; +import "Open-IM-Server/pkg/proto/sdk_ws/wrappers.proto"; +option go_package = "Open_IM/pkg/proto/sdk_ws;sdkws"; package sdkws; @@ -132,7 +132,6 @@ message FriendRequest{ ///////////////////////////////////base end///////////////////////////////////// message PullMessageBySeqListReq{ string userID = 1; - string operationID = 2; repeated uint32 seqList = 3; map groupSeqList = 4; } @@ -158,7 +157,6 @@ message PullMessageBySeqListResp { message GetMaxAndMinSeqReq { repeated string groupIDList = 1; string userID = 2; - string operationID = 3; } message MaxAndMinSeq{ uint32 maxSeq = 1; @@ -167,8 +165,6 @@ message MaxAndMinSeq{ message GetMaxAndMinSeqResp { uint32 maxSeq = 1; uint32 minSeq = 2; - int32 errCode = 3; - string errMsg = 4; map groupMaxAndMinSeq = 5; } @@ -612,15 +608,11 @@ message SignalGetTokenByRoomIDReply { message DelMsgListReq{ - string opUserID = 1; string userID = 2; repeated uint32 seqList = 3; - string operationID = 4; } message DelMsgListResp{ - int32 errCode = 1; - string errMsg = 2; } message SetAppBackgroundStatusReq { From 452d9840bfbef72691e8f5d4d35921c5b64959fa Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 10 Feb 2023 22:10:37 +0800 Subject: [PATCH 04/48] Error code standardization --- internal/common/notification/c.go | 289 +++++ ...sation_notification.go => conversation.go} | 0 .../notification/extend_msg.notification.go | 100 -- .../notification/extend_msg_callback.go | 62 - .../notification/friend_notification.go | 174 --- .../common/notification/group_notification.go | 622 --------- .../common/notification/msg_notification.go | 48 - .../notification/super_group_notification.go | 24 - internal/rpc/friend/friend.go | 1 - internal/rpc/msg/chat.go | 63 - internal/rpc/msg/{del_msg.go => delete.go} | 27 + internal/rpc/msg/pull_message.go | 126 -- internal/rpc/msg/query_msg.go | 4 - internal/rpc/msg/send_msg.go | 591 +-------- internal/rpc/msg/send_pull.go | 403 ++++++ internal/rpc/msg/{rpc_chat.go => server.go} | 19 +- pkg/common/db/controller/msg.go | 4 + pkg/proto/msg/msg.pb.go | 504 ++++---- pkg/proto/msg/msg.proto | 4 +- pkg/proto/sdkws/ws.pb.go | 1149 +++++------------ pkg/proto/sdkws/ws.proto | 4 +- 21 files changed, 1308 insertions(+), 2910 deletions(-) create mode 100644 internal/common/notification/c.go rename internal/common/notification/{conversation_notification.go => conversation.go} (100%) delete mode 100644 internal/common/notification/extend_msg.notification.go delete mode 100644 internal/common/notification/extend_msg_callback.go delete mode 100644 internal/common/notification/friend_notification.go delete mode 100644 internal/common/notification/group_notification.go delete mode 100644 internal/common/notification/msg_notification.go delete mode 100644 internal/common/notification/super_group_notification.go delete mode 100644 internal/rpc/msg/chat.go rename internal/rpc/msg/{del_msg.go => delete.go} (59%) delete mode 100644 internal/rpc/msg/pull_message.go create mode 100644 internal/rpc/msg/send_pull.go rename internal/rpc/msg/{rpc_chat.go => server.go} (91%) diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go new file mode 100644 index 000000000..32f1bef7a --- /dev/null +++ b/internal/common/notification/c.go @@ -0,0 +1,289 @@ +package notification + +import ( + "Open_IM/pkg/common/constant" + pbChat "Open_IM/pkg/proto/msg" + "strings" +) + +type NotificationMsg struct { + SendID string + RecvID string + Content []byte // sdkws.TipsComm + MsgFrom int32 + ContentType int32 + SessionType int32 + OperationID string + SenderNickname string + SenderFaceURL string +} + +func Notification(n *NotificationMsg) { + var req pbChat.SendMsgReq + var msg sdkws.MsgData + var offlineInfo sdkws.OfflinePushInfo + var title, desc, ex string + var pushSwitch, unReadCount bool + var reliabilityLevel int + req.OperationID = n.OperationID + msg.SendID = n.SendID + msg.RecvID = n.RecvID + msg.Content = n.Content + msg.MsgFrom = n.MsgFrom + msg.ContentType = n.ContentType + msg.SessionType = n.SessionType + msg.CreateTime = utils.GetCurrentTimestampByMill() + msg.ClientMsgID = utils.GetMsgID(n.SendID) + msg.Options = make(map[string]bool, 7) + msg.SenderNickname = n.SenderNickname + msg.SenderFaceURL = n.SenderFaceURL + switch n.SessionType { + case constant.GroupChatType, constant.SuperGroupChatType: + msg.RecvID = "" + msg.GroupID = n.RecvID + } + offlineInfo.IOSBadgeCount = config.Config.IOSPush.BadgeCount + offlineInfo.IOSPushSound = config.Config.IOSPush.PushSound + switch msg.ContentType { + case constant.GroupCreatedNotification: + pushSwitch = config.Config.Notification.GroupCreated.OfflinePush.PushSwitch + title = config.Config.Notification.GroupCreated.OfflinePush.Title + desc = config.Config.Notification.GroupCreated.OfflinePush.Desc + ex = config.Config.Notification.GroupCreated.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupCreated.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupCreated.Conversation.UnreadCount + case constant.GroupInfoSetNotification: + pushSwitch = config.Config.Notification.GroupInfoSet.OfflinePush.PushSwitch + title = config.Config.Notification.GroupInfoSet.OfflinePush.Title + desc = config.Config.Notification.GroupInfoSet.OfflinePush.Desc + ex = config.Config.Notification.GroupInfoSet.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupInfoSet.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupInfoSet.Conversation.UnreadCount + case constant.JoinGroupApplicationNotification: + pushSwitch = config.Config.Notification.JoinGroupApplication.OfflinePush.PushSwitch + title = config.Config.Notification.JoinGroupApplication.OfflinePush.Title + desc = config.Config.Notification.JoinGroupApplication.OfflinePush.Desc + ex = config.Config.Notification.JoinGroupApplication.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.JoinGroupApplication.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.JoinGroupApplication.Conversation.UnreadCount + case constant.MemberQuitNotification: + pushSwitch = config.Config.Notification.MemberQuit.OfflinePush.PushSwitch + title = config.Config.Notification.MemberQuit.OfflinePush.Title + desc = config.Config.Notification.MemberQuit.OfflinePush.Desc + ex = config.Config.Notification.MemberQuit.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.MemberQuit.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.MemberQuit.Conversation.UnreadCount + case constant.GroupApplicationAcceptedNotification: + pushSwitch = config.Config.Notification.GroupApplicationAccepted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Title + desc = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Desc + ex = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupApplicationAccepted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupApplicationAccepted.Conversation.UnreadCount + case constant.GroupApplicationRejectedNotification: + pushSwitch = config.Config.Notification.GroupApplicationRejected.OfflinePush.PushSwitch + title = config.Config.Notification.GroupApplicationRejected.OfflinePush.Title + desc = config.Config.Notification.GroupApplicationRejected.OfflinePush.Desc + ex = config.Config.Notification.GroupApplicationRejected.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupApplicationRejected.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupApplicationRejected.Conversation.UnreadCount + case constant.GroupOwnerTransferredNotification: + pushSwitch = config.Config.Notification.GroupOwnerTransferred.OfflinePush.PushSwitch + title = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Title + desc = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Desc + ex = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupOwnerTransferred.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupOwnerTransferred.Conversation.UnreadCount + case constant.MemberKickedNotification: + pushSwitch = config.Config.Notification.MemberKicked.OfflinePush.PushSwitch + title = config.Config.Notification.MemberKicked.OfflinePush.Title + desc = config.Config.Notification.MemberKicked.OfflinePush.Desc + ex = config.Config.Notification.MemberKicked.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.MemberKicked.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.MemberKicked.Conversation.UnreadCount + case constant.MemberInvitedNotification: + pushSwitch = config.Config.Notification.MemberInvited.OfflinePush.PushSwitch + title = config.Config.Notification.MemberInvited.OfflinePush.Title + desc = config.Config.Notification.MemberInvited.OfflinePush.Desc + ex = config.Config.Notification.MemberInvited.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.MemberInvited.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.MemberInvited.Conversation.UnreadCount + case constant.MemberEnterNotification: + pushSwitch = config.Config.Notification.MemberEnter.OfflinePush.PushSwitch + title = config.Config.Notification.MemberEnter.OfflinePush.Title + desc = config.Config.Notification.MemberEnter.OfflinePush.Desc + ex = config.Config.Notification.MemberEnter.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.MemberEnter.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.MemberEnter.Conversation.UnreadCount + case constant.UserInfoUpdatedNotification: + pushSwitch = config.Config.Notification.UserInfoUpdated.OfflinePush.PushSwitch + title = config.Config.Notification.UserInfoUpdated.OfflinePush.Title + desc = config.Config.Notification.UserInfoUpdated.OfflinePush.Desc + ex = config.Config.Notification.UserInfoUpdated.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.UserInfoUpdated.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.UserInfoUpdated.Conversation.UnreadCount + case constant.FriendApplicationNotification: + pushSwitch = config.Config.Notification.FriendApplication.OfflinePush.PushSwitch + title = config.Config.Notification.FriendApplication.OfflinePush.Title + desc = config.Config.Notification.FriendApplication.OfflinePush.Desc + ex = config.Config.Notification.FriendApplication.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.FriendApplication.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.FriendApplication.Conversation.UnreadCount + case constant.FriendApplicationApprovedNotification: + pushSwitch = config.Config.Notification.FriendApplicationApproved.OfflinePush.PushSwitch + title = config.Config.Notification.FriendApplicationApproved.OfflinePush.Title + desc = config.Config.Notification.FriendApplicationApproved.OfflinePush.Desc + ex = config.Config.Notification.FriendApplicationApproved.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.FriendApplicationApproved.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.FriendApplicationApproved.Conversation.UnreadCount + case constant.FriendApplicationRejectedNotification: + pushSwitch = config.Config.Notification.FriendApplicationRejected.OfflinePush.PushSwitch + title = config.Config.Notification.FriendApplicationRejected.OfflinePush.Title + desc = config.Config.Notification.FriendApplicationRejected.OfflinePush.Desc + ex = config.Config.Notification.FriendApplicationRejected.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.FriendApplicationRejected.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.FriendApplicationRejected.Conversation.UnreadCount + case constant.FriendAddedNotification: + pushSwitch = config.Config.Notification.FriendAdded.OfflinePush.PushSwitch + title = config.Config.Notification.FriendAdded.OfflinePush.Title + desc = config.Config.Notification.FriendAdded.OfflinePush.Desc + ex = config.Config.Notification.FriendAdded.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.FriendAdded.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.FriendAdded.Conversation.UnreadCount + case constant.FriendDeletedNotification: + pushSwitch = config.Config.Notification.FriendDeleted.OfflinePush.PushSwitch + title = config.Config.Notification.FriendDeleted.OfflinePush.Title + desc = config.Config.Notification.FriendDeleted.OfflinePush.Desc + ex = config.Config.Notification.FriendDeleted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.FriendDeleted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.FriendDeleted.Conversation.UnreadCount + case constant.FriendRemarkSetNotification: + pushSwitch = config.Config.Notification.FriendRemarkSet.OfflinePush.PushSwitch + title = config.Config.Notification.FriendRemarkSet.OfflinePush.Title + desc = config.Config.Notification.FriendRemarkSet.OfflinePush.Desc + ex = config.Config.Notification.FriendRemarkSet.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.FriendRemarkSet.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.FriendRemarkSet.Conversation.UnreadCount + case constant.BlackAddedNotification: + pushSwitch = config.Config.Notification.BlackAdded.OfflinePush.PushSwitch + title = config.Config.Notification.BlackAdded.OfflinePush.Title + desc = config.Config.Notification.BlackAdded.OfflinePush.Desc + ex = config.Config.Notification.BlackAdded.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.BlackAdded.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.BlackAdded.Conversation.UnreadCount + case constant.BlackDeletedNotification: + pushSwitch = config.Config.Notification.BlackDeleted.OfflinePush.PushSwitch + title = config.Config.Notification.BlackDeleted.OfflinePush.Title + desc = config.Config.Notification.BlackDeleted.OfflinePush.Desc + ex = config.Config.Notification.BlackDeleted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.BlackDeleted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.BlackDeleted.Conversation.UnreadCount + case constant.ConversationOptChangeNotification: + pushSwitch = config.Config.Notification.ConversationOptUpdate.OfflinePush.PushSwitch + title = config.Config.Notification.ConversationOptUpdate.OfflinePush.Title + desc = config.Config.Notification.ConversationOptUpdate.OfflinePush.Desc + ex = config.Config.Notification.ConversationOptUpdate.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.ConversationOptUpdate.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.ConversationOptUpdate.Conversation.UnreadCount + + case constant.GroupDismissedNotification: + pushSwitch = config.Config.Notification.GroupDismissed.OfflinePush.PushSwitch + title = config.Config.Notification.GroupDismissed.OfflinePush.Title + desc = config.Config.Notification.GroupDismissed.OfflinePush.Desc + ex = config.Config.Notification.GroupDismissed.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupDismissed.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupDismissed.Conversation.UnreadCount + + case constant.GroupMutedNotification: + pushSwitch = config.Config.Notification.GroupMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupMuted.OfflinePush.Title + desc = config.Config.Notification.GroupMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupMuted.Conversation.UnreadCount + + case constant.GroupCancelMutedNotification: + pushSwitch = config.Config.Notification.GroupCancelMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupCancelMuted.OfflinePush.Title + desc = config.Config.Notification.GroupCancelMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupCancelMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupCancelMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupCancelMuted.Conversation.UnreadCount + + case constant.GroupMemberMutedNotification: + pushSwitch = config.Config.Notification.GroupMemberMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupMemberMuted.OfflinePush.Title + desc = config.Config.Notification.GroupMemberMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupMemberMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupMemberMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupMemberMuted.Conversation.UnreadCount + + case constant.GroupMemberCancelMutedNotification: + pushSwitch = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Title + desc = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount + + case constant.GroupMemberInfoSetNotification: + pushSwitch = config.Config.Notification.GroupMemberInfoSet.OfflinePush.PushSwitch + title = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Title + desc = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Desc + ex = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupMemberInfoSet.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupMemberInfoSet.Conversation.UnreadCount + + case constant.ConversationPrivateChatNotification: + pushSwitch = config.Config.Notification.ConversationSetPrivate.OfflinePush.PushSwitch + title = config.Config.Notification.ConversationSetPrivate.OfflinePush.Title + desc = config.Config.Notification.ConversationSetPrivate.OfflinePush.Desc + ex = config.Config.Notification.ConversationSetPrivate.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.ConversationSetPrivate.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.ConversationSetPrivate.Conversation.UnreadCount + case constant.FriendInfoUpdatedNotification: + pushSwitch = config.Config.Notification.FriendInfoUpdated.OfflinePush.PushSwitch + title = config.Config.Notification.FriendInfoUpdated.OfflinePush.Title + desc = config.Config.Notification.FriendInfoUpdated.OfflinePush.Desc + ex = config.Config.Notification.FriendInfoUpdated.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.FriendInfoUpdated.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.FriendInfoUpdated.Conversation.UnreadCount + case constant.DeleteMessageNotification: + reliabilityLevel = constant.ReliableNotificationNoMsg + case constant.ConversationUnreadNotification, constant.SuperGroupUpdateNotification: + reliabilityLevel = constant.UnreliableNotification + } + switch reliabilityLevel { + case constant.UnreliableNotification: + utils.SetSwitchFromOptions(msg.Options, constant.IsHistory, false) + utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false) + utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false) + utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false) + case constant.ReliableNotificationNoMsg: + utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false) + utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false) + case constant.ReliableNotificationMsg: + + } + utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, unReadCount) + utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, pushSwitch) + offlineInfo.Title = title + offlineInfo.Desc = desc + offlineInfo.Ex = ex + msg.OfflinePushInfo = &offlineInfo + req.MsgData = &msg + etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID) + if etcdConn == nil { + errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil" + log.NewError(req.OperationID, errMsg) + return + } + + client := pbChat.NewMsgClient(etcdConn) + reply, err := client.SendMsg(context.Background(), &req) + if err != nil { + log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), err.Error()) + } else if reply.ErrCode != 0 { + log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), reply.ErrCode, reply.ErrMsg) + } +} diff --git a/internal/common/notification/conversation_notification.go b/internal/common/notification/conversation.go similarity index 100% rename from internal/common/notification/conversation_notification.go rename to internal/common/notification/conversation.go diff --git a/internal/common/notification/extend_msg.notification.go b/internal/common/notification/extend_msg.notification.go deleted file mode 100644 index 5a3b78a07..000000000 --- a/internal/common/notification/extend_msg.notification.go +++ /dev/null @@ -1,100 +0,0 @@ -package notification - -import ( - "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" - "Open_IM/pkg/proto/msg" - sdkws "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" - "context" -) - -func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32, - req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) { - var m apistruct.ReactionMessageModifierNotification - m.SourceID = req.SourceID - m.OpUserID = req.OpUserID - m.SessionType = req.SessionType - keyMap := make(map[string]*sdkws.KeyValue) - for _, valueResp := range resp.Result { - if valueResp.ErrCode == 0 { - keyMap[valueResp.KeyValue.TypeKey] = valueResp.KeyValue - } - } - if len(keyMap) == 0 { - log.NewWarn(operationID, "all key set failed can not send notification", *req) - return - } - m.SuccessReactionExtensionList = keyMap - m.ClientMsgID = req.ClientMsgID - m.IsReact = resp.IsReact - m.IsExternalExtensions = req.IsExternalExtensions - m.MsgFirstModifyTime = resp.MsgFirstModifyTime - messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache) -} -func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, sessionType int32, - req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) { - var m apistruct.ReactionMessageDeleteNotification - m.SourceID = req.SourceID - m.OpUserID = req.OpUserID - m.SessionType = req.SessionType - keyMap := make(map[string]*sdkws.KeyValue) - for _, valueResp := range resp.Result { - if valueResp.ErrCode == 0 { - keyMap[valueResp.KeyValue.TypeKey] = valueResp.KeyValue - } - } - if len(keyMap) == 0 { - log.NewWarn(operationID, "all key set failed can not send notification", *req) - return - } - m.SuccessReactionExtensionList = keyMap - m.ClientMsgID = req.ClientMsgID - m.MsgFirstModifyTime = req.MsgFirstModifyTime - - messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache) -} -func messageReactionSender(operationID, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) { - options := make(map[string]bool, 5) - utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false) - utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false) - utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false) - utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false) - utils.SetSwitchFromOptions(options, constant.IsReactionFromCache, isReactionFromCache) - if !isHistory { - utils.SetSwitchFromOptions(options, constant.IsHistory, false) - utils.SetSwitchFromOptions(options, constant.IsPersistent, false) - } - pbData := msg.SendMsgReq{ - OperationID: operationID, - MsgData: &sdkws.MsgData{ - SendID: sendID, - ClientMsgID: utils.GetMsgID(sendID), - SessionType: sessionType, - MsgFrom: constant.SysMsgType, - ContentType: contentType, - Content: []byte(content), - // ForceList: params.ForceList, - CreateTime: utils.GetCurrentTimestampByMill(), - Options: options, - }, - } - switch sessionType { - case constant.SingleChatType, constant.NotificationChatType: - pbData.MsgData.RecvID = sourceID - case constant.GroupChatType, constant.SuperGroupChatType: - pbData.MsgData.GroupID = sourceID - } - etcdConn, err := rpc.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName) - if err != nil { - return - } - client := msg.NewMsgClient(etcdConn) - reply, err := client.SendMsg(context.Background(), &pbData) - if err != nil { - log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), err.Error()) - } else if reply.ErrCode != 0 { - log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), reply.ErrCode, reply.ErrMsg) - } -} diff --git a/internal/common/notification/extend_msg_callback.go b/internal/common/notification/extend_msg_callback.go deleted file mode 100644 index 39958e4f0..000000000 --- a/internal/common/notification/extend_msg_callback.go +++ /dev/null @@ -1,62 +0,0 @@ -package notification - -import ( - cbApi "Open_IM/pkg/callback_struct" - "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/http" - "Open_IM/pkg/common/log" - "Open_IM/pkg/proto/msg" - "Open_IM/pkg/utils" - http2 "net/http" -) - -func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensionsReq) *cbApi.CallbackBeforeSetMessageReactionExtResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} - log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) - req := cbApi.CallbackBeforeSetMessageReactionExtReq{ - OperationID: setReq.OperationID, - CallbackCommand: constant.CallbackBeforeSetMessageReactionExtensionCommand, - SourceID: setReq.SourceID, - OpUserID: setReq.OpUserID, - SessionType: setReq.SessionType, - ReactionExtensionList: setReq.ReactionExtensionList, - ClientMsgID: setReq.ClientMsgID, - IsReact: setReq.IsReact, - IsExternalExtensions: setReq.IsExternalExtensions, - MsgFirstModifyTime: setReq.MsgFirstModifyTime, - } - resp := &cbApi.CallbackBeforeSetMessageReactionExtResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetMessageReactionExtensionCommand, - req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut, nil); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return resp - -} - -func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReactionExtensionsReq) *cbApi.CallbackDeleteMessageReactionExtResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} - log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) - req := cbApi.CallbackDeleteMessageReactionExtReq{ - OperationID: setReq.OperationID, - CallbackCommand: constant.CallbackBeforeDeleteMessageReactionExtensionsCommand, - SourceID: setReq.SourceID, - OpUserID: setReq.OpUserID, - SessionType: setReq.SessionType, - ReactionExtensionList: setReq.ReactionExtensionList, - ClientMsgID: setReq.ClientMsgID, - IsExternalExtensions: setReq.IsExternalExtensions, - MsgFirstModifyTime: setReq.MsgFirstModifyTime, - } - resp := &cbApi.CallbackDeleteMessageReactionExtResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeDeleteMessageReactionExtensionsCommand, - req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut, nil); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return resp -} diff --git a/internal/common/notification/friend_notification.go b/internal/common/notification/friend_notification.go deleted file mode 100644 index 2ade47709..000000000 --- a/internal/common/notification/friend_notification.go +++ /dev/null @@ -1,174 +0,0 @@ -package notification - -import ( - "Open_IM/internal/common/check" - "Open_IM/internal/rpc/msg" - "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/tracelog" - pbFriend "Open_IM/pkg/proto/friend" - sdkws "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" - "context" - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" -) - -func getFromToUserNickname(fromUserID, toUserID string) (string, string, error) { - users, err := check.GetUsersInfo(context.Background(), fromUserID, toUserID) - if err != nil { - return "", "", nil - } - if users[0].UserID == fromUserID { - return users[0].Nickname, users[1].Nickname, nil - } - return users[1].Nickname, users[0].Nickname, nil - -} - -func friendNotification(operationID, fromUserID, toUserID string, contentType int32, m proto.Message) { - log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType) - var err error - var tips sdkws.TipsComm - tips.Detail, err = proto.Marshal(m) - if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), m.String()) - return - } - - marshaler := jsonpb.Marshaler{ - OrigName: true, - EnumsAsInts: false, - EmitDefaults: false, - } - - tips.JsonDetail, _ = marshaler.MarshalToString(m) - - fromUserNickname, toUserNickname, err := getFromToUserNickname(fromUserID, toUserID) - if err != nil { - log.Error(operationID, "getFromToUserNickname failed ", err.Error(), fromUserID, toUserID) - return - } - cn := config.Config.Notification - switch contentType { - case constant.FriendApplicationNotification: - tips.DefaultTips = fromUserNickname + cn.FriendApplication.DefaultTips.Tips - case constant.FriendApplicationApprovedNotification: - tips.DefaultTips = fromUserNickname + cn.FriendApplicationApproved.DefaultTips.Tips - case constant.FriendApplicationRejectedNotification: - tips.DefaultTips = fromUserNickname + cn.FriendApplicationRejected.DefaultTips.Tips - case constant.FriendAddedNotification: - tips.DefaultTips = cn.FriendAdded.DefaultTips.Tips - case constant.FriendDeletedNotification: - tips.DefaultTips = cn.FriendDeleted.DefaultTips.Tips + toUserNickname - case constant.FriendRemarkSetNotification: - tips.DefaultTips = fromUserNickname + cn.FriendRemarkSet.DefaultTips.Tips - case constant.BlackAddedNotification: - tips.DefaultTips = cn.BlackAdded.DefaultTips.Tips - case constant.BlackDeletedNotification: - tips.DefaultTips = cn.BlackDeleted.DefaultTips.Tips + toUserNickname - case constant.UserInfoUpdatedNotification: - tips.DefaultTips = cn.UserInfoUpdated.DefaultTips.Tips - case constant.FriendInfoUpdatedNotification: - tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname - default: - log.Error(operationID, "contentType failed ", contentType) - return - } - - var n msg.NotificationMsg - n.SendID = fromUserID - n.RecvID = toUserID - n.ContentType = contentType - n.SessionType = constant.SingleChatType - n.MsgFrom = constant.SysMsgType - n.OperationID = operationID - n.Content, err = proto.Marshal(&tips) - if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) - return - } - msg.Notification(&n) -} - -func FriendApplicationAddNotification(ctx context.Context, req *pbFriend.AddFriendReq) { - FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}} - FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID - FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID - friendNotification(tracelog.GetOperationID(ctx), req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips) -} - -func FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { - FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}} - FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID - FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID - FriendApplicationApprovedTips.HandleMsg = req.HandleMsg - friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips) -} - -func FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { - FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}} - FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID - FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID - FriendApplicationApprovedTips.HandleMsg = req.HandleMsg - friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips) -} - -func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) { - friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}} - user, err := check.GetUsersInfo(context.Background(), opUserID) - if err != nil { - return - } - friendAddedTips.OpUser.UserID = user[0].UserID - friendAddedTips.OpUser.Ex = user[0].Ex - friendAddedTips.OpUser.Nickname = user[0].Nickname - friendAddedTips.OpUser.FaceURL = user[0].FaceURL - - friend, err := check.GetFriendsInfo(ctx, fromUserID, toUserID) - if err != nil { - return - } - friendAddedTips.Friend = friend - friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips) -} - -func FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) { - friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}} - friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID - friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID - friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips) -} - -func FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) { - friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}} - friendInfoChangedTips.FromToUserID.FromUserID = fromUserID - friendInfoChangedTips.FromToUserID.ToUserID = toUserID - friendNotification(tracelog.GetOperationID(ctx), fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips) -} - -func BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) { - blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}} - blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID - blackAddedTips.FromToUserID.ToUserID = req.BlackUserID - friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips) -} - -func BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) { - blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}} - blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID - blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID - friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips) -} - -// send to myself -func UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) { - selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} - friendNotification(tracelog.GetOperationID(ctx), opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) -} - -func FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { - selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} - friendNotification(tracelog.GetOperationID(ctx), opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips) -} diff --git a/internal/common/notification/group_notification.go b/internal/common/notification/group_notification.go deleted file mode 100644 index c3982ed6d..000000000 --- a/internal/common/notification/group_notification.go +++ /dev/null @@ -1,622 +0,0 @@ -package notification - -import ( - "Open_IM/internal/rpc/msg" - "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/tokenverify" - utils2 "Open_IM/pkg/common/utils" - pbGroup "Open_IM/pkg/proto/group" - "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" - "context" - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" - "google.golang.org/protobuf/types/known/wrapperspb" -) - -//message GroupCreatedTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo Creator = 2; -// repeated GroupMemberFullInfo MemberList = 3; -// uint64 OperationTime = 4; -//} creator->group - -func setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { - if tokenverify.IsManagerUserID(opUserID) { - u, err := imdb.GetUserByUserID(opUserID) - if err != nil { - return utils.Wrap(err, "GetUserByUserID failed") - } - utils.CopyStructFields(groupMemberInfo, u) - groupMemberInfo.GroupID = groupID - } else { - u, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, opUserID) - if err == nil { - if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, u); err != nil { - return utils.Wrap(err, "") - } - } - user, err := imdb.GetUserByUserID(opUserID) - if err != nil { - return utils.Wrap(err, "") - } - groupMemberInfo.GroupID = groupID - groupMemberInfo.UserID = user.UserID - groupMemberInfo.Nickname = user.Nickname - groupMemberInfo.AppMangerLevel = user.AppMangerLevel - groupMemberInfo.FaceURL = user.FaceURL - } - return nil -} - -func setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error { - group, err := imdb.GetGroupInfoByGroupID(groupID) - if err != nil { - return utils.Wrap(err, "GetGroupInfoByGroupID failed") - } - err = utils2.GroupDBCopyOpenIM(groupInfo, group) - if err != nil { - log.NewWarn("", "GroupDBCopyOpenIM failed ", groupID, err.Error()) - return nil - } - return nil -} - -func setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { - groupMember, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID) - if err == nil { - return utils.Wrap(utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember), "") - } - - user, err := imdb.GetUserByUserID(userID) - if err != nil { - return utils.Wrap(err, "") - } - groupMemberInfo.GroupID = groupID - groupMemberInfo.UserID = user.UserID - groupMemberInfo.Nickname = user.Nickname - groupMemberInfo.AppMangerLevel = user.AppMangerLevel - groupMemberInfo.FaceURL = user.FaceURL - return nil -} - -func setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { - groupMember, err := imdb.GetGroupOwnerInfoByGroupID(groupID) - if err != nil { - return utils.Wrap(err, "") - } - if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember); err != nil { - return utils.Wrap(err, "") - } - return nil -} - -func setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error { - user, err := imdb.GetUserByUserID(userID) - if err != nil { - return utils.Wrap(err, "") - } - utils2.UserDBCopyOpenIMPublicUser(publicUserInfo, user) - return nil -} - -func groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) { - log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID) - - var err error - var tips sdkws.TipsComm - tips.Detail, err = proto.Marshal(m) - if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), m.String()) - return - } - marshaler := jsonpb.Marshaler{ - OrigName: true, - EnumsAsInts: false, - EmitDefaults: false, - } - - tips.JsonDetail, _ = marshaler.MarshalToString(m) - var nickname string - - from, err := imdb.GetUserByUserID(sendID) - if err != nil { - log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID) - } - if from != nil { - nickname = from.Nickname - } - - to, err := imdb.GetUserByUserID(recvUserID) - if err != nil { - log.NewWarn(operationID, "GetUserByUserID failed ", err.Error(), recvUserID) - } - toNickname := "" - if to != nil { - toNickname = to.Nickname - } - - cn := config.Config.Notification - switch contentType { - case constant.GroupCreatedNotification: - tips.DefaultTips = nickname + " " + cn.GroupCreated.DefaultTips.Tips - case constant.GroupInfoSetNotification: - tips.DefaultTips = nickname + " " + cn.GroupInfoSet.DefaultTips.Tips - case constant.JoinGroupApplicationNotification: - tips.DefaultTips = nickname + " " + cn.JoinGroupApplication.DefaultTips.Tips - case constant.MemberQuitNotification: - tips.DefaultTips = nickname + " " + cn.MemberQuit.DefaultTips.Tips - case constant.GroupApplicationAcceptedNotification: // - tips.DefaultTips = toNickname + " " + cn.GroupApplicationAccepted.DefaultTips.Tips - case constant.GroupApplicationRejectedNotification: // - tips.DefaultTips = toNickname + " " + cn.GroupApplicationRejected.DefaultTips.Tips - case constant.GroupOwnerTransferredNotification: // - tips.DefaultTips = toNickname + " " + cn.GroupOwnerTransferred.DefaultTips.Tips - case constant.MemberKickedNotification: // - tips.DefaultTips = toNickname + " " + cn.MemberKicked.DefaultTips.Tips - case constant.MemberInvitedNotification: // - tips.DefaultTips = toNickname + " " + cn.MemberInvited.DefaultTips.Tips - case constant.MemberEnterNotification: - tips.DefaultTips = toNickname + " " + cn.MemberEnter.DefaultTips.Tips - case constant.GroupDismissedNotification: - tips.DefaultTips = toNickname + "" + cn.GroupDismissed.DefaultTips.Tips - case constant.GroupMutedNotification: - tips.DefaultTips = toNickname + "" + cn.GroupMuted.DefaultTips.Tips - case constant.GroupCancelMutedNotification: - tips.DefaultTips = toNickname + "" + cn.GroupCancelMuted.DefaultTips.Tips - case constant.GroupMemberMutedNotification: - tips.DefaultTips = toNickname + "" + cn.GroupMemberMuted.DefaultTips.Tips - case constant.GroupMemberCancelMutedNotification: - tips.DefaultTips = toNickname + "" + cn.GroupMemberCancelMuted.DefaultTips.Tips - case constant.GroupMemberInfoSetNotification: - tips.DefaultTips = toNickname + "" + cn.GroupMemberInfoSet.DefaultTips.Tips - case constant.GroupMemberSetToAdminNotification: - tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToAdmin.DefaultTips.Tips - case constant.GroupMemberSetToOrdinaryUserNotification: - tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips - default: - log.Error(operationID, "contentType failed ", contentType) - return - } - - var n msg.NotificationMsg - n.SendID = sendID - if groupID != "" { - n.RecvID = groupID - group, err := imdb.GetGroupInfoByGroupID(groupID) - if err != nil { - log.NewError(operationID, "GetGroupInfoByGroupID failed ", err.Error(), groupID) - } - switch group.GroupType { - case constant.NormalGroup: - n.SessionType = constant.GroupChatType - default: - n.SessionType = constant.SuperGroupChatType - } - } else { - n.RecvID = recvUserID - n.SessionType = constant.SingleChatType - } - n.ContentType = contentType - n.OperationID = operationID - n.Content, err = proto.Marshal(&tips) - if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) - return - } - msg.Notification(&n) -} - -// 创建群后调用 -func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) { - GroupCreatedTips := sdkws.GroupCreatedTips{Group: &sdkws.GroupInfo{}, - OpUser: &sdkws.GroupMemberFullInfo{}, GroupOwnerUser: &sdkws.GroupMemberFullInfo{}} - if err := setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil { - log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser) - return - } - err := setGroupInfo(groupID, GroupCreatedTips.Group) - if err != nil { - log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group) - return - } - imdb.GetGroupOwnerInfoByGroupID(groupID) - if err := setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil { - log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID) - return - } - for _, v := range initMemberList { - var groupMemberInfo sdkws.GroupMemberFullInfo - if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v) - continue - } - GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo) - if len(GroupCreatedTips.MemberList) == constant.MaxNotificationNum { - break - } - } - groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID) -} - -// 群信息改变后掉用 -// groupName := "" -// -// notification := "" -// introduction := "" -// faceURL := "" -func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) { - GroupInfoChangedTips := sdkws.GroupInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - GroupInfoChangedTips.Group.GroupName = groupName - GroupInfoChangedTips.Group.Notification = notification - GroupInfoChangedTips.Group.Introduction = introduction - GroupInfoChangedTips.Group.FaceURL = faceURL - if needVerification != nil { - GroupInfoChangedTips.Group.NeedVerification = needVerification.Value - } - - if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID) -} - -func GroupMutedNotification(operationID, opUserID, groupID string) { - tips := sdkws.GroupMutedTips{Group: &sdkws.GroupInfo{}, - OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID) -} - -func GroupCancelMutedNotification(operationID, opUserID, groupID string) { - tips := sdkws.GroupCancelMutedTips{Group: &sdkws.GroupInfo{}, - OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID) -} - -func GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) { - tips := sdkws.GroupMemberMutedTips{Group: &sdkws.GroupInfo{}, - OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} - tips.MutedSeconds = mutedSeconds - if err := setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) - return - } - groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID) -} - -func GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberUserID string) { - tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, - OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) - return - } - groupNotification(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID) -} - -func GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) { - if notificationType != constant.GroupMemberSetToAdminNotification && notificationType != constant.GroupMemberSetToOrdinaryUserNotification { - log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType) - return - } - tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, - OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) - return - } - groupNotification(notificationType, &tips, opUserID, groupID, "", operationID) -} - -func GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) { - tips := sdkws.GroupMemberCancelMutedTips{Group: &sdkws.GroupInfo{}, - OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) - return - } - groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID) -} - -// message ReceiveJoinApplicationTips{ -// GroupInfo Group = 1; -// PublicUserInfo Applicant = 2; -// string Reason = 3; -// } apply->all managers GroupID string `protobuf:"bytes,1,opt,name=GroupID" json:"GroupID,omitempty"` -// -// ReqMessage string `protobuf:"bytes,2,opt,name=ReqMessage" json:"ReqMessage,omitempty"` -// OpUserID string `protobuf:"bytes,3,opt,name=OpUserID" json:"OpUserID,omitempty"` -// OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"` -// -// 申请进群后调用 -func JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) { - JoinGroupApplicationTips := sdkws.JoinGroupApplicationTips{Group: &sdkws.GroupInfo{}, Applicant: &sdkws.PublicUserInfo{}} - err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group) - if err != nil { - log.Error(utils.OperationID(ctx), "setGroupInfo failed ", err.Error(), req.GroupID) - return - } - if err = setPublicUserInfo(utils.OpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { - log.Error(utils.OperationID(ctx), "setPublicUserInfo failed ", err.Error(), utils.OpUserID(ctx)) - return - } - JoinGroupApplicationTips.ReqMsg = req.ReqMessage - - managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) - if err != nil { - log.NewError(utils.OperationID(ctx), "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID) - return - } - for _, v := range managerList { - groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, utils.OpUserID(ctx), "", v.UserID, utils.OperationID(ctx)) - log.NewInfo(utils.OperationID(ctx), "Notification ", v) - } -} - -func MemberQuitNotification(req *pbGroup.QuitGroupReq) { - MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil { - log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) - return - } - if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberQuitTips.QuitUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID) - return - } - - groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID) -} - -// message ApplicationProcessedTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo OpUser = 2; -// int32 Result = 3; -// string Reason = 4; -// } -// -// 处理进群请求后调用 -func GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseReq) { - GroupApplicationAcceptedTips := sdkws.GroupApplicationAcceptedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} - if err := setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationAcceptedTips.Group) - return - } - if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser) - return - } - - groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", req.FromUserID, req.OperationID) - adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) - if err != nil { - log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) - return - } - for _, v := range adminList { - if v.UserID == req.OpUserID { - continue - } - GroupApplicationAcceptedTips.ReceiverAs = 1 - groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", v.UserID, req.OperationID) - } -} - -func GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseReq) { - GroupApplicationRejectedTips := sdkws.GroupApplicationRejectedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} - if err := setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationRejectedTips.Group) - return - } - if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser) - return - } - groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", req.FromUserID, req.OperationID) - adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) - if err != nil { - log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) - return - } - for _, v := range adminList { - if v.UserID == req.OpUserID { - continue - } - GroupApplicationRejectedTips.ReceiverAs = 1 - groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", v.UserID, req.OperationID) - } -} - -func GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) { - GroupOwnerTransferredTips := sdkws.GroupOwnerTransferredTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, NewGroupOwner: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) - return - } - if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) - return - } - if err := setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil { - log.Error(req.OperationID, "setGroupMemberInfo failed", req.GroupID, req.NewOwnerUserID) - return - } - groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID) -} - -func GroupDismissedNotification(req *pbGroup.DismissGroupReq) { - tips := sdkws.GroupDismissedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, tips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) - return - } - if err := setOpUserInfo(req.OpUserID, req.GroupID, tips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) - return - } - groupNotification(constant.GroupDismissedNotification, &tips, req.OpUserID, req.GroupID, "", req.OperationID) -} - -// message MemberKickedTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo OpUser = 2; -// GroupMemberFullInfo KickedUser = 3; -// uint64 OperationTime = 4; -// } -// -// 被踢后调用 -func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) { - MemberKickedTips := sdkws.MemberKickedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil { - log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) - return - } - if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID) - return - } - for _, v := range kickedUserIDList { - var groupMemberInfo sdkws.GroupMemberFullInfo - if err := setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil { - log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.GroupID, v) - continue - } - MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo) - } - groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, req.GroupID, "", req.OperationID) - // - //for _, v := range kickedUserIDList { - // groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID) - //} -} - -// message MemberInvitedTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo OpUser = 2; -// GroupMemberFullInfo InvitedUser = 3; -// uint64 OperationTime = 4; -// } -// -// 被邀请进群后调用 -func MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) { - MemberInvitedTips := sdkws.MemberInvitedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, MemberInvitedTips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) - return - } - if err := setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) - return - } - for _, v := range invitedUserIDList { - var groupMemberInfo sdkws.GroupMemberFullInfo - if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID) - continue - } - MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo) - } - groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID) -} - -//message GroupInfoChangedTips{ -// int32 ChangedType = 1; //bitwise operators: 1:groupName; 10:Notification 100:Introduction; 1000:FaceUrl -// GroupInfo Group = 2; -// GroupMemberFullInfo OpUser = 3; -//} - -//message MemberLeaveTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo LeaverUser = 2; -// uint64 OperationTime = 3; -//} - -//群成员退群后调用 - -// message MemberEnterTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo EntrantUser = 2; -// uint64 OperationTime = 3; -// } -// -// 群成员主动申请进群,管理员同意后调用, -func MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { - MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil { - log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberEnterTips.Group) - return - } - if err := setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil { - log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser) - return - } - groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID) -} - -func MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) { - MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, MemberEnterTips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group) - return - } - if err := setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser) - return - } - groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID) -} diff --git a/internal/common/notification/msg_notification.go b/internal/common/notification/msg_notification.go deleted file mode 100644 index a846ce738..000000000 --- a/internal/common/notification/msg_notification.go +++ /dev/null @@ -1,48 +0,0 @@ -package notification - -import ( - "Open_IM/internal/rpc/msg" - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" - sdkws "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" -) - -func DeleteMessageNotification(opUserID, userID string, seqList []uint32, operationID string) { - DeleteMessageTips := sdkws.DeleteMessageTips{OpUserID: opUserID, UserID: userID, SeqList: seqList} - MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips) -} - -func MessageNotification(operationID, sendID, recvID string, contentType int32, m proto.Message) { - log.Debug(operationID, utils.GetSelfFuncName(), "args: ", m.String(), contentType) - var err error - var tips sdkws.TipsComm - tips.Detail, err = proto.Marshal(m) - if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), m.String()) - return - } - - marshaler := jsonpb.Marshaler{ - OrigName: true, - EnumsAsInts: false, - EmitDefaults: false, - } - - tips.JsonDetail, _ = marshaler.MarshalToString(m) - var n msg.NotificationMsg - n.SendID = sendID - n.RecvID = recvID - n.ContentType = contentType - n.SessionType = constant.SingleChatType - n.MsgFrom = constant.SysMsgType - n.OperationID = operationID - n.Content, err = proto.Marshal(&tips) - if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) - return - } - msg.Notification(&n) -} diff --git a/internal/common/notification/super_group_notification.go b/internal/common/notification/super_group_notification.go deleted file mode 100644 index 19d08dd98..000000000 --- a/internal/common/notification/super_group_notification.go +++ /dev/null @@ -1,24 +0,0 @@ -package notification - -import ( - "Open_IM/internal/rpc/msg" - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" - //sdk "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" - //"github.com/golang/protobuf/jsonpb" - //"github.com/golang/protobuf/proto" -) - -func SuperGroupNotification(operationID, sendID, recvID string) { - n := &msg.NotificationMsg{ - SendID: sendID, - RecvID: recvID, - MsgFrom: constant.SysMsgType, - ContentType: constant.SuperGroupUpdateNotification, - SessionType: constant.SingleChatType, - OperationID: operationID, - } - log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content)) - msg.Notification(n) -} diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 218ed13a7..28b146281 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -24,7 +24,6 @@ import ( type friendServer struct { *rpcserver.RpcServer - controller.FriendInterface controller.BlackInterface } diff --git a/internal/rpc/msg/chat.go b/internal/rpc/msg/chat.go deleted file mode 100644 index ff2debcb8..000000000 --- a/internal/rpc/msg/chat.go +++ /dev/null @@ -1,63 +0,0 @@ -package msg - -import ( - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/tokenverify" - pbChat "Open_IM/pkg/proto/msg" - "Open_IM/pkg/utils" - "context" -) - -func (rpc *rpcChat) ClearMsg(_ context.Context, req *pbChat.ClearMsgReq) (*pbChat.ClearMsgResp, error) { - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc req: ", req.String()) - if req.OpUserID != req.UserID && !tokenverify.IsManagerUserID(req.UserID) { - errMsg := "No permission" + req.OpUserID + req.UserID - log.Error(req.OperationID, errMsg) - return &pbChat.ClearMsgResp{ErrCode: constant.ErrNoPermission.ErrCode, ErrMsg: errMsg}, nil - } - log.Debug(req.OperationID, "CleanUpOneUserAllMsgFromRedis args", req.UserID) - err := db.DB.CleanUpOneUserAllMsgFromRedis(req.UserID, req.OperationID) - if err != nil { - errMsg := "CleanUpOneUserAllMsgFromRedis failed " + err.Error() + req.OperationID + req.UserID - log.Error(req.OperationID, errMsg) - return &pbChat.ClearMsgResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil - } - log.Debug(req.OperationID, "CleanUpUserMsgFromMongo args", req.UserID) - err = db.DB.CleanUpUserMsgFromMongo(req.UserID, req.OperationID) - if err != nil { - errMsg := "CleanUpUserMsgFromMongo failed " + err.Error() + req.OperationID + req.UserID - log.Error(req.OperationID, errMsg) - return &pbChat.ClearMsgResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil - } - - resp := pbChat.ClearMsgResp{ErrCode: 0} - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) - return &resp, nil -} - -func (rpc *rpcChat) SetMsgMinSeq(_ context.Context, req *pbChat.SetMsgMinSeqReq) (*pbChat.SetMsgMinSeqResp, error) { - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc req: ", req.String()) - if req.OpUserID != req.UserID && !tokenverify.IsManagerUserID(req.UserID) { - errMsg := "No permission" + req.OpUserID + req.UserID - log.Error(req.OperationID, errMsg) - return &pbChat.SetMsgMinSeqResp{ErrCode: constant.ErrNoPermission.ErrCode, ErrMsg: errMsg}, nil - } - if req.GroupID == "" { - err := db.DB.SetUserMinSeq(req.UserID, req.MinSeq) - if err != nil { - errMsg := "SetUserMinSeq failed " + err.Error() + req.OperationID + req.UserID + utils.Uint32ToString(req.MinSeq) - log.Error(req.OperationID, errMsg) - return &pbChat.SetMsgMinSeqResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil - } - return &pbChat.SetMsgMinSeqResp{}, nil - } - err := db.DB.SetGroupUserMinSeq(req.GroupID, req.UserID, uint64(req.MinSeq)) - if err != nil { - errMsg := "SetGroupUserMinSeq failed " + err.Error() + req.OperationID + req.GroupID + req.UserID + utils.Uint32ToString(req.MinSeq) - log.Error(req.OperationID, errMsg) - return &pbChat.SetMsgMinSeqResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil - } - return &pbChat.SetMsgMinSeqResp{}, nil -} diff --git a/internal/rpc/msg/del_msg.go b/internal/rpc/msg/delete.go similarity index 59% rename from internal/rpc/msg/del_msg.go rename to internal/rpc/msg/delete.go index 39559d00b..954126134 100644 --- a/internal/rpc/msg/del_msg.go +++ b/internal/rpc/msg/delete.go @@ -54,3 +54,30 @@ func (rpc *rpcChat) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroup log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil } + +func (rpc *rpcChat) ClearMsg(_ context.Context, req *pbChat.ClearMsgReq) (*pbChat.ClearMsgResp, error) { + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc req: ", req.String()) + if req.OpUserID != req.UserID && !tokenverify.IsManagerUserID(req.UserID) { + errMsg := "No permission" + req.OpUserID + req.UserID + log.Error(req.OperationID, errMsg) + return &pbChat.ClearMsgResp{ErrCode: constant.ErrNoPermission.ErrCode, ErrMsg: errMsg}, nil + } + log.Debug(req.OperationID, "CleanUpOneUserAllMsgFromRedis args", req.UserID) + err := db.DB.CleanUpOneUserAllMsgFromRedis(req.UserID, req.OperationID) + if err != nil { + errMsg := "CleanUpOneUserAllMsgFromRedis failed " + err.Error() + req.OperationID + req.UserID + log.Error(req.OperationID, errMsg) + return &pbChat.ClearMsgResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil + } + log.Debug(req.OperationID, "CleanUpUserMsgFromMongo args", req.UserID) + err = db.DB.CleanUpUserMsgFromMongo(req.UserID, req.OperationID) + if err != nil { + errMsg := "CleanUpUserMsgFromMongo failed " + err.Error() + req.OperationID + req.UserID + log.Error(req.OperationID, errMsg) + return &pbChat.ClearMsgResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil + } + + resp := pbChat.ClearMsgResp{ErrCode: 0} + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + return &resp, nil +} diff --git a/internal/rpc/msg/pull_message.go b/internal/rpc/msg/pull_message.go deleted file mode 100644 index 265c1e264..000000000 --- a/internal/rpc/msg/pull_message.go +++ /dev/null @@ -1,126 +0,0 @@ -package msg - -import ( - "Open_IM/pkg/utils" - "context" - go_redis "github.com/go-redis/redis/v8" - - commonDB "Open_IM/pkg/common/db" - "Open_IM/pkg/common/log" - sdkws "Open_IM/pkg/proto/sdkws" - - promePkg "Open_IM/pkg/common/prometheus" -) - -func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) { - log.NewInfo(in.OperationID, "rpc getMaxAndMinSeq is arriving", in.String()) - resp := new(sdkws.GetMaxAndMinSeqResp) - m := make(map[string]*sdkws.MaxAndMinSeq) - var maxSeq, minSeq uint64 - var err1, err2 error - maxSeq, err1 = commonDB.DB.GetUserMaxSeq(in.UserID) - minSeq, err2 = commonDB.DB.GetUserMinSeq(in.UserID) - if (err1 != nil && err1 != go_redis.Nil) || (err2 != nil && err2 != go_redis.Nil) { - log.NewError(in.OperationID, "getMaxSeq from redis error", in.String()) - if err1 != nil { - log.NewError(in.OperationID, utils.GetSelfFuncName(), err1.Error()) - } - if err2 != nil { - log.NewError(in.OperationID, utils.GetSelfFuncName(), err2.Error()) - } - resp.ErrCode = 200 - resp.ErrMsg = "redis get err" - return resp, nil - } - resp.MaxSeq = uint32(maxSeq) - resp.MinSeq = uint32(minSeq) - for _, groupID := range in.GroupIDList { - x := new(sdkws.MaxAndMinSeq) - maxSeq, _ := commonDB.DB.GetGroupMaxSeq(groupID) - minSeq, _ := commonDB.DB.GetGroupUserMinSeq(groupID, in.UserID) - x.MaxSeq = uint32(maxSeq) - x.MinSeq = uint32(minSeq) - m[groupID] = x - } - resp.GroupMaxAndMinSeq = m - return resp, nil -} - -func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *sdkws.PullMessageBySeqListReq) (*sdkws.PullMessageBySeqListResp, error) { - log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String()) - resp := new(sdkws.PullMessageBySeqListResp) - m := make(map[string]*sdkws.MsgDataList) - redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(in.UserID, in.SeqList, in.OperationID) - if err != nil { - if err != go_redis.Nil { - promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList) - } else { - log.Debug(in.OperationID, "get message from redis is nil", failedSeqList) - } - msgList, err1 := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, failedSeqList, in.OperationID) - if err1 != nil { - promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error()) - resp.ErrCode = 201 - resp.ErrMsg = err1.Error() - return resp, nil - } else { - promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - redisMsgList = append(redisMsgList, msgList...) - resp.List = redisMsgList - } - } else { - promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - resp.List = redisMsgList - } - - for k, v := range in.GroupSeqList { - x := new(sdkws.MsgDataList) - redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(k, v.SeqList, in.OperationID) - if err != nil { - if err != go_redis.Nil { - promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList) - } else { - log.Debug(in.OperationID, "get message from redis is nil", failedSeqList) - } - msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, in.OperationID) - if err1 != nil { - promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error()) - resp.ErrCode = 201 - resp.ErrMsg = err1.Error() - return resp, nil - } else { - promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - redisMsgList = append(redisMsgList, msgList...) - x.MsgDataList = redisMsgList - m[k] = x - } - } else { - promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - x.MsgDataList = redisMsgList - m[k] = x - } - } - resp.GroupMsgDataList = m - return resp, nil -} - -type MsgFormats []*sdkws.MsgData - -// Implement the sort.Interface interface to get the number of elements method -func (s MsgFormats) Len() int { - return len(s) -} - -//Implement the sort.Interface interface comparison element method -func (s MsgFormats) Less(i, j int) bool { - return s[i].SendTime < s[j].SendTime -} - -//Implement the sort.Interface interface exchange element method -func (s MsgFormats) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} diff --git a/internal/rpc/msg/query_msg.go b/internal/rpc/msg/query_msg.go index f8a2afc7c..1bdc98fac 100644 --- a/internal/rpc/msg/query_msg.go +++ b/internal/rpc/msg/query_msg.go @@ -45,7 +45,3 @@ func (rpc *rpcChat) GetSuperGroupMsg(context context.Context, req *msg.GetSuperG log.Debug(req.OperationID, utils.GetSelfFuncName(), resp.String()) return resp, nil } - -func (rpc *rpcChat) GetWriteDiffMsg(context context.Context, req *msg.GetWriteDiffMsgReq) (*msg.GetWriteDiffMsgResp, error) { - panic("implement me") -} diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 2060e8998..6da381df9 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -7,10 +7,8 @@ import ( rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/log" "Open_IM/pkg/common/tokenverify" - "Open_IM/pkg/getcdv3" cacheRpc "Open_IM/pkg/proto/cache" - pbConversation "Open_IM/pkg/proto/conversation" - pbChat "Open_IM/pkg/proto/msg" + "Open_IM/pkg/proto/msg" pbPush "Open_IM/pkg/proto/push" pbRelay "Open_IM/pkg/proto/relay" sdkws "Open_IM/pkg/proto/sdkws" @@ -23,26 +21,17 @@ import ( "sync" "time" - promePkg "Open_IM/pkg/common/prometheus" go_redis "github.com/go-redis/redis/v8" - "github.com/golang/protobuf/proto" ) -//When the number of group members is greater than this value,Online users will be sent first,Guaranteed service availability -const GroupMemberNum = 500 - var ( ExcludeContentType = []int{constant.HasReadReceipt, constant.GroupHasReadReceipt} ) type Validator interface { - validate(pb *pbChat.SendMsgReq) (bool, int32, string) + validate(pb *msg.SendMsgReq) (bool, int32, string) } -//type MessageValidator struct { -// -//} - type MessageRevoked struct { RevokerID string `json:"revokerID"` RevokerRole int32 `json:"revokerRole"` @@ -77,7 +66,7 @@ type MsgCallBackResp struct { } } -func isMessageHasReadEnabled(pb *pbChat.SendMsgReq) (bool, int32, string) { +func isMessageHasReadEnabled(pb *msg.SendMsgReq) (bool, int32, string) { switch pb.MsgData.ContentType { case constant.HasReadReceipt: if config.Config.SingleMessageHasReadReceiptEnable { @@ -341,298 +330,6 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdkws.MsgData) { utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false) } } -func (rpc *rpcChat) SendMsg(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) { - replay := pbChat.SendMsgResp{} - log.Info(pb.OperationID, "rpc sendMsg come here ", pb.String()) - flag, errCode, errMsg := isMessageHasReadEnabled(pb) - if !flag { - return returnMsg(&replay, pb, errCode, errMsg, "", 0) - } - t1 := time.Now() - rpc.encapsulateMsgData(pb.MsgData) - log.Debug(pb.OperationID, "encapsulateMsgData ", " cost time: ", time.Since(t1)) - msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData} - // callback - t1 = time.Now() - callbackResp := callbackMsgModify(pb) - log.Debug(pb.OperationID, "callbackMsgModify ", callbackResp, "cost time: ", time.Since(t1)) - if callbackResp.ErrCode != 0 { - log.Error(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify resp: ", callbackResp) - } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackResp: ", callbackResp) - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 - } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify result", "end rpc and return", pb.MsgData) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) - } - switch pb.MsgData.SessionType { - case constant.SingleChatType: - promePkg.PromeInc(promePkg.SingleChatMsgRecvSuccessCounter) - // callback - t1 = time.Now() - callbackResp := callbackBeforeSendSingleMsg(pb) - log.Debug(pb.OperationID, "callbackBeforeSendSingleMsg ", " cost time: ", time.Since(t1)) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp) - } - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 - } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp) - promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) - } - t1 = time.Now() - flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb) - log.Debug(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1)) - if !flag { - return returnMsg(&replay, pb, errCode, errMsg, "", 0) - } - t1 = time.Now() - isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb) - log.Info(pb.OperationID, "modifyMessageByUserMessageReceiveOpt ", " cost time: ", time.Since(t1)) - if isSend { - msgToMQSingle.MsgData = pb.MsgData - log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) - t1 = time.Now() - err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) - log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) - if err1 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error()) - promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - } - if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself - t1 = time.Now() - err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) - log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) - if err2 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) - promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - } - // callback - t1 = time.Now() - callbackResp = callbackAfterSendSingleMsg(pb) - log.Info(pb.OperationID, "callbackAfterSendSingleMsg ", " cost time: ", time.Since(t1)) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg resp: ", callbackResp) - } - promePkg.PromeInc(promePkg.SingleChatMsgProcessSuccessCounter) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) - case constant.GroupChatType: - // callback - promePkg.PromeInc(promePkg.GroupChatMsgRecvSuccessCounter) - callbackResp := callbackBeforeSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg resp:", callbackResp) - } - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 - } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp) - promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) - } - var memberUserIDList []string - if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(ctx, pb); !flag { - promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, errCode, errMsg, "", 0) - } - log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList, "len: ", len(memberUserIDList)) - var addUidList []string - switch pb.MsgData.ContentType { - case constant.MemberKickedNotification: - var tips sdkws.TipsComm - var memberKickedTips sdkws.MemberKickedTips - err := proto.Unmarshal(pb.MsgData.Content, &tips) - if err != nil { - log.Error(pb.OperationID, "Unmarshal err", err.Error()) - } - err = proto.Unmarshal(tips.Detail, &memberKickedTips) - if err != nil { - log.Error(pb.OperationID, "Unmarshal err", err.Error()) - } - log.Info(pb.OperationID, "data is ", memberKickedTips) - for _, v := range memberKickedTips.KickedUserList { - addUidList = append(addUidList, v.UserID) - } - case constant.MemberQuitNotification: - addUidList = append(addUidList, pb.MsgData.SendID) - - default: - } - if len(addUidList) > 0 { - memberUserIDList = append(memberUserIDList, addUidList...) - } - m := make(map[string][]string, 2) - m[constant.OnlineStatus] = memberUserIDList - t1 = time.Now() - - //split parallel send - var wg sync.WaitGroup - var sendTag bool - var split = 20 - for k, v := range m { - remain := len(v) % split - for i := 0; i < len(v)/split; i++ { - wg.Add(1) - tmp := valueCopy(pb) - // go rpc.sendMsgToGroup(v[i*split:(i+1)*split], *pb, k, &sendTag, &wg) - go rpc.sendMsgToGroupOptimization(ctx, v[i*split:(i+1)*split], tmp, k, &sendTag, &wg) - } - if remain > 0 { - wg.Add(1) - tmp := valueCopy(pb) - // go rpc.sendMsgToGroup(v[split*(len(v)/split):], *pb, k, &sendTag, &wg) - go rpc.sendMsgToGroupOptimization(ctx, v[split*(len(v)/split):], tmp, k, &sendTag, &wg) - } - } - log.Debug(pb.OperationID, "send msg cost time22 ", time.Since(t1), pb.MsgData.ClientMsgID, "uidList : ", len(addUidList)) - //wg.Add(1) - //go rpc.sendMsgToGroup(addUidList, *pb, constant.OnlineStatus, &sendTag, &wg) - wg.Wait() - t1 = time.Now() - // callback - callbackResp = callbackAfterSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendGroupMsg resp: ", callbackResp) - } - if !sendTag { - log.NewWarn(pb.OperationID, "send tag is ", sendTag) - promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } else { - if pb.MsgData.ContentType == constant.AtText { - go func() { - var conversationReq pbConversation.ModifyConversationFieldReq - var tag bool - var atUserID []string - conversation := pbConversation.Conversation{ - OwnerUserID: pb.MsgData.SendID, - ConversationID: utils.GetConversationIDBySessionType(pb.MsgData.GroupID, constant.GroupChatType), - ConversationType: constant.GroupChatType, - GroupID: pb.MsgData.GroupID, - } - conversationReq.Conversation = &conversation - conversationReq.OperationID = pb.OperationID - conversationReq.FieldType = constant.FieldGroupAtType - tagAll := utils.IsContain(constant.AtAllString, pb.MsgData.AtUserIDList) - if tagAll { - atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList) - if len(atUserID) == 0 { //just @everyone - conversationReq.UserIDList = memberUserIDList - conversation.GroupAtType = constant.AtAll - } else { //@Everyone and @other people - conversationReq.UserIDList = atUserID - conversation.GroupAtType = constant.AtAllAtMe - tag = true - } - } else { - conversationReq.UserIDList = pb.MsgData.AtUserIDList - conversation.GroupAtType = constant.AtMe - } - etcdConn, err := rpc.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName) - if err != nil { - errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(pb.OperationID, errMsg) - return - } - client := pbConversation.NewConversationClient(etcdConn) - conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) - if err != nil { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) - } else if conversationReply.CommonResp.ErrCode != 0 { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) - } - if tag { - conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList) - conversation.GroupAtType = constant.AtAll - etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID) - if etcdConn == nil { - errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(pb.OperationID, errMsg) - return - } - client := pbConversation.NewConversationClient(etcdConn) - conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) - if err != nil { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) - } else if conversationReply.CommonResp.ErrCode != 0 { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) - } - } - }() - } - log.Debug(pb.OperationID, "send msg cost time3 ", time.Since(t1), pb.MsgData.ClientMsgID) - promePkg.PromeInc(promePkg.GroupChatMsgProcessSuccessCounter) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) - } - case constant.NotificationChatType: - t1 = time.Now() - msgToMQSingle.MsgData = pb.MsgData - log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) - err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) - if err1 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String()) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - - if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself - err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) - if err2 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - } - - log.Debug(pb.OperationID, "send msg cost time ", time.Since(t1), pb.MsgData.ClientMsgID) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) - case constant.SuperGroupChatType: - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter) - // callback - callbackResp := callbackBeforeSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg resp: ", callbackResp) - } - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 - } - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg result", "end rpc and return", callbackResp) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) - } - if flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb); !flag { - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, errCode, errMsg, "", 0) - } - msgToMQSingle.MsgData = pb.MsgData - log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) - err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.GroupID, constant.OnlineStatus) - if err1 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String()) - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - // callback - callbackResp = callbackAfterSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSuperGroupMsg resp: ", callbackResp) - } - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) - - default: - return returnMsg(&replay, pb, 203, "unknown sessionType", "", 0) - } -} func (rpc *rpcChat) sendMsgToWriter(ctx context.Context, m *pbChat.MsgDataToMQ, key string, status string) error { switch status { @@ -747,288 +444,6 @@ func modifyMessageByUserMessageReceiveOptoptimization(userID, sourceID string, s return true } -type NotificationMsg struct { - SendID string - RecvID string - Content []byte // sdkws.TipsComm - MsgFrom int32 - ContentType int32 - SessionType int32 - OperationID string - SenderNickname string - SenderFaceURL string -} - -func Notification(n *NotificationMsg) { - var req pbChat.SendMsgReq - var msg sdkws.MsgData - var offlineInfo sdkws.OfflinePushInfo - var title, desc, ex string - var pushSwitch, unReadCount bool - var reliabilityLevel int - req.OperationID = n.OperationID - msg.SendID = n.SendID - msg.RecvID = n.RecvID - msg.Content = n.Content - msg.MsgFrom = n.MsgFrom - msg.ContentType = n.ContentType - msg.SessionType = n.SessionType - msg.CreateTime = utils.GetCurrentTimestampByMill() - msg.ClientMsgID = utils.GetMsgID(n.SendID) - msg.Options = make(map[string]bool, 7) - msg.SenderNickname = n.SenderNickname - msg.SenderFaceURL = n.SenderFaceURL - switch n.SessionType { - case constant.GroupChatType, constant.SuperGroupChatType: - msg.RecvID = "" - msg.GroupID = n.RecvID - } - offlineInfo.IOSBadgeCount = config.Config.IOSPush.BadgeCount - offlineInfo.IOSPushSound = config.Config.IOSPush.PushSound - switch msg.ContentType { - case constant.GroupCreatedNotification: - pushSwitch = config.Config.Notification.GroupCreated.OfflinePush.PushSwitch - title = config.Config.Notification.GroupCreated.OfflinePush.Title - desc = config.Config.Notification.GroupCreated.OfflinePush.Desc - ex = config.Config.Notification.GroupCreated.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupCreated.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupCreated.Conversation.UnreadCount - case constant.GroupInfoSetNotification: - pushSwitch = config.Config.Notification.GroupInfoSet.OfflinePush.PushSwitch - title = config.Config.Notification.GroupInfoSet.OfflinePush.Title - desc = config.Config.Notification.GroupInfoSet.OfflinePush.Desc - ex = config.Config.Notification.GroupInfoSet.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupInfoSet.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupInfoSet.Conversation.UnreadCount - case constant.JoinGroupApplicationNotification: - pushSwitch = config.Config.Notification.JoinGroupApplication.OfflinePush.PushSwitch - title = config.Config.Notification.JoinGroupApplication.OfflinePush.Title - desc = config.Config.Notification.JoinGroupApplication.OfflinePush.Desc - ex = config.Config.Notification.JoinGroupApplication.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.JoinGroupApplication.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.JoinGroupApplication.Conversation.UnreadCount - case constant.MemberQuitNotification: - pushSwitch = config.Config.Notification.MemberQuit.OfflinePush.PushSwitch - title = config.Config.Notification.MemberQuit.OfflinePush.Title - desc = config.Config.Notification.MemberQuit.OfflinePush.Desc - ex = config.Config.Notification.MemberQuit.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.MemberQuit.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.MemberQuit.Conversation.UnreadCount - case constant.GroupApplicationAcceptedNotification: - pushSwitch = config.Config.Notification.GroupApplicationAccepted.OfflinePush.PushSwitch - title = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Title - desc = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Desc - ex = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupApplicationAccepted.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupApplicationAccepted.Conversation.UnreadCount - case constant.GroupApplicationRejectedNotification: - pushSwitch = config.Config.Notification.GroupApplicationRejected.OfflinePush.PushSwitch - title = config.Config.Notification.GroupApplicationRejected.OfflinePush.Title - desc = config.Config.Notification.GroupApplicationRejected.OfflinePush.Desc - ex = config.Config.Notification.GroupApplicationRejected.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupApplicationRejected.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupApplicationRejected.Conversation.UnreadCount - case constant.GroupOwnerTransferredNotification: - pushSwitch = config.Config.Notification.GroupOwnerTransferred.OfflinePush.PushSwitch - title = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Title - desc = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Desc - ex = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupOwnerTransferred.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupOwnerTransferred.Conversation.UnreadCount - case constant.MemberKickedNotification: - pushSwitch = config.Config.Notification.MemberKicked.OfflinePush.PushSwitch - title = config.Config.Notification.MemberKicked.OfflinePush.Title - desc = config.Config.Notification.MemberKicked.OfflinePush.Desc - ex = config.Config.Notification.MemberKicked.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.MemberKicked.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.MemberKicked.Conversation.UnreadCount - case constant.MemberInvitedNotification: - pushSwitch = config.Config.Notification.MemberInvited.OfflinePush.PushSwitch - title = config.Config.Notification.MemberInvited.OfflinePush.Title - desc = config.Config.Notification.MemberInvited.OfflinePush.Desc - ex = config.Config.Notification.MemberInvited.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.MemberInvited.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.MemberInvited.Conversation.UnreadCount - case constant.MemberEnterNotification: - pushSwitch = config.Config.Notification.MemberEnter.OfflinePush.PushSwitch - title = config.Config.Notification.MemberEnter.OfflinePush.Title - desc = config.Config.Notification.MemberEnter.OfflinePush.Desc - ex = config.Config.Notification.MemberEnter.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.MemberEnter.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.MemberEnter.Conversation.UnreadCount - case constant.UserInfoUpdatedNotification: - pushSwitch = config.Config.Notification.UserInfoUpdated.OfflinePush.PushSwitch - title = config.Config.Notification.UserInfoUpdated.OfflinePush.Title - desc = config.Config.Notification.UserInfoUpdated.OfflinePush.Desc - ex = config.Config.Notification.UserInfoUpdated.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.UserInfoUpdated.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.UserInfoUpdated.Conversation.UnreadCount - case constant.FriendApplicationNotification: - pushSwitch = config.Config.Notification.FriendApplication.OfflinePush.PushSwitch - title = config.Config.Notification.FriendApplication.OfflinePush.Title - desc = config.Config.Notification.FriendApplication.OfflinePush.Desc - ex = config.Config.Notification.FriendApplication.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.FriendApplication.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.FriendApplication.Conversation.UnreadCount - case constant.FriendApplicationApprovedNotification: - pushSwitch = config.Config.Notification.FriendApplicationApproved.OfflinePush.PushSwitch - title = config.Config.Notification.FriendApplicationApproved.OfflinePush.Title - desc = config.Config.Notification.FriendApplicationApproved.OfflinePush.Desc - ex = config.Config.Notification.FriendApplicationApproved.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.FriendApplicationApproved.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.FriendApplicationApproved.Conversation.UnreadCount - case constant.FriendApplicationRejectedNotification: - pushSwitch = config.Config.Notification.FriendApplicationRejected.OfflinePush.PushSwitch - title = config.Config.Notification.FriendApplicationRejected.OfflinePush.Title - desc = config.Config.Notification.FriendApplicationRejected.OfflinePush.Desc - ex = config.Config.Notification.FriendApplicationRejected.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.FriendApplicationRejected.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.FriendApplicationRejected.Conversation.UnreadCount - case constant.FriendAddedNotification: - pushSwitch = config.Config.Notification.FriendAdded.OfflinePush.PushSwitch - title = config.Config.Notification.FriendAdded.OfflinePush.Title - desc = config.Config.Notification.FriendAdded.OfflinePush.Desc - ex = config.Config.Notification.FriendAdded.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.FriendAdded.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.FriendAdded.Conversation.UnreadCount - case constant.FriendDeletedNotification: - pushSwitch = config.Config.Notification.FriendDeleted.OfflinePush.PushSwitch - title = config.Config.Notification.FriendDeleted.OfflinePush.Title - desc = config.Config.Notification.FriendDeleted.OfflinePush.Desc - ex = config.Config.Notification.FriendDeleted.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.FriendDeleted.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.FriendDeleted.Conversation.UnreadCount - case constant.FriendRemarkSetNotification: - pushSwitch = config.Config.Notification.FriendRemarkSet.OfflinePush.PushSwitch - title = config.Config.Notification.FriendRemarkSet.OfflinePush.Title - desc = config.Config.Notification.FriendRemarkSet.OfflinePush.Desc - ex = config.Config.Notification.FriendRemarkSet.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.FriendRemarkSet.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.FriendRemarkSet.Conversation.UnreadCount - case constant.BlackAddedNotification: - pushSwitch = config.Config.Notification.BlackAdded.OfflinePush.PushSwitch - title = config.Config.Notification.BlackAdded.OfflinePush.Title - desc = config.Config.Notification.BlackAdded.OfflinePush.Desc - ex = config.Config.Notification.BlackAdded.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.BlackAdded.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.BlackAdded.Conversation.UnreadCount - case constant.BlackDeletedNotification: - pushSwitch = config.Config.Notification.BlackDeleted.OfflinePush.PushSwitch - title = config.Config.Notification.BlackDeleted.OfflinePush.Title - desc = config.Config.Notification.BlackDeleted.OfflinePush.Desc - ex = config.Config.Notification.BlackDeleted.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.BlackDeleted.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.BlackDeleted.Conversation.UnreadCount - case constant.ConversationOptChangeNotification: - pushSwitch = config.Config.Notification.ConversationOptUpdate.OfflinePush.PushSwitch - title = config.Config.Notification.ConversationOptUpdate.OfflinePush.Title - desc = config.Config.Notification.ConversationOptUpdate.OfflinePush.Desc - ex = config.Config.Notification.ConversationOptUpdate.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.ConversationOptUpdate.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.ConversationOptUpdate.Conversation.UnreadCount - - case constant.GroupDismissedNotification: - pushSwitch = config.Config.Notification.GroupDismissed.OfflinePush.PushSwitch - title = config.Config.Notification.GroupDismissed.OfflinePush.Title - desc = config.Config.Notification.GroupDismissed.OfflinePush.Desc - ex = config.Config.Notification.GroupDismissed.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupDismissed.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupDismissed.Conversation.UnreadCount - - case constant.GroupMutedNotification: - pushSwitch = config.Config.Notification.GroupMuted.OfflinePush.PushSwitch - title = config.Config.Notification.GroupMuted.OfflinePush.Title - desc = config.Config.Notification.GroupMuted.OfflinePush.Desc - ex = config.Config.Notification.GroupMuted.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupMuted.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupMuted.Conversation.UnreadCount - - case constant.GroupCancelMutedNotification: - pushSwitch = config.Config.Notification.GroupCancelMuted.OfflinePush.PushSwitch - title = config.Config.Notification.GroupCancelMuted.OfflinePush.Title - desc = config.Config.Notification.GroupCancelMuted.OfflinePush.Desc - ex = config.Config.Notification.GroupCancelMuted.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupCancelMuted.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupCancelMuted.Conversation.UnreadCount - - case constant.GroupMemberMutedNotification: - pushSwitch = config.Config.Notification.GroupMemberMuted.OfflinePush.PushSwitch - title = config.Config.Notification.GroupMemberMuted.OfflinePush.Title - desc = config.Config.Notification.GroupMemberMuted.OfflinePush.Desc - ex = config.Config.Notification.GroupMemberMuted.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupMemberMuted.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupMemberMuted.Conversation.UnreadCount - - case constant.GroupMemberCancelMutedNotification: - pushSwitch = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.PushSwitch - title = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Title - desc = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Desc - ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount - - case constant.GroupMemberInfoSetNotification: - pushSwitch = config.Config.Notification.GroupMemberInfoSet.OfflinePush.PushSwitch - title = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Title - desc = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Desc - ex = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.GroupMemberInfoSet.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.GroupMemberInfoSet.Conversation.UnreadCount - - case constant.ConversationPrivateChatNotification: - pushSwitch = config.Config.Notification.ConversationSetPrivate.OfflinePush.PushSwitch - title = config.Config.Notification.ConversationSetPrivate.OfflinePush.Title - desc = config.Config.Notification.ConversationSetPrivate.OfflinePush.Desc - ex = config.Config.Notification.ConversationSetPrivate.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.ConversationSetPrivate.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.ConversationSetPrivate.Conversation.UnreadCount - case constant.FriendInfoUpdatedNotification: - pushSwitch = config.Config.Notification.FriendInfoUpdated.OfflinePush.PushSwitch - title = config.Config.Notification.FriendInfoUpdated.OfflinePush.Title - desc = config.Config.Notification.FriendInfoUpdated.OfflinePush.Desc - ex = config.Config.Notification.FriendInfoUpdated.OfflinePush.Ext - reliabilityLevel = config.Config.Notification.FriendInfoUpdated.Conversation.ReliabilityLevel - unReadCount = config.Config.Notification.FriendInfoUpdated.Conversation.UnreadCount - case constant.DeleteMessageNotification: - reliabilityLevel = constant.ReliableNotificationNoMsg - case constant.ConversationUnreadNotification, constant.SuperGroupUpdateNotification: - reliabilityLevel = constant.UnreliableNotification - } - switch reliabilityLevel { - case constant.UnreliableNotification: - utils.SetSwitchFromOptions(msg.Options, constant.IsHistory, false) - utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false) - utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false) - utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false) - case constant.ReliableNotificationNoMsg: - utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false) - utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false) - case constant.ReliableNotificationMsg: - - } - utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, unReadCount) - utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, pushSwitch) - offlineInfo.Title = title - offlineInfo.Desc = desc - offlineInfo.Ex = ex - msg.OfflinePushInfo = &offlineInfo - req.MsgData = &msg - etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID) - if etcdConn == nil { - errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(req.OperationID, errMsg) - return - } - - client := pbChat.NewMsgClient(etcdConn) - reply, err := client.SendMsg(context.Background(), &req) - if err != nil { - log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), err.Error()) - } else if reply.ErrCode != 0 { - log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), reply.ErrCode, reply.ErrMsg) - } -} - func getOnlineAndOfflineUserIDList(memberList []string, m map[string][]string, operationID string) { var onllUserIDList, offlUserIDList []string var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go new file mode 100644 index 000000000..04159886a --- /dev/null +++ b/internal/rpc/msg/send_pull.go @@ -0,0 +1,403 @@ +package msg + +import ( + "Open_IM/pkg/common/constant" + promePkg "Open_IM/pkg/common/prometheus" + pbConversation "Open_IM/pkg/proto/conversation" + pbChat "Open_IM/pkg/proto/msg" + "Open_IM/pkg/proto/sdkws" + "context" + go_redis "github.com/go-redis/redis/v8" + "strings" + "sync" + "time" +) + +func (m *msgServer) SendMsg(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) { + replay := pbChat.SendMsgResp{} + + flag, errCode, errMsg := isMessageHasReadEnabled(pb) + if !flag { + return returnMsg(&replay, pb, errCode, errMsg, "", 0) + } + t1 := time.Now() + rpc.encapsulateMsgData(pb.MsgData) + log.Debug(pb.OperationID, "encapsulateMsgData ", " cost time: ", time.Since(t1)) + msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData} + // callback + t1 = time.Now() + callbackResp := callbackMsgModify(pb) + log.Debug(pb.OperationID, "callbackMsgModify ", callbackResp, "cost time: ", time.Since(t1)) + if callbackResp.ErrCode != 0 { + log.Error(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify resp: ", callbackResp) + } + log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackResp: ", callbackResp) + if callbackResp.ActionCode != constant.ActionAllow { + if callbackResp.ErrCode == 0 { + callbackResp.ErrCode = 201 + } + log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify result", "end rpc and return", pb.MsgData) + return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) + } + switch pb.MsgData.SessionType { + case constant.SingleChatType: + promePkg.PromeInc(promePkg.SingleChatMsgRecvSuccessCounter) + // callback + t1 = time.Now() + callbackResp := callbackBeforeSendSingleMsg(pb) + log.Debug(pb.OperationID, "callbackBeforeSendSingleMsg ", " cost time: ", time.Since(t1)) + if callbackResp.ErrCode != 0 { + log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp) + } + if callbackResp.ActionCode != constant.ActionAllow { + if callbackResp.ErrCode == 0 { + callbackResp.ErrCode = 201 + } + log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp) + promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) + } + t1 = time.Now() + flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb) + log.Debug(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1)) + if !flag { + return returnMsg(&replay, pb, errCode, errMsg, "", 0) + } + t1 = time.Now() + isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb) + log.Info(pb.OperationID, "modifyMessageByUserMessageReceiveOpt ", " cost time: ", time.Since(t1)) + if isSend { + msgToMQSingle.MsgData = pb.MsgData + log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) + t1 = time.Now() + err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) + log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) + if err1 != nil { + log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error()) + promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + } + if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself + t1 = time.Now() + err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) + log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) + if err2 != nil { + log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) + promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + } + // callback + t1 = time.Now() + callbackResp = callbackAfterSendSingleMsg(pb) + log.Info(pb.OperationID, "callbackAfterSendSingleMsg ", " cost time: ", time.Since(t1)) + if callbackResp.ErrCode != 0 { + log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg resp: ", callbackResp) + } + promePkg.PromeInc(promePkg.SingleChatMsgProcessSuccessCounter) + return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) + case constant.GroupChatType: + // callback + promePkg.PromeInc(promePkg.GroupChatMsgRecvSuccessCounter) + callbackResp := callbackBeforeSendGroupMsg(pb) + if callbackResp.ErrCode != 0 { + log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg resp:", callbackResp) + } + if callbackResp.ActionCode != constant.ActionAllow { + if callbackResp.ErrCode == 0 { + callbackResp.ErrCode = 201 + } + log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp) + promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) + } + var memberUserIDList []string + if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(ctx, pb); !flag { + promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, errCode, errMsg, "", 0) + } + log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList, "len: ", len(memberUserIDList)) + var addUidList []string + switch pb.MsgData.ContentType { + case constant.MemberKickedNotification: + var tips sdkws.TipsComm + var memberKickedTips sdkws.MemberKickedTips + err := proto.Unmarshal(pb.MsgData.Content, &tips) + if err != nil { + log.Error(pb.OperationID, "Unmarshal err", err.Error()) + } + err = proto.Unmarshal(tips.Detail, &memberKickedTips) + if err != nil { + log.Error(pb.OperationID, "Unmarshal err", err.Error()) + } + log.Info(pb.OperationID, "data is ", memberKickedTips) + for _, v := range memberKickedTips.KickedUserList { + addUidList = append(addUidList, v.UserID) + } + case constant.MemberQuitNotification: + addUidList = append(addUidList, pb.MsgData.SendID) + + default: + } + if len(addUidList) > 0 { + memberUserIDList = append(memberUserIDList, addUidList...) + } + m := make(map[string][]string, 2) + m[constant.OnlineStatus] = memberUserIDList + t1 = time.Now() + + //split parallel send + var wg sync.WaitGroup + var sendTag bool + var split = 20 + for k, v := range m { + remain := len(v) % split + for i := 0; i < len(v)/split; i++ { + wg.Add(1) + tmp := valueCopy(pb) + // go rpc.sendMsgToGroup(v[i*split:(i+1)*split], *pb, k, &sendTag, &wg) + go rpc.sendMsgToGroupOptimization(ctx, v[i*split:(i+1)*split], tmp, k, &sendTag, &wg) + } + if remain > 0 { + wg.Add(1) + tmp := valueCopy(pb) + // go rpc.sendMsgToGroup(v[split*(len(v)/split):], *pb, k, &sendTag, &wg) + go rpc.sendMsgToGroupOptimization(ctx, v[split*(len(v)/split):], tmp, k, &sendTag, &wg) + } + } + log.Debug(pb.OperationID, "send msg cost time22 ", time.Since(t1), pb.MsgData.ClientMsgID, "uidList : ", len(addUidList)) + //wg.Add(1) + //go rpc.sendMsgToGroup(addUidList, *pb, constant.OnlineStatus, &sendTag, &wg) + wg.Wait() + t1 = time.Now() + // callback + callbackResp = callbackAfterSendGroupMsg(pb) + if callbackResp.ErrCode != 0 { + log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendGroupMsg resp: ", callbackResp) + } + if !sendTag { + log.NewWarn(pb.OperationID, "send tag is ", sendTag) + promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } else { + if pb.MsgData.ContentType == constant.AtText { + go func() { + var conversationReq pbConversation.ModifyConversationFieldReq + var tag bool + var atUserID []string + conversation := pbConversation.Conversation{ + OwnerUserID: pb.MsgData.SendID, + ConversationID: utils.GetConversationIDBySessionType(pb.MsgData.GroupID, constant.GroupChatType), + ConversationType: constant.GroupChatType, + GroupID: pb.MsgData.GroupID, + } + conversationReq.Conversation = &conversation + conversationReq.OperationID = pb.OperationID + conversationReq.FieldType = constant.FieldGroupAtType + tagAll := utils.IsContain(constant.AtAllString, pb.MsgData.AtUserIDList) + if tagAll { + atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList) + if len(atUserID) == 0 { //just @everyone + conversationReq.UserIDList = memberUserIDList + conversation.GroupAtType = constant.AtAll + } else { //@Everyone and @other people + conversationReq.UserIDList = atUserID + conversation.GroupAtType = constant.AtAllAtMe + tag = true + } + } else { + conversationReq.UserIDList = pb.MsgData.AtUserIDList + conversation.GroupAtType = constant.AtMe + } + etcdConn, err := rpc.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName) + if err != nil { + errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" + log.NewError(pb.OperationID, errMsg) + return + } + client := pbConversation.NewConversationClient(etcdConn) + conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) + if err != nil { + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) + } else if conversationReply.CommonResp.ErrCode != 0 { + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) + } + if tag { + conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList) + conversation.GroupAtType = constant.AtAll + etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID) + if etcdConn == nil { + errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" + log.NewError(pb.OperationID, errMsg) + return + } + client := pbConversation.NewConversationClient(etcdConn) + conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) + if err != nil { + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) + } else if conversationReply.CommonResp.ErrCode != 0 { + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) + } + } + }() + } + log.Debug(pb.OperationID, "send msg cost time3 ", time.Since(t1), pb.MsgData.ClientMsgID) + promePkg.PromeInc(promePkg.GroupChatMsgProcessSuccessCounter) + return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) + } + case constant.NotificationChatType: + t1 = time.Now() + msgToMQSingle.MsgData = pb.MsgData + log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) + err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) + if err1 != nil { + log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String()) + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + + if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself + err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) + if err2 != nil { + log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + } + + log.Debug(pb.OperationID, "send msg cost time ", time.Since(t1), pb.MsgData.ClientMsgID) + return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) + case constant.SuperGroupChatType: + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter) + // callback + callbackResp := callbackBeforeSendGroupMsg(pb) + if callbackResp.ErrCode != 0 { + log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg resp: ", callbackResp) + } + if callbackResp.ActionCode != constant.ActionAllow { + if callbackResp.ErrCode == 0 { + callbackResp.ErrCode = 201 + } + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) + log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg result", "end rpc and return", callbackResp) + return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) + } + if flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb); !flag { + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, errCode, errMsg, "", 0) + } + msgToMQSingle.MsgData = pb.MsgData + log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) + err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.GroupID, constant.OnlineStatus) + if err1 != nil { + log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String()) + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) + return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) + } + // callback + callbackResp = callbackAfterSendGroupMsg(pb) + if callbackResp.ErrCode != 0 { + log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSuperGroupMsg resp: ", callbackResp) + } + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter) + return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) + + default: + return returnMsg(&replay, pb, 203, "unknown sessionType", "", 0) + } +} + +func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) { + log.NewInfo(in.OperationID, "rpc getMaxAndMinSeq is arriving", in.String()) + resp := new(sdkws.GetMaxAndMinSeqResp) + m := make(map[string]*sdkws.MaxAndMinSeq) + var maxSeq, minSeq uint64 + var err1, err2 error + maxSeq, err1 = commonDB.DB.GetUserMaxSeq(in.UserID) + minSeq, err2 = commonDB.DB.GetUserMinSeq(in.UserID) + if (err1 != nil && err1 != go_redis.Nil) || (err2 != nil && err2 != go_redis.Nil) { + log.NewError(in.OperationID, "getMaxSeq from redis error", in.String()) + if err1 != nil { + log.NewError(in.OperationID, utils.GetSelfFuncName(), err1.Error()) + } + if err2 != nil { + log.NewError(in.OperationID, utils.GetSelfFuncName(), err2.Error()) + } + resp.ErrCode = 200 + resp.ErrMsg = "redis get err" + return resp, nil + } + resp.MaxSeq = uint32(maxSeq) + resp.MinSeq = uint32(minSeq) + for _, groupID := range in.GroupIDList { + x := new(sdkws.MaxAndMinSeq) + maxSeq, _ := commonDB.DB.GetGroupMaxSeq(groupID) + minSeq, _ := commonDB.DB.GetGroupUserMinSeq(groupID, in.UserID) + x.MaxSeq = uint32(maxSeq) + x.MinSeq = uint32(minSeq) + m[groupID] = x + } + resp.GroupMaxAndMinSeq = m + return resp, nil +} + +func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *sdkws.PullMessageBySeqListReq) (*sdkws.PullMessageBySeqListResp, error) { + log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String()) + resp := new(sdkws.PullMessageBySeqListResp) + m := make(map[string]*sdkws.MsgDataList) + redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(in.UserID, in.SeqList, in.OperationID) + if err != nil { + if err != go_redis.Nil { + promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) + log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList) + } else { + log.Debug(in.OperationID, "get message from redis is nil", failedSeqList) + } + msgList, err1 := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, failedSeqList, in.OperationID) + if err1 != nil { + promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) + log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error()) + resp.ErrCode = 201 + resp.ErrMsg = err1.Error() + return resp, nil + } else { + promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) + redisMsgList = append(redisMsgList, msgList...) + resp.List = redisMsgList + } + } else { + promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) + resp.List = redisMsgList + } + + for k, v := range in.GroupSeqList { + x := new(sdkws.MsgDataList) + redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(k, v.SeqList, in.OperationID) + if err != nil { + if err != go_redis.Nil { + promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) + log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList) + } else { + log.Debug(in.OperationID, "get message from redis is nil", failedSeqList) + } + msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, in.OperationID) + if err1 != nil { + promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) + log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error()) + resp.ErrCode = 201 + resp.ErrMsg = err1.Error() + return resp, nil + } else { + promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) + redisMsgList = append(redisMsgList, msgList...) + x.MsgDataList = redisMsgList + m[k] = x + } + } else { + promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) + x.MsgDataList = redisMsgList + m[k] = x + } + } + resp.GroupMsgDataList = m + return resp, nil +} diff --git a/internal/rpc/msg/rpc_chat.go b/internal/rpc/msg/server.go similarity index 91% rename from internal/rpc/msg/rpc_chat.go rename to internal/rpc/msg/server.go index 6f65ca1ed..659a70a3a 100644 --- a/internal/rpc/msg/rpc_chat.go +++ b/internal/rpc/msg/server.go @@ -2,9 +2,10 @@ package msg import ( "Open_IM/internal/common/notification" + "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db" + "Open_IM/pkg/common/kafka" "Open_IM/pkg/common/log" promePkg "Open_IM/pkg/common/prometheus" @@ -15,25 +16,13 @@ import ( "strconv" "strings" - "github.com/golang/protobuf/proto" - grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "google.golang.org/grpc" ) -type MessageWriter interface { - SendMessage(m proto.Message, key string, operationID string) (int32, int64, error) -} -type rpcChat struct { - rpcPort int - rpcRegisterName string - etcdSchema string - etcdAddr []string - messageWriter MessageWriter - //offlineProducer *kafka.Producer - delMsgCh chan deleteMsg - dMessageLocker MessageLocker +type msgServer struct { + *rpcserver.RpcServer } type deleteMsg struct { diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index ae427442a..15cbe872a 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -1,11 +1,15 @@ package controller import ( + "Open_IM/pkg/proto/msg" pbMsg "Open_IM/pkg/proto/msg" "context" ) type MsgInterface interface { + //消息写入队列 + MsgToMQ(ctx context.Context, key string, m *msg.MsgDataToMQ) error + BatchInsertChat2DB(ctx context.Context, userID string, msgList []*pbMsg.MsgDataToMQ, currentMaxSeq uint64) error BatchInsertChat2Cache(ctx context.Context, insertID string, msgList []*pbMsg.MsgDataToMQ) (error, uint64) diff --git a/pkg/proto/msg/msg.pb.go b/pkg/proto/msg/msg.pb.go index bb5fa819c..08cdde4fc 100644 --- a/pkg/proto/msg/msg.pb.go +++ b/pkg/proto/msg/msg.pb.go @@ -6,7 +6,7 @@ package msg // import "Open_IM/pkg/proto/msg" import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import sdk_ws "Open_IM/pkg/proto/sdk_ws" +import sdkws "Open_IM/pkg/proto/sdkws" import wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" import ( @@ -26,19 +26,19 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type MsgDataToMQ struct { - Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` - MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Token string `protobuf:"bytes,1,opt,name=token" json:"token,omitempty"` + OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` + MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *MsgDataToMQ) Reset() { *m = MsgDataToMQ{} } func (m *MsgDataToMQ) String() string { return proto.CompactTextString(m) } func (*MsgDataToMQ) ProtoMessage() {} func (*MsgDataToMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{0} + return fileDescriptor_msg_9bd9d9abca588885, []int{0} } func (m *MsgDataToMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToMQ.Unmarshal(m, b) @@ -72,7 +72,7 @@ func (m *MsgDataToMQ) GetOperationID() string { return "" } -func (m *MsgDataToMQ) GetMsgData() *sdk_ws.MsgData { +func (m *MsgDataToMQ) GetMsgData() *sdkws.MsgData { if m != nil { return m.MsgData } @@ -80,18 +80,18 @@ func (m *MsgDataToMQ) GetMsgData() *sdk_ws.MsgData { } type MsgDataToDB struct { - MsgData *sdk_ws.MsgData `protobuf:"bytes,1,opt,name=msgData" json:"msgData,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + MsgData *sdkws.MsgData `protobuf:"bytes,1,opt,name=msgData" json:"msgData,omitempty"` + OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *MsgDataToDB) Reset() { *m = MsgDataToDB{} } func (m *MsgDataToDB) String() string { return proto.CompactTextString(m) } func (*MsgDataToDB) ProtoMessage() {} func (*MsgDataToDB) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{1} + return fileDescriptor_msg_9bd9d9abca588885, []int{1} } func (m *MsgDataToDB) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToDB.Unmarshal(m, b) @@ -111,7 +111,7 @@ func (m *MsgDataToDB) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDataToDB proto.InternalMessageInfo -func (m *MsgDataToDB) GetMsgData() *sdk_ws.MsgData { +func (m *MsgDataToDB) GetMsgData() *sdkws.MsgData { if m != nil { return m.MsgData } @@ -126,19 +126,19 @@ func (m *MsgDataToDB) GetOperationID() string { } type PushMsgDataToMQ struct { - OperationID string `protobuf:"bytes,1,opt,name=OperationID" json:"OperationID,omitempty"` - MsgData *sdk_ws.MsgData `protobuf:"bytes,2,opt,name=msgData" json:"msgData,omitempty"` - PushToUserID string `protobuf:"bytes,3,opt,name=pushToUserID" json:"pushToUserID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=OperationID" json:"OperationID,omitempty"` + MsgData *sdkws.MsgData `protobuf:"bytes,2,opt,name=msgData" json:"msgData,omitempty"` + PushToUserID string `protobuf:"bytes,3,opt,name=pushToUserID" json:"pushToUserID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *PushMsgDataToMQ) Reset() { *m = PushMsgDataToMQ{} } func (m *PushMsgDataToMQ) String() string { return proto.CompactTextString(m) } func (*PushMsgDataToMQ) ProtoMessage() {} func (*PushMsgDataToMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{2} + return fileDescriptor_msg_9bd9d9abca588885, []int{2} } func (m *PushMsgDataToMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PushMsgDataToMQ.Unmarshal(m, b) @@ -165,7 +165,7 @@ func (m *PushMsgDataToMQ) GetOperationID() string { return "" } -func (m *PushMsgDataToMQ) GetMsgData() *sdk_ws.MsgData { +func (m *PushMsgDataToMQ) GetMsgData() *sdkws.MsgData { if m != nil { return m.MsgData } @@ -193,7 +193,7 @@ func (m *MsgDataToMongoByMQ) Reset() { *m = MsgDataToMongoByMQ{} } func (m *MsgDataToMongoByMQ) String() string { return proto.CompactTextString(m) } func (*MsgDataToMongoByMQ) ProtoMessage() {} func (*MsgDataToMongoByMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{3} + return fileDescriptor_msg_9bd9d9abca588885, []int{3} } func (m *MsgDataToMongoByMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToMongoByMQ.Unmarshal(m, b) @@ -253,7 +253,7 @@ func (m *GetMaxAndMinSeqReq) Reset() { *m = GetMaxAndMinSeqReq{} } func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqReq) ProtoMessage() {} func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{4} + return fileDescriptor_msg_9bd9d9abca588885, []int{4} } func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b) @@ -301,7 +301,7 @@ func (m *GetMaxAndMinSeqResp) Reset() { *m = GetMaxAndMinSeqResp{} } func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqResp) ProtoMessage() {} func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{5} + return fileDescriptor_msg_9bd9d9abca588885, []int{5} } func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b) @@ -350,17 +350,17 @@ func (m *GetMaxAndMinSeqResp) GetMinSeq() uint32 { } type SendMsgReq struct { - MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SendMsgReq) Reset() { *m = SendMsgReq{} } func (m *SendMsgReq) String() string { return proto.CompactTextString(m) } func (*SendMsgReq) ProtoMessage() {} func (*SendMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{6} + return fileDescriptor_msg_9bd9d9abca588885, []int{6} } func (m *SendMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SendMsgReq.Unmarshal(m, b) @@ -380,7 +380,7 @@ func (m *SendMsgReq) XXX_DiscardUnknown() { var xxx_messageInfo_SendMsgReq proto.InternalMessageInfo -func (m *SendMsgReq) GetMsgData() *sdk_ws.MsgData { +func (m *SendMsgReq) GetMsgData() *sdkws.MsgData { if m != nil { return m.MsgData } @@ -400,7 +400,7 @@ func (m *SendMsgResp) Reset() { *m = SendMsgResp{} } func (m *SendMsgResp) String() string { return proto.CompactTextString(m) } func (*SendMsgResp) ProtoMessage() {} func (*SendMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{7} + return fileDescriptor_msg_9bd9d9abca588885, []int{7} } func (m *SendMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SendMsgResp.Unmarshal(m, b) @@ -452,7 +452,7 @@ func (m *ClearMsgReq) Reset() { *m = ClearMsgReq{} } func (m *ClearMsgReq) String() string { return proto.CompactTextString(m) } func (*ClearMsgReq) ProtoMessage() {} func (*ClearMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{8} + return fileDescriptor_msg_9bd9d9abca588885, []int{8} } func (m *ClearMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ClearMsgReq.Unmarshal(m, b) @@ -489,7 +489,7 @@ func (m *ClearMsgResp) Reset() { *m = ClearMsgResp{} } func (m *ClearMsgResp) String() string { return proto.CompactTextString(m) } func (*ClearMsgResp) ProtoMessage() {} func (*ClearMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{9} + return fileDescriptor_msg_9bd9d9abca588885, []int{9} } func (m *ClearMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ClearMsgResp.Unmarshal(m, b) @@ -522,7 +522,7 @@ func (m *SetMsgMinSeqReq) Reset() { *m = SetMsgMinSeqReq{} } func (m *SetMsgMinSeqReq) String() string { return proto.CompactTextString(m) } func (*SetMsgMinSeqReq) ProtoMessage() {} func (*SetMsgMinSeqReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{10} + return fileDescriptor_msg_9bd9d9abca588885, []int{10} } func (m *SetMsgMinSeqReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMsgMinSeqReq.Unmarshal(m, b) @@ -573,7 +573,7 @@ func (m *SetMsgMinSeqResp) Reset() { *m = SetMsgMinSeqResp{} } func (m *SetMsgMinSeqResp) String() string { return proto.CompactTextString(m) } func (*SetMsgMinSeqResp) ProtoMessage() {} func (*SetMsgMinSeqResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{11} + return fileDescriptor_msg_9bd9d9abca588885, []int{11} } func (m *SetMsgMinSeqResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMsgMinSeqResp.Unmarshal(m, b) @@ -604,7 +604,7 @@ func (m *SetSendMsgStatusReq) Reset() { *m = SetSendMsgStatusReq{} } func (m *SetSendMsgStatusReq) String() string { return proto.CompactTextString(m) } func (*SetSendMsgStatusReq) ProtoMessage() {} func (*SetSendMsgStatusReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{12} + return fileDescriptor_msg_9bd9d9abca588885, []int{12} } func (m *SetSendMsgStatusReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetSendMsgStatusReq.Unmarshal(m, b) @@ -641,7 +641,7 @@ func (m *SetSendMsgStatusResp) Reset() { *m = SetSendMsgStatusResp{} } func (m *SetSendMsgStatusResp) String() string { return proto.CompactTextString(m) } func (*SetSendMsgStatusResp) ProtoMessage() {} func (*SetSendMsgStatusResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{13} + return fileDescriptor_msg_9bd9d9abca588885, []int{13} } func (m *SetSendMsgStatusResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetSendMsgStatusResp.Unmarshal(m, b) @@ -672,7 +672,7 @@ func (m *GetSendMsgStatusReq) Reset() { *m = GetSendMsgStatusReq{} } func (m *GetSendMsgStatusReq) String() string { return proto.CompactTextString(m) } func (*GetSendMsgStatusReq) ProtoMessage() {} func (*GetSendMsgStatusReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{14} + return fileDescriptor_msg_9bd9d9abca588885, []int{14} } func (m *GetSendMsgStatusReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSendMsgStatusReq.Unmarshal(m, b) @@ -712,7 +712,7 @@ func (m *GetSendMsgStatusResp) Reset() { *m = GetSendMsgStatusResp{} } func (m *GetSendMsgStatusResp) String() string { return proto.CompactTextString(m) } func (*GetSendMsgStatusResp) ProtoMessage() {} func (*GetSendMsgStatusResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{15} + return fileDescriptor_msg_9bd9d9abca588885, []int{15} } func (m *GetSendMsgStatusResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSendMsgStatusResp.Unmarshal(m, b) @@ -765,7 +765,7 @@ func (m *DelSuperGroupMsgReq) Reset() { *m = DelSuperGroupMsgReq{} } func (m *DelSuperGroupMsgReq) String() string { return proto.CompactTextString(m) } func (*DelSuperGroupMsgReq) ProtoMessage() {} func (*DelSuperGroupMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{16} + return fileDescriptor_msg_9bd9d9abca588885, []int{16} } func (m *DelSuperGroupMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DelSuperGroupMsgReq.Unmarshal(m, b) @@ -809,7 +809,7 @@ func (m *DelSuperGroupMsgResp) Reset() { *m = DelSuperGroupMsgResp{} } func (m *DelSuperGroupMsgResp) String() string { return proto.CompactTextString(m) } func (*DelSuperGroupMsgResp) ProtoMessage() {} func (*DelSuperGroupMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{17} + return fileDescriptor_msg_9bd9d9abca588885, []int{17} } func (m *DelSuperGroupMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DelSuperGroupMsgResp.Unmarshal(m, b) @@ -842,7 +842,7 @@ func (m *GetSuperGroupMsgReq) Reset() { *m = GetSuperGroupMsgReq{} } func (m *GetSuperGroupMsgReq) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupMsgReq) ProtoMessage() {} func (*GetSuperGroupMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{18} + return fileDescriptor_msg_9bd9d9abca588885, []int{18} } func (m *GetSuperGroupMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupMsgReq.Unmarshal(m, b) @@ -884,19 +884,19 @@ func (m *GetSuperGroupMsgReq) GetGroupID() string { } type GetSuperGroupMsgResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` - MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` + MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *GetSuperGroupMsgResp) Reset() { *m = GetSuperGroupMsgResp{} } func (m *GetSuperGroupMsgResp) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupMsgResp) ProtoMessage() {} func (*GetSuperGroupMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{19} + return fileDescriptor_msg_9bd9d9abca588885, []int{19} } func (m *GetSuperGroupMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupMsgResp.Unmarshal(m, b) @@ -930,7 +930,7 @@ func (m *GetSuperGroupMsgResp) GetErrMsg() string { return "" } -func (m *GetSuperGroupMsgResp) GetMsgData() *sdk_ws.MsgData { +func (m *GetSuperGroupMsgResp) GetMsgData() *sdkws.MsgData { if m != nil { return m.MsgData } @@ -949,7 +949,7 @@ func (m *GetWriteDiffMsgReq) Reset() { *m = GetWriteDiffMsgReq{} } func (m *GetWriteDiffMsgReq) String() string { return proto.CompactTextString(m) } func (*GetWriteDiffMsgReq) ProtoMessage() {} func (*GetWriteDiffMsgReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{20} + return fileDescriptor_msg_9bd9d9abca588885, []int{20} } func (m *GetWriteDiffMsgReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetWriteDiffMsgReq.Unmarshal(m, b) @@ -984,19 +984,19 @@ func (m *GetWriteDiffMsgReq) GetSeq() uint32 { } type GetWriteDiffMsgResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` - MsgData *sdk_ws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` + MsgData *sdkws.MsgData `protobuf:"bytes,3,opt,name=msgData" json:"msgData,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *GetWriteDiffMsgResp) Reset() { *m = GetWriteDiffMsgResp{} } func (m *GetWriteDiffMsgResp) String() string { return proto.CompactTextString(m) } func (*GetWriteDiffMsgResp) ProtoMessage() {} func (*GetWriteDiffMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{21} + return fileDescriptor_msg_9bd9d9abca588885, []int{21} } func (m *GetWriteDiffMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetWriteDiffMsgResp.Unmarshal(m, b) @@ -1030,7 +1030,7 @@ func (m *GetWriteDiffMsgResp) GetErrMsg() string { return "" } -func (m *GetWriteDiffMsgResp) GetMsgData() *sdk_ws.MsgData { +func (m *GetWriteDiffMsgResp) GetMsgData() *sdkws.MsgData { if m != nil { return m.MsgData } @@ -1038,27 +1038,27 @@ func (m *GetWriteDiffMsgResp) GetMsgData() *sdk_ws.MsgData { } type ModifyMessageReactionExtensionsReq struct { - OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` - SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` - OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` - SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` - ReactionExtensionList map[string]*sdk_ws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` - AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` - IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` - IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` - MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` + SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` + OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` + SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` + ReactionExtensionList map[string]*sdkws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` + AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` + IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` + IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` + MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *ModifyMessageReactionExtensionsReq) Reset() { *m = ModifyMessageReactionExtensionsReq{} } func (m *ModifyMessageReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*ModifyMessageReactionExtensionsReq) ProtoMessage() {} func (*ModifyMessageReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{22} + return fileDescriptor_msg_9bd9d9abca588885, []int{22} } func (m *ModifyMessageReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ModifyMessageReactionExtensionsReq.Unmarshal(m, b) @@ -1106,7 +1106,7 @@ func (m *ModifyMessageReactionExtensionsReq) GetSessionType() int32 { return 0 } -func (m *ModifyMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdk_ws.KeyValue { +func (m *ModifyMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdkws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1156,27 +1156,27 @@ func (m *ModifyMessageReactionExtensionsReq) GetMsgFirstModifyTime() int64 { } type SetMessageReactionExtensionsReq struct { - OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` - SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` - OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` - SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` - ReactionExtensionList map[string]*sdk_ws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` - AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` - IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` - IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` - MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` + SourceID string `protobuf:"bytes,2,opt,name=sourceID" json:"sourceID,omitempty"` + OpUserID string `protobuf:"bytes,3,opt,name=opUserID" json:"opUserID,omitempty"` + SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` + ReactionExtensionList map[string]*sdkws.KeyValue `protobuf:"bytes,5,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ClientMsgID string `protobuf:"bytes,6,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + Ex *wrapperspb.StringValue `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` + AttachedInfo *wrapperspb.StringValue `protobuf:"bytes,8,opt,name=attachedInfo" json:"attachedInfo,omitempty"` + IsReact bool `protobuf:"varint,9,opt,name=isReact" json:"isReact,omitempty"` + IsExternalExtensions bool `protobuf:"varint,10,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` + MsgFirstModifyTime int64 `protobuf:"varint,11,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SetMessageReactionExtensionsReq) Reset() { *m = SetMessageReactionExtensionsReq{} } func (m *SetMessageReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*SetMessageReactionExtensionsReq) ProtoMessage() {} func (*SetMessageReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{23} + return fileDescriptor_msg_9bd9d9abca588885, []int{23} } func (m *SetMessageReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMessageReactionExtensionsReq.Unmarshal(m, b) @@ -1224,7 +1224,7 @@ func (m *SetMessageReactionExtensionsReq) GetSessionType() int32 { return 0 } -func (m *SetMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdk_ws.KeyValue { +func (m *SetMessageReactionExtensionsReq) GetReactionExtensionList() map[string]*sdkws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1289,7 +1289,7 @@ func (m *SetMessageReactionExtensionsResp) Reset() { *m = SetMessageReac func (m *SetMessageReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*SetMessageReactionExtensionsResp) ProtoMessage() {} func (*SetMessageReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{24} + return fileDescriptor_msg_9bd9d9abca588885, []int{24} } func (m *SetMessageReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetMessageReactionExtensionsResp.Unmarshal(m, b) @@ -1366,7 +1366,7 @@ func (m *GetMessageListReactionExtensionsReq) Reset() { *m = GetMessageL func (m *GetMessageListReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*GetMessageListReactionExtensionsReq) ProtoMessage() {} func (*GetMessageListReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{25} + return fileDescriptor_msg_9bd9d9abca588885, []int{25} } func (m *GetMessageListReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMessageListReactionExtensionsReq.Unmarshal(m, b) @@ -1437,7 +1437,7 @@ func (m *GetMessageListReactionExtensionsReq_MessageReactionKey) String() string } func (*GetMessageListReactionExtensionsReq_MessageReactionKey) ProtoMessage() {} func (*GetMessageListReactionExtensionsReq_MessageReactionKey) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{25, 0} + return fileDescriptor_msg_9bd9d9abca588885, []int{25, 0} } func (m *GetMessageListReactionExtensionsReq_MessageReactionKey) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMessageListReactionExtensionsReq_MessageReactionKey.Unmarshal(m, b) @@ -1484,7 +1484,7 @@ func (m *GetMessageListReactionExtensionsResp) Reset() { *m = GetMessage func (m *GetMessageListReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*GetMessageListReactionExtensionsResp) ProtoMessage() {} func (*GetMessageListReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{26} + return fileDescriptor_msg_9bd9d9abca588885, []int{26} } func (m *GetMessageListReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMessageListReactionExtensionsResp.Unmarshal(m, b) @@ -1526,20 +1526,20 @@ func (m *GetMessageListReactionExtensionsResp) GetSingleMessageResult() []*Singl } type SingleMessageExtensionResult struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` - ReactionExtensionList map[string]*sdk_ws.KeyValue `protobuf:"bytes,3,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - ClientMsgID string `protobuf:"bytes,4,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` + ReactionExtensionList map[string]*sdkws.KeyValue `protobuf:"bytes,3,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ClientMsgID string `protobuf:"bytes,4,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *SingleMessageExtensionResult) Reset() { *m = SingleMessageExtensionResult{} } func (m *SingleMessageExtensionResult) String() string { return proto.CompactTextString(m) } func (*SingleMessageExtensionResult) ProtoMessage() {} func (*SingleMessageExtensionResult) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{27} + return fileDescriptor_msg_9bd9d9abca588885, []int{27} } func (m *SingleMessageExtensionResult) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SingleMessageExtensionResult.Unmarshal(m, b) @@ -1573,7 +1573,7 @@ func (m *SingleMessageExtensionResult) GetErrMsg() string { return "" } -func (m *SingleMessageExtensionResult) GetReactionExtensionList() map[string]*sdk_ws.KeyValue { +func (m *SingleMessageExtensionResult) GetReactionExtensionList() map[string]*sdkws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1601,7 +1601,7 @@ func (m *ModifyMessageReactionExtensionsResp) Reset() { *m = ModifyMessa func (m *ModifyMessageReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*ModifyMessageReactionExtensionsResp) ProtoMessage() {} func (*ModifyMessageReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{28} + return fileDescriptor_msg_9bd9d9abca588885, []int{28} } func (m *ModifyMessageReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ModifyMessageReactionExtensionsResp.Unmarshal(m, b) @@ -1650,17 +1650,17 @@ func (m *ModifyMessageReactionExtensionsResp) GetFailedList() []*ExtendMsgResp { } type DeleteMessageListReactionExtensionsReq struct { - OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` - OpUserID string `protobuf:"bytes,2,opt,name=opUserID" json:"opUserID,omitempty"` - SourceID string `protobuf:"bytes,3,opt,name=sourceID" json:"sourceID,omitempty"` - SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` - ClientMsgID string `protobuf:"bytes,5,opt,name=clientMsgID" json:"clientMsgID,omitempty"` - IsExternalExtensions bool `protobuf:"varint,6,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` - MsgFirstModifyTime int64 `protobuf:"varint,7,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` - ReactionExtensionList []*sdk_ws.KeyValue `protobuf:"bytes,8,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + OperationID string `protobuf:"bytes,1,opt,name=operationID" json:"operationID,omitempty"` + OpUserID string `protobuf:"bytes,2,opt,name=opUserID" json:"opUserID,omitempty"` + SourceID string `protobuf:"bytes,3,opt,name=sourceID" json:"sourceID,omitempty"` + SessionType int32 `protobuf:"varint,4,opt,name=sessionType" json:"sessionType,omitempty"` + ClientMsgID string `protobuf:"bytes,5,opt,name=clientMsgID" json:"clientMsgID,omitempty"` + IsExternalExtensions bool `protobuf:"varint,6,opt,name=isExternalExtensions" json:"isExternalExtensions,omitempty"` + MsgFirstModifyTime int64 `protobuf:"varint,7,opt,name=msgFirstModifyTime" json:"msgFirstModifyTime,omitempty"` + ReactionExtensionList []*sdkws.KeyValue `protobuf:"bytes,8,rep,name=reactionExtensionList" json:"reactionExtensionList,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *DeleteMessageListReactionExtensionsReq) Reset() { @@ -1669,7 +1669,7 @@ func (m *DeleteMessageListReactionExtensionsReq) Reset() { func (m *DeleteMessageListReactionExtensionsReq) String() string { return proto.CompactTextString(m) } func (*DeleteMessageListReactionExtensionsReq) ProtoMessage() {} func (*DeleteMessageListReactionExtensionsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{29} + return fileDescriptor_msg_9bd9d9abca588885, []int{29} } func (m *DeleteMessageListReactionExtensionsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteMessageListReactionExtensionsReq.Unmarshal(m, b) @@ -1738,7 +1738,7 @@ func (m *DeleteMessageListReactionExtensionsReq) GetMsgFirstModifyTime() int64 { return 0 } -func (m *DeleteMessageListReactionExtensionsReq) GetReactionExtensionList() []*sdk_ws.KeyValue { +func (m *DeleteMessageListReactionExtensionsReq) GetReactionExtensionList() []*sdkws.KeyValue { if m != nil { return m.ReactionExtensionList } @@ -1760,7 +1760,7 @@ func (m *DeleteMessageListReactionExtensionsResp) Reset() { func (m *DeleteMessageListReactionExtensionsResp) String() string { return proto.CompactTextString(m) } func (*DeleteMessageListReactionExtensionsResp) ProtoMessage() {} func (*DeleteMessageListReactionExtensionsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{30} + return fileDescriptor_msg_9bd9d9abca588885, []int{30} } func (m *DeleteMessageListReactionExtensionsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteMessageListReactionExtensionsResp.Unmarshal(m, b) @@ -1814,7 +1814,7 @@ func (m *ExtendMsgResp) Reset() { *m = ExtendMsgResp{} } func (m *ExtendMsgResp) String() string { return proto.CompactTextString(m) } func (*ExtendMsgResp) ProtoMessage() {} func (*ExtendMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{31} + return fileDescriptor_msg_9bd9d9abca588885, []int{31} } func (m *ExtendMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExtendMsgResp.Unmarshal(m, b) @@ -1870,7 +1870,7 @@ func (m *ExtendMsg) Reset() { *m = ExtendMsg{} } func (m *ExtendMsg) String() string { return proto.CompactTextString(m) } func (*ExtendMsg) ProtoMessage() {} func (*ExtendMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{32} + return fileDescriptor_msg_9bd9d9abca588885, []int{32} } func (m *ExtendMsg) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExtendMsg.Unmarshal(m, b) @@ -1926,19 +1926,19 @@ func (m *ExtendMsg) GetEx() string { } type KeyValueResp struct { - KeyValue *sdk_ws.KeyValue `protobuf:"bytes,1,opt,name=keyValue" json:"keyValue,omitempty"` - ErrCode int32 `protobuf:"varint,2,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,3,opt,name=errMsg" json:"errMsg,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + KeyValue *sdkws.KeyValue `protobuf:"bytes,1,opt,name=keyValue" json:"keyValue,omitempty"` + ErrCode int32 `protobuf:"varint,2,opt,name=errCode" json:"errCode,omitempty"` + ErrMsg string `protobuf:"bytes,3,opt,name=errMsg" json:"errMsg,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *KeyValueResp) Reset() { *m = KeyValueResp{} } func (m *KeyValueResp) String() string { return proto.CompactTextString(m) } func (*KeyValueResp) ProtoMessage() {} func (*KeyValueResp) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{33} + return fileDescriptor_msg_9bd9d9abca588885, []int{33} } func (m *KeyValueResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KeyValueResp.Unmarshal(m, b) @@ -1958,7 +1958,7 @@ func (m *KeyValueResp) XXX_DiscardUnknown() { var xxx_messageInfo_KeyValueResp proto.InternalMessageInfo -func (m *KeyValueResp) GetKeyValue() *sdk_ws.KeyValue { +func (m *KeyValueResp) GetKeyValue() *sdkws.KeyValue { if m != nil { return m.KeyValue } @@ -1992,7 +1992,7 @@ func (m *MsgDataToModifyByMQ) Reset() { *m = MsgDataToModifyByMQ{} } func (m *MsgDataToModifyByMQ) String() string { return proto.CompactTextString(m) } func (*MsgDataToModifyByMQ) ProtoMessage() {} func (*MsgDataToModifyByMQ) Descriptor() ([]byte, []int) { - return fileDescriptor_msg_69316330d19ec9fa, []int{34} + return fileDescriptor_msg_9bd9d9abca588885, []int{34} } func (m *MsgDataToModifyByMQ) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataToModifyByMQ.Unmarshal(m, b) @@ -2057,15 +2057,15 @@ func init() { proto.RegisterType((*GetWriteDiffMsgReq)(nil), "msg.GetWriteDiffMsgReq") proto.RegisterType((*GetWriteDiffMsgResp)(nil), "msg.GetWriteDiffMsgResp") proto.RegisterType((*ModifyMessageReactionExtensionsReq)(nil), "msg.ModifyMessageReactionExtensionsReq") - proto.RegisterMapType((map[string]*sdk_ws.KeyValue)(nil), "msg.ModifyMessageReactionExtensionsReq.ReactionExtensionListEntry") + proto.RegisterMapType((map[string]*sdkws.KeyValue)(nil), "msg.ModifyMessageReactionExtensionsReq.ReactionExtensionListEntry") proto.RegisterType((*SetMessageReactionExtensionsReq)(nil), "msg.SetMessageReactionExtensionsReq") - proto.RegisterMapType((map[string]*sdk_ws.KeyValue)(nil), "msg.SetMessageReactionExtensionsReq.ReactionExtensionListEntry") + proto.RegisterMapType((map[string]*sdkws.KeyValue)(nil), "msg.SetMessageReactionExtensionsReq.ReactionExtensionListEntry") proto.RegisterType((*SetMessageReactionExtensionsResp)(nil), "msg.SetMessageReactionExtensionsResp") proto.RegisterType((*GetMessageListReactionExtensionsReq)(nil), "msg.GetMessageListReactionExtensionsReq") proto.RegisterType((*GetMessageListReactionExtensionsReq_MessageReactionKey)(nil), "msg.GetMessageListReactionExtensionsReq.MessageReactionKey") proto.RegisterType((*GetMessageListReactionExtensionsResp)(nil), "msg.GetMessageListReactionExtensionsResp") proto.RegisterType((*SingleMessageExtensionResult)(nil), "msg.SingleMessageExtensionResult") - proto.RegisterMapType((map[string]*sdk_ws.KeyValue)(nil), "msg.SingleMessageExtensionResult.ReactionExtensionListEntry") + proto.RegisterMapType((map[string]*sdkws.KeyValue)(nil), "msg.SingleMessageExtensionResult.ReactionExtensionListEntry") proto.RegisterType((*ModifyMessageReactionExtensionsResp)(nil), "msg.ModifyMessageReactionExtensionsResp") proto.RegisterType((*DeleteMessageListReactionExtensionsReq)(nil), "msg.DeleteMessageListReactionExtensionsReq") proto.RegisterType((*DeleteMessageListReactionExtensionsResp)(nil), "msg.DeleteMessageListReactionExtensionsResp") @@ -2088,13 +2088,13 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // 获取最小最大seq(包括用户的,以及指定群组的) - GetMaxAndMinSeq(ctx context.Context, in *sdk_ws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdk_ws.GetMaxAndMinSeqResp, error) + GetMaxAndMinSeq(ctx context.Context, in *sdkws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdkws.GetMaxAndMinSeqResp, error) // 拉取历史消息(包括用户的,以及指定群组的) - PullMessageBySeqList(ctx context.Context, in *sdk_ws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdk_ws.PullMessageBySeqListResp, error) + PullMessageBySeqList(ctx context.Context, in *sdkws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdkws.PullMessageBySeqListResp, error) // 发送消息 SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgResp, error) // 删除某人消息 - DelMsgList(ctx context.Context, in *sdk_ws.DelMsgListReq, opts ...grpc.CallOption) (*sdk_ws.DelMsgListResp, error) + DelMsgList(ctx context.Context, in *sdkws.DelMsgListReq, opts ...grpc.CallOption) (*sdkws.DelMsgListResp, error) // 删除某个用户某个大群消息 DelSuperGroupMsg(ctx context.Context, in *DelSuperGroupMsgReq, opts ...grpc.CallOption) (*DelSuperGroupMsgResp, error) // 清空某人所有消息 @@ -2118,8 +2118,8 @@ func NewMsgClient(cc *grpc.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) GetMaxAndMinSeq(ctx context.Context, in *sdk_ws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdk_ws.GetMaxAndMinSeqResp, error) { - out := new(sdk_ws.GetMaxAndMinSeqResp) +func (c *msgClient) GetMaxAndMinSeq(ctx context.Context, in *sdkws.GetMaxAndMinSeqReq, opts ...grpc.CallOption) (*sdkws.GetMaxAndMinSeqResp, error) { + out := new(sdkws.GetMaxAndMinSeqResp) err := grpc.Invoke(ctx, "/msg.msg/GetMaxAndMinSeq", in, out, c.cc, opts...) if err != nil { return nil, err @@ -2127,8 +2127,8 @@ func (c *msgClient) GetMaxAndMinSeq(ctx context.Context, in *sdk_ws.GetMaxAndMin return out, nil } -func (c *msgClient) PullMessageBySeqList(ctx context.Context, in *sdk_ws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdk_ws.PullMessageBySeqListResp, error) { - out := new(sdk_ws.PullMessageBySeqListResp) +func (c *msgClient) PullMessageBySeqList(ctx context.Context, in *sdkws.PullMessageBySeqListReq, opts ...grpc.CallOption) (*sdkws.PullMessageBySeqListResp, error) { + out := new(sdkws.PullMessageBySeqListResp) err := grpc.Invoke(ctx, "/msg.msg/PullMessageBySeqList", in, out, c.cc, opts...) if err != nil { return nil, err @@ -2145,8 +2145,8 @@ func (c *msgClient) SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.Ca return out, nil } -func (c *msgClient) DelMsgList(ctx context.Context, in *sdk_ws.DelMsgListReq, opts ...grpc.CallOption) (*sdk_ws.DelMsgListResp, error) { - out := new(sdk_ws.DelMsgListResp) +func (c *msgClient) DelMsgList(ctx context.Context, in *sdkws.DelMsgListReq, opts ...grpc.CallOption) (*sdkws.DelMsgListResp, error) { + out := new(sdkws.DelMsgListResp) err := grpc.Invoke(ctx, "/msg.msg/DelMsgList", in, out, c.cc, opts...) if err != nil { return nil, err @@ -2230,13 +2230,13 @@ func (c *msgClient) DeleteMessageReactionExtensions(ctx context.Context, in *Del type MsgServer interface { // 获取最小最大seq(包括用户的,以及指定群组的) - GetMaxAndMinSeq(context.Context, *sdk_ws.GetMaxAndMinSeqReq) (*sdk_ws.GetMaxAndMinSeqResp, error) + GetMaxAndMinSeq(context.Context, *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) // 拉取历史消息(包括用户的,以及指定群组的) - PullMessageBySeqList(context.Context, *sdk_ws.PullMessageBySeqListReq) (*sdk_ws.PullMessageBySeqListResp, error) + PullMessageBySeqList(context.Context, *sdkws.PullMessageBySeqListReq) (*sdkws.PullMessageBySeqListResp, error) // 发送消息 SendMsg(context.Context, *SendMsgReq) (*SendMsgResp, error) // 删除某人消息 - DelMsgList(context.Context, *sdk_ws.DelMsgListReq) (*sdk_ws.DelMsgListResp, error) + DelMsgList(context.Context, *sdkws.DelMsgListReq) (*sdkws.DelMsgListResp, error) // 删除某个用户某个大群消息 DelSuperGroupMsg(context.Context, *DelSuperGroupMsgReq) (*DelSuperGroupMsgResp, error) // 清空某人所有消息 @@ -2257,7 +2257,7 @@ func RegisterMsgServer(s *grpc.Server, srv MsgServer) { } func _Msg_GetMaxAndMinSeq_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(sdk_ws.GetMaxAndMinSeqReq) + in := new(sdkws.GetMaxAndMinSeqReq) if err := dec(in); err != nil { return nil, err } @@ -2269,13 +2269,13 @@ func _Msg_GetMaxAndMinSeq_Handler(srv interface{}, ctx context.Context, dec func FullMethod: "/msg.msg/GetMaxAndMinSeq", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).GetMaxAndMinSeq(ctx, req.(*sdk_ws.GetMaxAndMinSeqReq)) + return srv.(MsgServer).GetMaxAndMinSeq(ctx, req.(*sdkws.GetMaxAndMinSeqReq)) } return interceptor(ctx, in, info, handler) } func _Msg_PullMessageBySeqList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(sdk_ws.PullMessageBySeqListReq) + in := new(sdkws.PullMessageBySeqListReq) if err := dec(in); err != nil { return nil, err } @@ -2287,7 +2287,7 @@ func _Msg_PullMessageBySeqList_Handler(srv interface{}, ctx context.Context, dec FullMethod: "/msg.msg/PullMessageBySeqList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).PullMessageBySeqList(ctx, req.(*sdk_ws.PullMessageBySeqListReq)) + return srv.(MsgServer).PullMessageBySeqList(ctx, req.(*sdkws.PullMessageBySeqListReq)) } return interceptor(ctx, in, info, handler) } @@ -2311,7 +2311,7 @@ func _Msg_SendMsg_Handler(srv interface{}, ctx context.Context, dec func(interfa } func _Msg_DelMsgList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(sdk_ws.DelMsgListReq) + in := new(sdkws.DelMsgListReq) if err := dec(in); err != nil { return nil, err } @@ -2323,7 +2323,7 @@ func _Msg_DelMsgList_Handler(srv interface{}, ctx context.Context, dec func(inte FullMethod: "/msg.msg/DelMsgList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DelMsgList(ctx, req.(*sdk_ws.DelMsgListReq)) + return srv.(MsgServer).DelMsgList(ctx, req.(*sdkws.DelMsgListReq)) } return interceptor(ctx, in, info, handler) } @@ -2529,107 +2529,107 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "msg/msg.proto", } -func init() { proto.RegisterFile("msg/msg.proto", fileDescriptor_msg_69316330d19ec9fa) } +func init() { proto.RegisterFile("msg/msg.proto", fileDescriptor_msg_9bd9d9abca588885) } -var fileDescriptor_msg_69316330d19ec9fa = []byte{ - // 1572 bytes of a gzipped FileDescriptorProto +var fileDescriptor_msg_9bd9d9abca588885 = []byte{ + // 1569 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xcd, 0x6e, 0xdb, 0x46, 0x10, 0x06, 0x49, 0x4b, 0xb6, 0x47, 0x76, 0xec, 0xac, 0x1d, 0x43, 0x61, 0x8d, 0x46, 0x65, 0x92, - 0x46, 0x41, 0x12, 0x19, 0x70, 0x8b, 0xfe, 0xa5, 0x40, 0x1b, 0x47, 0xae, 0x62, 0xa4, 0x6c, 0x12, - 0xca, 0x6d, 0x90, 0xe6, 0x90, 0x32, 0xd6, 0x9a, 0x21, 0xc4, 0x3f, 0x73, 0xa9, 0x58, 0x02, 0x7a, + 0x5a, 0x41, 0x62, 0x19, 0x70, 0x8b, 0xfe, 0xa5, 0x40, 0x1b, 0x47, 0xae, 0x62, 0xa4, 0x6c, 0x12, + 0xca, 0x6d, 0x90, 0xe6, 0x90, 0x32, 0xd6, 0x9a, 0x21, 0xcc, 0x3f, 0x73, 0xa9, 0x58, 0x02, 0x7a, 0xe9, 0xa1, 0xbd, 0xf5, 0x35, 0x7a, 0xeb, 0x43, 0xe4, 0x09, 0xfa, 0x20, 0x3d, 0x15, 0xe8, 0xb9, 0x2d, 0x76, 0xb9, 0xa2, 0xf8, 0x2b, 0xd1, 0x0a, 0x02, 0xe4, 0xd0, 0x9b, 0x67, 0x76, 0x76, 0x7e, - 0xbf, 0x19, 0x2d, 0xc7, 0xb0, 0x6a, 0x13, 0x63, 0xc7, 0x26, 0x46, 0xcb, 0xf3, 0xdd, 0xc0, 0x45, - 0x92, 0x4d, 0x0c, 0xb9, 0xf9, 0xc0, 0xc3, 0xce, 0xad, 0x03, 0xf5, 0x56, 0x17, 0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ae, 0x42, 0xed, 0xae, 0x85, 0x75, 0x9f, - 0xfb, 0xb9, 0x05, 0xd5, 0x41, 0x22, 0xd1, 0x21, 0xa5, 0x9c, 0x83, 0x95, 0x89, 0x18, 0xf1, 0x94, - 0xa7, 0xb0, 0xd6, 0xc5, 0x54, 0x7d, 0xa2, 0x46, 0x79, 0x57, 0x69, 0xaa, 0x0d, 0xdf, 0x1d, 0x78, - 0x51, 0x7d, 0xc6, 0x24, 0xbd, 0x61, 0x87, 0xa9, 0xe3, 0x29, 0x0d, 0x29, 0x05, 0xc1, 0x7a, 0x52, - 0x39, 0xf1, 0x94, 0x5b, 0xb0, 0xd1, 0xc5, 0x01, 0xcf, 0x4c, 0x37, 0xd0, 0x83, 0x01, 0xe1, 0x46, - 0x09, 0x23, 0x98, 0xee, 0x8a, 0xc6, 0x29, 0x65, 0x0b, 0x36, 0xb3, 0xe2, 0xc4, 0x53, 0x3e, 0x66, - 0x70, 0xc8, 0xa8, 0x49, 0x35, 0xb1, 0x90, 0x6d, 0xe2, 0x1f, 0x60, 0xb3, 0x93, 0xa3, 0x90, 0x46, - 0x87, 0x93, 0x40, 0xc2, 0x13, 0x20, 0xe1, 0x04, 0x90, 0x70, 0x04, 0x24, 0xee, 0xb2, 0x94, 0x70, - 0xb9, 0x03, 0x1b, 0x6d, 0x6c, 0x75, 0x07, 0x1e, 0xf6, 0x3b, 0x34, 0x41, 0x99, 0x8a, 0x88, 0x45, - 0x69, 0x95, 0x12, 0x69, 0xa5, 0xb1, 0x67, 0x15, 0x11, 0x4f, 0x39, 0x0a, 0x63, 0x4f, 0x1b, 0x98, - 0x19, 0x3b, 0x5a, 0x07, 0x89, 0x16, 0x49, 0x64, 0x45, 0xa2, 0x7f, 0x4e, 0x31, 0xee, 0x87, 0x79, - 0x4a, 0x1b, 0x9f, 0x23, 0x4f, 0xe5, 0x5b, 0xe6, 0x1e, 0x9b, 0x19, 0x8f, 0x7d, 0x33, 0xc0, 0x6d, - 0xf3, 0xf8, 0x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e, 0xcc, 0x69, 0x23, 0x12, 0x5d, 0x83, 0x65, 0xdd, 0x30, + 0x7c, 0x6c, 0x24, 0x03, 0x4b, 0x32, 0xd1, 0x2e, 0xd4, 0x6c, 0x4c, 0x88, 0x6e, 0xe0, 0xaf, 0x4d, + 0x12, 0xd4, 0xa5, 0x86, 0xd4, 0xac, 0xed, 0xae, 0xb6, 0x28, 0x48, 0x62, 0xd1, 0x6a, 0x71, 0x21, + 0xb4, 0x09, 0x8b, 0x81, 0x6f, 0x1a, 0x06, 0xf3, 0x75, 0x8e, 0x69, 0x1d, 0x33, 0x94, 0x6f, 0x00, + 0x75, 0x70, 0xa0, 0xea, 0x83, 0x3b, 0x4e, 0x4f, 0x35, 0x9d, 0x2e, 0x3e, 0xd5, 0xf0, 0x29, 0xda, + 0x80, 0x2a, 0x0f, 0x2e, 0xcc, 0x14, 0xa7, 0xd2, 0x69, 0x14, 0x33, 0x69, 0x54, 0xce, 0x60, 0x2d, + 0xa3, 0x8f, 0x78, 0x34, 0xf0, 0x7d, 0xdf, 0xbf, 0xeb, 0xf6, 0x30, 0xd3, 0x58, 0xd1, 0x46, 0x24, + 0x35, 0xb5, 0xef, 0xfb, 0x2a, 0x31, 0xb8, 0x36, 0x4e, 0x51, 0xbe, 0xaa, 0x0f, 0x68, 0xa6, 0x68, + 0x7e, 0x97, 0x35, 0x4e, 0x31, 0x3e, 0xd3, 0xcb, 0x62, 0xa1, 0x7c, 0x46, 0x29, 0x1f, 0x01, 0x74, + 0xb1, 0xd3, 0x53, 0x89, 0x41, 0x03, 0x28, 0x0f, 0x44, 0x1b, 0x6a, 0xd1, 0x3d, 0xe2, 0xd1, 0x08, + 0x09, 0xeb, 0x18, 0x95, 0x18, 0x51, 0xbe, 0xe2, 0x2c, 0x2a, 0x71, 0x64, 0x99, 0xd8, 0x09, 0x42, + 0x89, 0x4a, 0x28, 0x11, 0x63, 0x21, 0x19, 0x16, 0x08, 0x76, 0x7a, 0x87, 0xa6, 0x8d, 0xeb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 0xc1, 0x8c, 0xaf, 0x73, 0xe5, 0x63, 0x16, 0xbd, 0x75, 0x29, 0x87, 0x4b, 0x3c, 0xd4, 0x81, 0xd5, + 0xf4, 0xc6, 0x06, 0xd5, 0x99, 0x81, 0x9c, 0x8d, 0x90, 0x7c, 0xb9, 0xe0, 0x84, 0x78, 0x68, 0x07, + 0x16, 0x46, 0x6b, 0x3a, 0x14, 0x7a, 0x18, 0x5b, 0xee, 0xc9, 0x17, 0x53, 0x9c, 0xd0, 0x72, 0x7a, + 0x4f, 0xc6, 0x2d, 0xe7, 0x6c, 0xdb, 0xb8, 0xe5, 0xbc, 0xc5, 0x1a, 0x55, 0xd4, 0xc9, 0x57, 0xd4, + 0x29, 0x54, 0x94, 0xbb, 0x50, 0x3b, 0x81, 0xcd, 0x49, 0x1f, 0x01, 0xe8, 0x5a, 0x99, 0x0f, 0x3d, + 0xf9, 0x7a, 0x09, 0x29, 0xe2, 0xa1, 0x33, 0x68, 0x4c, 0x7b, 0x02, 0xa2, 0x66, 0xd9, 0x47, 0xae, + 0x7c, 0xa3, 0xa4, 0x24, 0xf1, 0xd0, 0x29, 0x6c, 0xde, 0xe9, 0xf5, 0x8a, 0xa3, 0xdc, 0x2a, 0xb9, + 0x53, 0x91, 0x9b, 0xe5, 0x04, 0x89, 0x87, 0x7e, 0x84, 0x2b, 0x89, 0x9f, 0xb0, 0x1c, 0xab, 0x37, + 0x47, 0xc8, 0x2a, 0xf1, 0xb8, 0x90, 0x6f, 0x95, 0x17, 0x26, 0xde, 0xde, 0x3b, 0xdf, 0x5f, 0x7e, + 0xe0, 0x61, 0xe7, 0xd9, 0x81, 0x1a, 0xfb, 0xd7, 0x8f, 0x4d, 0x8c, 0xdb, 0x36, 0x31, 0x9e, 0x57, + 0x19, 0xf9, 0xc1, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb1, 0x5e, 0x2e, 0xb4, 0x62, 0x1a, 0x00, + 0x00, } diff --git a/pkg/proto/msg/msg.proto b/pkg/proto/msg/msg.proto index f4cac8ccc..45962720a 100644 --- a/pkg/proto/msg/msg.proto +++ b/pkg/proto/msg/msg.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto"; -import "Open-IM-Server/pkg/proto/sdk_ws/wrappers.proto"; +import "Open-IM-Server/pkg/proto/sdkws/ws.proto"; +import "Open-IM-Server/pkg/proto/sdkws/wrappers.proto"; option go_package = "Open_IM/pkg/proto/msg;msg"; package msg; diff --git a/pkg/proto/sdkws/ws.pb.go b/pkg/proto/sdkws/ws.pb.go index 2bba6281c..265075a49 100644 --- a/pkg/proto/sdkws/ws.pb.go +++ b/pkg/proto/sdkws/ws.pb.go @@ -46,7 +46,7 @@ func (m *GroupInfo) Reset() { *m = GroupInfo{} } func (m *GroupInfo) String() string { return proto.CompactTextString(m) } func (*GroupInfo) ProtoMessage() {} func (*GroupInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{0} + return fileDescriptor_ws_a0747f665ef3b307, []int{0} } func (m *GroupInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupInfo.Unmarshal(m, b) @@ -204,7 +204,7 @@ func (m *GroupInfoForSet) Reset() { *m = GroupInfoForSet{} } func (m *GroupInfoForSet) String() string { return proto.CompactTextString(m) } func (*GroupInfoForSet) ProtoMessage() {} func (*GroupInfoForSet) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{1} + return fileDescriptor_ws_a0747f665ef3b307, []int{1} } func (m *GroupInfoForSet) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupInfoForSet.Unmarshal(m, b) @@ -309,7 +309,7 @@ func (m *GroupMemberFullInfo) Reset() { *m = GroupMemberFullInfo{} } func (m *GroupMemberFullInfo) String() string { return proto.CompactTextString(m) } func (*GroupMemberFullInfo) ProtoMessage() {} func (*GroupMemberFullInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{2} + return fileDescriptor_ws_a0747f665ef3b307, []int{2} } func (m *GroupMemberFullInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupMemberFullInfo.Unmarshal(m, b) @@ -428,7 +428,7 @@ func (m *PublicUserInfo) Reset() { *m = PublicUserInfo{} } func (m *PublicUserInfo) String() string { return proto.CompactTextString(m) } func (*PublicUserInfo) ProtoMessage() {} func (*PublicUserInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{3} + return fileDescriptor_ws_a0747f665ef3b307, []int{3} } func (m *PublicUserInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PublicUserInfo.Unmarshal(m, b) @@ -505,7 +505,7 @@ func (m *UserInfo) Reset() { *m = UserInfo{} } func (m *UserInfo) String() string { return proto.CompactTextString(m) } func (*UserInfo) ProtoMessage() {} func (*UserInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{4} + return fileDescriptor_ws_a0747f665ef3b307, []int{4} } func (m *UserInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UserInfo.Unmarshal(m, b) @@ -626,7 +626,7 @@ func (m *FriendInfo) Reset() { *m = FriendInfo{} } func (m *FriendInfo) String() string { return proto.CompactTextString(m) } func (*FriendInfo) ProtoMessage() {} func (*FriendInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{5} + return fileDescriptor_ws_a0747f665ef3b307, []int{5} } func (m *FriendInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendInfo.Unmarshal(m, b) @@ -711,7 +711,7 @@ func (m *BlackInfo) Reset() { *m = BlackInfo{} } func (m *BlackInfo) String() string { return proto.CompactTextString(m) } func (*BlackInfo) ProtoMessage() {} func (*BlackInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{6} + return fileDescriptor_ws_a0747f665ef3b307, []int{6} } func (m *BlackInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BlackInfo.Unmarshal(m, b) @@ -794,7 +794,7 @@ func (m *GroupRequest) Reset() { *m = GroupRequest{} } func (m *GroupRequest) String() string { return proto.CompactTextString(m) } func (*GroupRequest) ProtoMessage() {} func (*GroupRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{7} + return fileDescriptor_ws_a0747f665ef3b307, []int{7} } func (m *GroupRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupRequest.Unmarshal(m, b) @@ -916,7 +916,7 @@ func (m *FriendRequest) Reset() { *m = FriendRequest{} } func (m *FriendRequest) String() string { return proto.CompactTextString(m) } func (*FriendRequest) ProtoMessage() {} func (*FriendRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{8} + return fileDescriptor_ws_a0747f665ef3b307, []int{8} } func (m *FriendRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendRequest.Unmarshal(m, b) @@ -1041,424 +1041,9 @@ func (m *FriendRequest) GetEx() string { return "" } -type Department struct { - DepartmentID string `protobuf:"bytes,1,opt,name=departmentID" json:"departmentID,omitempty"` - FaceURL string `protobuf:"bytes,2,opt,name=faceURL" json:"faceURL,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` - ParentID string `protobuf:"bytes,4,opt,name=parentID" json:"parentID,omitempty"` - Order int32 `protobuf:"varint,5,opt,name=order" json:"order,omitempty"` - DepartmentType int32 `protobuf:"varint,6,opt,name=departmentType" json:"departmentType,omitempty"` - CreateTime int64 `protobuf:"varint,7,opt,name=createTime" json:"createTime,omitempty"` - SubDepartmentNum uint32 `protobuf:"varint,8,opt,name=subDepartmentNum" json:"subDepartmentNum,omitempty"` - MemberNum uint32 `protobuf:"varint,9,opt,name=memberNum" json:"memberNum,omitempty"` - Ex string `protobuf:"bytes,10,opt,name=ex" json:"ex,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Department) Reset() { *m = Department{} } -func (m *Department) String() string { return proto.CompactTextString(m) } -func (*Department) ProtoMessage() {} -func (*Department) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{9} -} -func (m *Department) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Department.Unmarshal(m, b) -} -func (m *Department) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Department.Marshal(b, m, deterministic) -} -func (dst *Department) XXX_Merge(src proto.Message) { - xxx_messageInfo_Department.Merge(dst, src) -} -func (m *Department) XXX_Size() int { - return xxx_messageInfo_Department.Size(m) -} -func (m *Department) XXX_DiscardUnknown() { - xxx_messageInfo_Department.DiscardUnknown(m) -} - -var xxx_messageInfo_Department proto.InternalMessageInfo - -func (m *Department) GetDepartmentID() string { - if m != nil { - return m.DepartmentID - } - return "" -} - -func (m *Department) GetFaceURL() string { - if m != nil { - return m.FaceURL - } - return "" -} - -func (m *Department) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Department) GetParentID() string { - if m != nil { - return m.ParentID - } - return "" -} - -func (m *Department) GetOrder() int32 { - if m != nil { - return m.Order - } - return 0 -} - -func (m *Department) GetDepartmentType() int32 { - if m != nil { - return m.DepartmentType - } - return 0 -} - -func (m *Department) GetCreateTime() int64 { - if m != nil { - return m.CreateTime - } - return 0 -} - -func (m *Department) GetSubDepartmentNum() uint32 { - if m != nil { - return m.SubDepartmentNum - } - return 0 -} - -func (m *Department) GetMemberNum() uint32 { - if m != nil { - return m.MemberNum - } - return 0 -} - -func (m *Department) GetEx() string { - if m != nil { - return m.Ex - } - return "" -} - -type OrganizationUser struct { - UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` - Nickname string `protobuf:"bytes,2,opt,name=nickname" json:"nickname,omitempty"` - EnglishName string `protobuf:"bytes,3,opt,name=englishName" json:"englishName,omitempty"` - FaceURL string `protobuf:"bytes,4,opt,name=faceURL" json:"faceURL,omitempty"` - Gender int32 `protobuf:"varint,5,opt,name=gender" json:"gender,omitempty"` - Mobile string `protobuf:"bytes,6,opt,name=mobile" json:"mobile,omitempty"` - Telephone string `protobuf:"bytes,7,opt,name=telephone" json:"telephone,omitempty"` - Birth uint32 `protobuf:"varint,8,opt,name=birth" json:"birth,omitempty"` - Email string `protobuf:"bytes,9,opt,name=email" json:"email,omitempty"` - CreateTime int64 `protobuf:"varint,10,opt,name=createTime" json:"createTime,omitempty"` - Ex string `protobuf:"bytes,11,opt,name=ex" json:"ex,omitempty"` - BirthStr string `protobuf:"bytes,12,opt,name=birthStr" json:"birthStr,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *OrganizationUser) Reset() { *m = OrganizationUser{} } -func (m *OrganizationUser) String() string { return proto.CompactTextString(m) } -func (*OrganizationUser) ProtoMessage() {} -func (*OrganizationUser) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{10} -} -func (m *OrganizationUser) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_OrganizationUser.Unmarshal(m, b) -} -func (m *OrganizationUser) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_OrganizationUser.Marshal(b, m, deterministic) -} -func (dst *OrganizationUser) XXX_Merge(src proto.Message) { - xxx_messageInfo_OrganizationUser.Merge(dst, src) -} -func (m *OrganizationUser) XXX_Size() int { - return xxx_messageInfo_OrganizationUser.Size(m) -} -func (m *OrganizationUser) XXX_DiscardUnknown() { - xxx_messageInfo_OrganizationUser.DiscardUnknown(m) -} - -var xxx_messageInfo_OrganizationUser proto.InternalMessageInfo - -func (m *OrganizationUser) GetUserID() string { - if m != nil { - return m.UserID - } - return "" -} - -func (m *OrganizationUser) GetNickname() string { - if m != nil { - return m.Nickname - } - return "" -} - -func (m *OrganizationUser) GetEnglishName() string { - if m != nil { - return m.EnglishName - } - return "" -} - -func (m *OrganizationUser) GetFaceURL() string { - if m != nil { - return m.FaceURL - } - return "" -} - -func (m *OrganizationUser) GetGender() int32 { - if m != nil { - return m.Gender - } - return 0 -} - -func (m *OrganizationUser) GetMobile() string { - if m != nil { - return m.Mobile - } - return "" -} - -func (m *OrganizationUser) GetTelephone() string { - if m != nil { - return m.Telephone - } - return "" -} - -func (m *OrganizationUser) GetBirth() uint32 { - if m != nil { - return m.Birth - } - return 0 -} - -func (m *OrganizationUser) GetEmail() string { - if m != nil { - return m.Email - } - return "" -} - -func (m *OrganizationUser) GetCreateTime() int64 { - if m != nil { - return m.CreateTime - } - return 0 -} - -func (m *OrganizationUser) GetEx() string { - if m != nil { - return m.Ex - } - return "" -} - -func (m *OrganizationUser) GetBirthStr() string { - if m != nil { - return m.BirthStr - } - return "" -} - -type DepartmentMember struct { - UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` - DepartmentID string `protobuf:"bytes,2,opt,name=departmentID" json:"departmentID,omitempty"` - Order int32 `protobuf:"varint,3,opt,name=order" json:"order,omitempty"` - Position string `protobuf:"bytes,4,opt,name=position" json:"position,omitempty"` - Leader int32 `protobuf:"varint,5,opt,name=leader" json:"leader,omitempty"` - Status int32 `protobuf:"varint,6,opt,name=status" json:"status,omitempty"` - Ex string `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DepartmentMember) Reset() { *m = DepartmentMember{} } -func (m *DepartmentMember) String() string { return proto.CompactTextString(m) } -func (*DepartmentMember) ProtoMessage() {} -func (*DepartmentMember) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{11} -} -func (m *DepartmentMember) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DepartmentMember.Unmarshal(m, b) -} -func (m *DepartmentMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DepartmentMember.Marshal(b, m, deterministic) -} -func (dst *DepartmentMember) XXX_Merge(src proto.Message) { - xxx_messageInfo_DepartmentMember.Merge(dst, src) -} -func (m *DepartmentMember) XXX_Size() int { - return xxx_messageInfo_DepartmentMember.Size(m) -} -func (m *DepartmentMember) XXX_DiscardUnknown() { - xxx_messageInfo_DepartmentMember.DiscardUnknown(m) -} - -var xxx_messageInfo_DepartmentMember proto.InternalMessageInfo - -func (m *DepartmentMember) GetUserID() string { - if m != nil { - return m.UserID - } - return "" -} - -func (m *DepartmentMember) GetDepartmentID() string { - if m != nil { - return m.DepartmentID - } - return "" -} - -func (m *DepartmentMember) GetOrder() int32 { - if m != nil { - return m.Order - } - return 0 -} - -func (m *DepartmentMember) GetPosition() string { - if m != nil { - return m.Position - } - return "" -} - -func (m *DepartmentMember) GetLeader() int32 { - if m != nil { - return m.Leader - } - return 0 -} - -func (m *DepartmentMember) GetStatus() int32 { - if m != nil { - return m.Status - } - return 0 -} - -func (m *DepartmentMember) GetEx() string { - if m != nil { - return m.Ex - } - return "" -} - -type UserDepartmentMember struct { - OrganizationUser *OrganizationUser `protobuf:"bytes,1,opt,name=organizationUser" json:"organizationUser,omitempty"` - DepartmentMember *DepartmentMember `protobuf:"bytes,2,opt,name=departmentMember" json:"departmentMember,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UserDepartmentMember) Reset() { *m = UserDepartmentMember{} } -func (m *UserDepartmentMember) String() string { return proto.CompactTextString(m) } -func (*UserDepartmentMember) ProtoMessage() {} -func (*UserDepartmentMember) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{12} -} -func (m *UserDepartmentMember) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UserDepartmentMember.Unmarshal(m, b) -} -func (m *UserDepartmentMember) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UserDepartmentMember.Marshal(b, m, deterministic) -} -func (dst *UserDepartmentMember) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserDepartmentMember.Merge(dst, src) -} -func (m *UserDepartmentMember) XXX_Size() int { - return xxx_messageInfo_UserDepartmentMember.Size(m) -} -func (m *UserDepartmentMember) XXX_DiscardUnknown() { - xxx_messageInfo_UserDepartmentMember.DiscardUnknown(m) -} - -var xxx_messageInfo_UserDepartmentMember proto.InternalMessageInfo - -func (m *UserDepartmentMember) GetOrganizationUser() *OrganizationUser { - if m != nil { - return m.OrganizationUser - } - return nil -} - -func (m *UserDepartmentMember) GetDepartmentMember() *DepartmentMember { - if m != nil { - return m.DepartmentMember - } - return nil -} - -type UserInDepartment struct { - OrganizationUser *OrganizationUser `protobuf:"bytes,1,opt,name=organizationUser" json:"organizationUser,omitempty"` - DepartmentMemberList []*DepartmentMember `protobuf:"bytes,2,rep,name=departmentMemberList" json:"departmentMemberList,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UserInDepartment) Reset() { *m = UserInDepartment{} } -func (m *UserInDepartment) String() string { return proto.CompactTextString(m) } -func (*UserInDepartment) ProtoMessage() {} -func (*UserInDepartment) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{13} -} -func (m *UserInDepartment) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UserInDepartment.Unmarshal(m, b) -} -func (m *UserInDepartment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UserInDepartment.Marshal(b, m, deterministic) -} -func (dst *UserInDepartment) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserInDepartment.Merge(dst, src) -} -func (m *UserInDepartment) XXX_Size() int { - return xxx_messageInfo_UserInDepartment.Size(m) -} -func (m *UserInDepartment) XXX_DiscardUnknown() { - xxx_messageInfo_UserInDepartment.DiscardUnknown(m) -} - -var xxx_messageInfo_UserInDepartment proto.InternalMessageInfo - -func (m *UserInDepartment) GetOrganizationUser() *OrganizationUser { - if m != nil { - return m.OrganizationUser - } - return nil -} - -func (m *UserInDepartment) GetDepartmentMemberList() []*DepartmentMember { - if m != nil { - return m.DepartmentMemberList - } - return nil -} - // /////////////////////////////////base end///////////////////////////////////// type PullMessageBySeqListReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` - OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"` SeqList []uint32 `protobuf:"varint,3,rep,packed,name=seqList" json:"seqList,omitempty"` GroupSeqList map[string]*SeqList `protobuf:"bytes,4,rep,name=groupSeqList" json:"groupSeqList,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1470,7 +1055,7 @@ func (m *PullMessageBySeqListReq) Reset() { *m = PullMessageBySeqListReq func (m *PullMessageBySeqListReq) String() string { return proto.CompactTextString(m) } func (*PullMessageBySeqListReq) ProtoMessage() {} func (*PullMessageBySeqListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{14} + return fileDescriptor_ws_a0747f665ef3b307, []int{9} } func (m *PullMessageBySeqListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PullMessageBySeqListReq.Unmarshal(m, b) @@ -1497,13 +1082,6 @@ func (m *PullMessageBySeqListReq) GetUserID() string { return "" } -func (m *PullMessageBySeqListReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - func (m *PullMessageBySeqListReq) GetSeqList() []uint32 { if m != nil { return m.SeqList @@ -1529,7 +1107,7 @@ func (m *SeqList) Reset() { *m = SeqList{} } func (m *SeqList) String() string { return proto.CompactTextString(m) } func (*SeqList) ProtoMessage() {} func (*SeqList) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{15} + return fileDescriptor_ws_a0747f665ef3b307, []int{10} } func (m *SeqList) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SeqList.Unmarshal(m, b) @@ -1567,7 +1145,7 @@ func (m *MsgDataList) Reset() { *m = MsgDataList{} } func (m *MsgDataList) String() string { return proto.CompactTextString(m) } func (*MsgDataList) ProtoMessage() {} func (*MsgDataList) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{16} + return fileDescriptor_ws_a0747f665ef3b307, []int{11} } func (m *MsgDataList) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgDataList.Unmarshal(m, b) @@ -1608,7 +1186,7 @@ func (m *PullMessageBySeqListResp) Reset() { *m = PullMessageBySeqListRe func (m *PullMessageBySeqListResp) String() string { return proto.CompactTextString(m) } func (*PullMessageBySeqListResp) ProtoMessage() {} func (*PullMessageBySeqListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{17} + return fileDescriptor_ws_a0747f665ef3b307, []int{12} } func (m *PullMessageBySeqListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PullMessageBySeqListResp.Unmarshal(m, b) @@ -1659,7 +1237,6 @@ func (m *PullMessageBySeqListResp) GetGroupMsgDataList() map[string]*MsgDataList type GetMaxAndMinSeqReq struct { GroupIDList []string `protobuf:"bytes,1,rep,name=groupIDList" json:"groupIDList,omitempty"` UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` - OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1669,7 +1246,7 @@ func (m *GetMaxAndMinSeqReq) Reset() { *m = GetMaxAndMinSeqReq{} } func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqReq) ProtoMessage() {} func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{18} + return fileDescriptor_ws_a0747f665ef3b307, []int{13} } func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b) @@ -1703,13 +1280,6 @@ func (m *GetMaxAndMinSeqReq) GetUserID() string { return "" } -func (m *GetMaxAndMinSeqReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - type MaxAndMinSeq struct { MaxSeq uint32 `protobuf:"varint,1,opt,name=maxSeq" json:"maxSeq,omitempty"` MinSeq uint32 `protobuf:"varint,2,opt,name=minSeq" json:"minSeq,omitempty"` @@ -1722,7 +1292,7 @@ func (m *MaxAndMinSeq) Reset() { *m = MaxAndMinSeq{} } func (m *MaxAndMinSeq) String() string { return proto.CompactTextString(m) } func (*MaxAndMinSeq) ProtoMessage() {} func (*MaxAndMinSeq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{19} + return fileDescriptor_ws_a0747f665ef3b307, []int{14} } func (m *MaxAndMinSeq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MaxAndMinSeq.Unmarshal(m, b) @@ -1759,8 +1329,6 @@ func (m *MaxAndMinSeq) GetMinSeq() uint32 { type GetMaxAndMinSeqResp struct { MaxSeq uint32 `protobuf:"varint,1,opt,name=maxSeq" json:"maxSeq,omitempty"` MinSeq uint32 `protobuf:"varint,2,opt,name=minSeq" json:"minSeq,omitempty"` - ErrCode int32 `protobuf:"varint,3,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,4,opt,name=errMsg" json:"errMsg,omitempty"` GroupMaxAndMinSeq map[string]*MaxAndMinSeq `protobuf:"bytes,5,rep,name=groupMaxAndMinSeq" json:"groupMaxAndMinSeq,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -1771,7 +1339,7 @@ func (m *GetMaxAndMinSeqResp) Reset() { *m = GetMaxAndMinSeqResp{} } func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) } func (*GetMaxAndMinSeqResp) ProtoMessage() {} func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{20} + return fileDescriptor_ws_a0747f665ef3b307, []int{15} } func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b) @@ -1805,20 +1373,6 @@ func (m *GetMaxAndMinSeqResp) GetMinSeq() uint32 { return 0 } -func (m *GetMaxAndMinSeqResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *GetMaxAndMinSeqResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - func (m *GetMaxAndMinSeqResp) GetGroupMaxAndMinSeq() map[string]*MaxAndMinSeq { if m != nil { return m.GroupMaxAndMinSeq @@ -1839,7 +1393,7 @@ func (m *UserSendMsgResp) Reset() { *m = UserSendMsgResp{} } func (m *UserSendMsgResp) String() string { return proto.CompactTextString(m) } func (*UserSendMsgResp) ProtoMessage() {} func (*UserSendMsgResp) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{21} + return fileDescriptor_ws_a0747f665ef3b307, []int{16} } func (m *UserSendMsgResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UserSendMsgResp.Unmarshal(m, b) @@ -1912,7 +1466,7 @@ func (m *MsgData) Reset() { *m = MsgData{} } func (m *MsgData) String() string { return proto.CompactTextString(m) } func (*MsgData) ProtoMessage() {} func (*MsgData) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{22} + return fileDescriptor_ws_a0747f665ef3b307, []int{17} } func (m *MsgData) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MsgData.Unmarshal(m, b) @@ -2101,7 +1655,7 @@ func (m *OfflinePushInfo) Reset() { *m = OfflinePushInfo{} } func (m *OfflinePushInfo) String() string { return proto.CompactTextString(m) } func (*OfflinePushInfo) ProtoMessage() {} func (*OfflinePushInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{23} + return fileDescriptor_ws_a0747f665ef3b307, []int{18} } func (m *OfflinePushInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_OfflinePushInfo.Unmarshal(m, b) @@ -2169,7 +1723,7 @@ func (m *TipsComm) Reset() { *m = TipsComm{} } func (m *TipsComm) String() string { return proto.CompactTextString(m) } func (*TipsComm) ProtoMessage() {} func (*TipsComm) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{24} + return fileDescriptor_ws_a0747f665ef3b307, []int{19} } func (m *TipsComm) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_TipsComm.Unmarshal(m, b) @@ -2226,7 +1780,7 @@ func (m *GroupCreatedTips) Reset() { *m = GroupCreatedTips{} } func (m *GroupCreatedTips) String() string { return proto.CompactTextString(m) } func (*GroupCreatedTips) ProtoMessage() {} func (*GroupCreatedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{25} + return fileDescriptor_ws_a0747f665ef3b307, []int{20} } func (m *GroupCreatedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupCreatedTips.Unmarshal(m, b) @@ -2295,7 +1849,7 @@ func (m *GroupInfoSetTips) Reset() { *m = GroupInfoSetTips{} } func (m *GroupInfoSetTips) String() string { return proto.CompactTextString(m) } func (*GroupInfoSetTips) ProtoMessage() {} func (*GroupInfoSetTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{26} + return fileDescriptor_ws_a0747f665ef3b307, []int{21} } func (m *GroupInfoSetTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupInfoSetTips.Unmarshal(m, b) @@ -2350,7 +1904,7 @@ func (m *JoinGroupApplicationTips) Reset() { *m = JoinGroupApplicationTi func (m *JoinGroupApplicationTips) String() string { return proto.CompactTextString(m) } func (*JoinGroupApplicationTips) ProtoMessage() {} func (*JoinGroupApplicationTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{27} + return fileDescriptor_ws_a0747f665ef3b307, []int{22} } func (m *JoinGroupApplicationTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_JoinGroupApplicationTips.Unmarshal(m, b) @@ -2407,7 +1961,7 @@ func (m *MemberQuitTips) Reset() { *m = MemberQuitTips{} } func (m *MemberQuitTips) String() string { return proto.CompactTextString(m) } func (*MemberQuitTips) ProtoMessage() {} func (*MemberQuitTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{28} + return fileDescriptor_ws_a0747f665ef3b307, []int{23} } func (m *MemberQuitTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MemberQuitTips.Unmarshal(m, b) @@ -2463,7 +2017,7 @@ func (m *GroupApplicationAcceptedTips) Reset() { *m = GroupApplicationAc func (m *GroupApplicationAcceptedTips) String() string { return proto.CompactTextString(m) } func (*GroupApplicationAcceptedTips) ProtoMessage() {} func (*GroupApplicationAcceptedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{29} + return fileDescriptor_ws_a0747f665ef3b307, []int{24} } func (m *GroupApplicationAcceptedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupApplicationAcceptedTips.Unmarshal(m, b) @@ -2526,7 +2080,7 @@ func (m *GroupApplicationRejectedTips) Reset() { *m = GroupApplicationRe func (m *GroupApplicationRejectedTips) String() string { return proto.CompactTextString(m) } func (*GroupApplicationRejectedTips) ProtoMessage() {} func (*GroupApplicationRejectedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{30} + return fileDescriptor_ws_a0747f665ef3b307, []int{25} } func (m *GroupApplicationRejectedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupApplicationRejectedTips.Unmarshal(m, b) @@ -2589,7 +2143,7 @@ func (m *GroupOwnerTransferredTips) Reset() { *m = GroupOwnerTransferred func (m *GroupOwnerTransferredTips) String() string { return proto.CompactTextString(m) } func (*GroupOwnerTransferredTips) ProtoMessage() {} func (*GroupOwnerTransferredTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{31} + return fileDescriptor_ws_a0747f665ef3b307, []int{26} } func (m *GroupOwnerTransferredTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupOwnerTransferredTips.Unmarshal(m, b) @@ -2652,7 +2206,7 @@ func (m *MemberKickedTips) Reset() { *m = MemberKickedTips{} } func (m *MemberKickedTips) String() string { return proto.CompactTextString(m) } func (*MemberKickedTips) ProtoMessage() {} func (*MemberKickedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{32} + return fileDescriptor_ws_a0747f665ef3b307, []int{27} } func (m *MemberKickedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MemberKickedTips.Unmarshal(m, b) @@ -2715,7 +2269,7 @@ func (m *MemberInvitedTips) Reset() { *m = MemberInvitedTips{} } func (m *MemberInvitedTips) String() string { return proto.CompactTextString(m) } func (*MemberInvitedTips) ProtoMessage() {} func (*MemberInvitedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{33} + return fileDescriptor_ws_a0747f665ef3b307, []int{28} } func (m *MemberInvitedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MemberInvitedTips.Unmarshal(m, b) @@ -2777,7 +2331,7 @@ func (m *MemberEnterTips) Reset() { *m = MemberEnterTips{} } func (m *MemberEnterTips) String() string { return proto.CompactTextString(m) } func (*MemberEnterTips) ProtoMessage() {} func (*MemberEnterTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{34} + return fileDescriptor_ws_a0747f665ef3b307, []int{29} } func (m *MemberEnterTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MemberEnterTips.Unmarshal(m, b) @@ -2831,7 +2385,7 @@ func (m *GroupDismissedTips) Reset() { *m = GroupDismissedTips{} } func (m *GroupDismissedTips) String() string { return proto.CompactTextString(m) } func (*GroupDismissedTips) ProtoMessage() {} func (*GroupDismissedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{35} + return fileDescriptor_ws_a0747f665ef3b307, []int{30} } func (m *GroupDismissedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupDismissedTips.Unmarshal(m, b) @@ -2887,7 +2441,7 @@ func (m *GroupMemberMutedTips) Reset() { *m = GroupMemberMutedTips{} } func (m *GroupMemberMutedTips) String() string { return proto.CompactTextString(m) } func (*GroupMemberMutedTips) ProtoMessage() {} func (*GroupMemberMutedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{36} + return fileDescriptor_ws_a0747f665ef3b307, []int{31} } func (m *GroupMemberMutedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupMemberMutedTips.Unmarshal(m, b) @@ -2956,7 +2510,7 @@ func (m *GroupMemberCancelMutedTips) Reset() { *m = GroupMemberCancelMut func (m *GroupMemberCancelMutedTips) String() string { return proto.CompactTextString(m) } func (*GroupMemberCancelMutedTips) ProtoMessage() {} func (*GroupMemberCancelMutedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{37} + return fileDescriptor_ws_a0747f665ef3b307, []int{32} } func (m *GroupMemberCancelMutedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupMemberCancelMutedTips.Unmarshal(m, b) @@ -3017,7 +2571,7 @@ func (m *GroupMutedTips) Reset() { *m = GroupMutedTips{} } func (m *GroupMutedTips) String() string { return proto.CompactTextString(m) } func (*GroupMutedTips) ProtoMessage() {} func (*GroupMutedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{38} + return fileDescriptor_ws_a0747f665ef3b307, []int{33} } func (m *GroupMutedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupMutedTips.Unmarshal(m, b) @@ -3071,7 +2625,7 @@ func (m *GroupCancelMutedTips) Reset() { *m = GroupCancelMutedTips{} } func (m *GroupCancelMutedTips) String() string { return proto.CompactTextString(m) } func (*GroupCancelMutedTips) ProtoMessage() {} func (*GroupCancelMutedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{39} + return fileDescriptor_ws_a0747f665ef3b307, []int{34} } func (m *GroupCancelMutedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupCancelMutedTips.Unmarshal(m, b) @@ -3126,7 +2680,7 @@ func (m *GroupMemberInfoSetTips) Reset() { *m = GroupMemberInfoSetTips{} func (m *GroupMemberInfoSetTips) String() string { return proto.CompactTextString(m) } func (*GroupMemberInfoSetTips) ProtoMessage() {} func (*GroupMemberInfoSetTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{40} + return fileDescriptor_ws_a0747f665ef3b307, []int{35} } func (m *GroupMemberInfoSetTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupMemberInfoSetTips.Unmarshal(m, b) @@ -3186,7 +2740,7 @@ func (m *OrganizationChangedTips) Reset() { *m = OrganizationChangedTips func (m *OrganizationChangedTips) String() string { return proto.CompactTextString(m) } func (*OrganizationChangedTips) ProtoMessage() {} func (*OrganizationChangedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{41} + return fileDescriptor_ws_a0747f665ef3b307, []int{36} } func (m *OrganizationChangedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_OrganizationChangedTips.Unmarshal(m, b) @@ -3233,7 +2787,7 @@ func (m *FriendApplication) Reset() { *m = FriendApplication{} } func (m *FriendApplication) String() string { return proto.CompactTextString(m) } func (*FriendApplication) ProtoMessage() {} func (*FriendApplication) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{42} + return fileDescriptor_ws_a0747f665ef3b307, []int{37} } func (m *FriendApplication) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendApplication.Unmarshal(m, b) @@ -3286,7 +2840,7 @@ func (m *FromToUserID) Reset() { *m = FromToUserID{} } func (m *FromToUserID) String() string { return proto.CompactTextString(m) } func (*FromToUserID) ProtoMessage() {} func (*FromToUserID) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{43} + return fileDescriptor_ws_a0747f665ef3b307, []int{38} } func (m *FromToUserID) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FromToUserID.Unmarshal(m, b) @@ -3332,7 +2886,7 @@ func (m *FriendApplicationTips) Reset() { *m = FriendApplicationTips{} } func (m *FriendApplicationTips) String() string { return proto.CompactTextString(m) } func (*FriendApplicationTips) ProtoMessage() {} func (*FriendApplicationTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{44} + return fileDescriptor_ws_a0747f665ef3b307, []int{39} } func (m *FriendApplicationTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendApplicationTips.Unmarshal(m, b) @@ -3372,7 +2926,7 @@ func (m *FriendApplicationApprovedTips) Reset() { *m = FriendApplication func (m *FriendApplicationApprovedTips) String() string { return proto.CompactTextString(m) } func (*FriendApplicationApprovedTips) ProtoMessage() {} func (*FriendApplicationApprovedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{45} + return fileDescriptor_ws_a0747f665ef3b307, []int{40} } func (m *FriendApplicationApprovedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendApplicationApprovedTips.Unmarshal(m, b) @@ -3419,7 +2973,7 @@ func (m *FriendApplicationRejectedTips) Reset() { *m = FriendApplication func (m *FriendApplicationRejectedTips) String() string { return proto.CompactTextString(m) } func (*FriendApplicationRejectedTips) ProtoMessage() {} func (*FriendApplicationRejectedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{46} + return fileDescriptor_ws_a0747f665ef3b307, []int{41} } func (m *FriendApplicationRejectedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendApplicationRejectedTips.Unmarshal(m, b) @@ -3467,7 +3021,7 @@ func (m *FriendAddedTips) Reset() { *m = FriendAddedTips{} } func (m *FriendAddedTips) String() string { return proto.CompactTextString(m) } func (*FriendAddedTips) ProtoMessage() {} func (*FriendAddedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{47} + return fileDescriptor_ws_a0747f665ef3b307, []int{42} } func (m *FriendAddedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendAddedTips.Unmarshal(m, b) @@ -3520,7 +3074,7 @@ func (m *FriendDeletedTips) Reset() { *m = FriendDeletedTips{} } func (m *FriendDeletedTips) String() string { return proto.CompactTextString(m) } func (*FriendDeletedTips) ProtoMessage() {} func (*FriendDeletedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{48} + return fileDescriptor_ws_a0747f665ef3b307, []int{43} } func (m *FriendDeletedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendDeletedTips.Unmarshal(m, b) @@ -3558,7 +3112,7 @@ func (m *BlackAddedTips) Reset() { *m = BlackAddedTips{} } func (m *BlackAddedTips) String() string { return proto.CompactTextString(m) } func (*BlackAddedTips) ProtoMessage() {} func (*BlackAddedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{49} + return fileDescriptor_ws_a0747f665ef3b307, []int{44} } func (m *BlackAddedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BlackAddedTips.Unmarshal(m, b) @@ -3596,7 +3150,7 @@ func (m *BlackDeletedTips) Reset() { *m = BlackDeletedTips{} } func (m *BlackDeletedTips) String() string { return proto.CompactTextString(m) } func (*BlackDeletedTips) ProtoMessage() {} func (*BlackDeletedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{50} + return fileDescriptor_ws_a0747f665ef3b307, []int{45} } func (m *BlackDeletedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BlackDeletedTips.Unmarshal(m, b) @@ -3634,7 +3188,7 @@ func (m *FriendInfoChangedTips) Reset() { *m = FriendInfoChangedTips{} } func (m *FriendInfoChangedTips) String() string { return proto.CompactTextString(m) } func (*FriendInfoChangedTips) ProtoMessage() {} func (*FriendInfoChangedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{51} + return fileDescriptor_ws_a0747f665ef3b307, []int{46} } func (m *FriendInfoChangedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_FriendInfoChangedTips.Unmarshal(m, b) @@ -3673,7 +3227,7 @@ func (m *UserInfoUpdatedTips) Reset() { *m = UserInfoUpdatedTips{} } func (m *UserInfoUpdatedTips) String() string { return proto.CompactTextString(m) } func (*UserInfoUpdatedTips) ProtoMessage() {} func (*UserInfoUpdatedTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{52} + return fileDescriptor_ws_a0747f665ef3b307, []int{47} } func (m *UserInfoUpdatedTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UserInfoUpdatedTips.Unmarshal(m, b) @@ -3714,7 +3268,7 @@ func (m *ConversationUpdateTips) Reset() { *m = ConversationUpdateTips{} func (m *ConversationUpdateTips) String() string { return proto.CompactTextString(m) } func (*ConversationUpdateTips) ProtoMessage() {} func (*ConversationUpdateTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{53} + return fileDescriptor_ws_a0747f665ef3b307, []int{48} } func (m *ConversationUpdateTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ConversationUpdateTips.Unmarshal(m, b) @@ -3768,7 +3322,7 @@ func (m *ConversationSetPrivateTips) Reset() { *m = ConversationSetPriva func (m *ConversationSetPrivateTips) String() string { return proto.CompactTextString(m) } func (*ConversationSetPrivateTips) ProtoMessage() {} func (*ConversationSetPrivateTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{54} + return fileDescriptor_ws_a0747f665ef3b307, []int{49} } func (m *ConversationSetPrivateTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ConversationSetPrivateTips.Unmarshal(m, b) @@ -3823,7 +3377,7 @@ func (m *DeleteMessageTips) Reset() { *m = DeleteMessageTips{} } func (m *DeleteMessageTips) String() string { return proto.CompactTextString(m) } func (*DeleteMessageTips) ProtoMessage() {} func (*DeleteMessageTips) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{55} + return fileDescriptor_ws_a0747f665ef3b307, []int{50} } func (m *DeleteMessageTips) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteMessageTips.Unmarshal(m, b) @@ -3877,7 +3431,7 @@ func (m *RequestPagination) Reset() { *m = RequestPagination{} } func (m *RequestPagination) String() string { return proto.CompactTextString(m) } func (*RequestPagination) ProtoMessage() {} func (*RequestPagination) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{56} + return fileDescriptor_ws_a0747f665ef3b307, []int{51} } func (m *RequestPagination) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RequestPagination.Unmarshal(m, b) @@ -3934,7 +3488,7 @@ func (m *SignalReq) Reset() { *m = SignalReq{} } func (m *SignalReq) String() string { return proto.CompactTextString(m) } func (*SignalReq) ProtoMessage() {} func (*SignalReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{57} + return fileDescriptor_ws_a0747f665ef3b307, []int{52} } func (m *SignalReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalReq.Unmarshal(m, b) @@ -4323,7 +3877,7 @@ func (m *SignalResp) Reset() { *m = SignalResp{} } func (m *SignalResp) String() string { return proto.CompactTextString(m) } func (*SignalResp) ProtoMessage() {} func (*SignalResp) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{58} + return fileDescriptor_ws_a0747f665ef3b307, []int{53} } func (m *SignalResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalResp.Unmarshal(m, b) @@ -4653,7 +4207,7 @@ func (m *InvitationInfo) Reset() { *m = InvitationInfo{} } func (m *InvitationInfo) String() string { return proto.CompactTextString(m) } func (*InvitationInfo) ProtoMessage() {} func (*InvitationInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{59} + return fileDescriptor_ws_a0747f665ef3b307, []int{54} } func (m *InvitationInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_InvitationInfo.Unmarshal(m, b) @@ -4763,7 +4317,7 @@ func (m *ParticipantMetaData) Reset() { *m = ParticipantMetaData{} } func (m *ParticipantMetaData) String() string { return proto.CompactTextString(m) } func (*ParticipantMetaData) ProtoMessage() {} func (*ParticipantMetaData) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{60} + return fileDescriptor_ws_a0747f665ef3b307, []int{55} } func (m *ParticipantMetaData) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ParticipantMetaData.Unmarshal(m, b) @@ -4818,7 +4372,7 @@ func (m *SignalInviteReq) Reset() { *m = SignalInviteReq{} } func (m *SignalInviteReq) String() string { return proto.CompactTextString(m) } func (*SignalInviteReq) ProtoMessage() {} func (*SignalInviteReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{61} + return fileDescriptor_ws_a0747f665ef3b307, []int{56} } func (m *SignalInviteReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalInviteReq.Unmarshal(m, b) @@ -4880,7 +4434,7 @@ func (m *SignalInviteReply) Reset() { *m = SignalInviteReply{} } func (m *SignalInviteReply) String() string { return proto.CompactTextString(m) } func (*SignalInviteReply) ProtoMessage() {} func (*SignalInviteReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{62} + return fileDescriptor_ws_a0747f665ef3b307, []int{57} } func (m *SignalInviteReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalInviteReply.Unmarshal(m, b) @@ -4942,7 +4496,7 @@ func (m *SignalInviteInGroupReq) Reset() { *m = SignalInviteInGroupReq{} func (m *SignalInviteInGroupReq) String() string { return proto.CompactTextString(m) } func (*SignalInviteInGroupReq) ProtoMessage() {} func (*SignalInviteInGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{63} + return fileDescriptor_ws_a0747f665ef3b307, []int{58} } func (m *SignalInviteInGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalInviteInGroupReq.Unmarshal(m, b) @@ -5004,7 +4558,7 @@ func (m *SignalInviteInGroupReply) Reset() { *m = SignalInviteInGroupRep func (m *SignalInviteInGroupReply) String() string { return proto.CompactTextString(m) } func (*SignalInviteInGroupReply) ProtoMessage() {} func (*SignalInviteInGroupReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{64} + return fileDescriptor_ws_a0747f665ef3b307, []int{59} } func (m *SignalInviteInGroupReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalInviteInGroupReply.Unmarshal(m, b) @@ -5066,7 +4620,7 @@ func (m *SignalCancelReq) Reset() { *m = SignalCancelReq{} } func (m *SignalCancelReq) String() string { return proto.CompactTextString(m) } func (*SignalCancelReq) ProtoMessage() {} func (*SignalCancelReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{65} + return fileDescriptor_ws_a0747f665ef3b307, []int{60} } func (m *SignalCancelReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalCancelReq.Unmarshal(m, b) @@ -5124,7 +4678,7 @@ func (m *SignalCancelReply) Reset() { *m = SignalCancelReply{} } func (m *SignalCancelReply) String() string { return proto.CompactTextString(m) } func (*SignalCancelReply) ProtoMessage() {} func (*SignalCancelReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{66} + return fileDescriptor_ws_a0747f665ef3b307, []int{61} } func (m *SignalCancelReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalCancelReply.Unmarshal(m, b) @@ -5159,7 +4713,7 @@ func (m *SignalAcceptReq) Reset() { *m = SignalAcceptReq{} } func (m *SignalAcceptReq) String() string { return proto.CompactTextString(m) } func (*SignalAcceptReq) ProtoMessage() {} func (*SignalAcceptReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{67} + return fileDescriptor_ws_a0747f665ef3b307, []int{62} } func (m *SignalAcceptReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalAcceptReq.Unmarshal(m, b) @@ -5227,7 +4781,7 @@ func (m *SignalAcceptReply) Reset() { *m = SignalAcceptReply{} } func (m *SignalAcceptReply) String() string { return proto.CompactTextString(m) } func (*SignalAcceptReply) ProtoMessage() {} func (*SignalAcceptReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{68} + return fileDescriptor_ws_a0747f665ef3b307, []int{63} } func (m *SignalAcceptReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalAcceptReply.Unmarshal(m, b) @@ -5281,7 +4835,7 @@ func (m *SignalHungUpReq) Reset() { *m = SignalHungUpReq{} } func (m *SignalHungUpReq) String() string { return proto.CompactTextString(m) } func (*SignalHungUpReq) ProtoMessage() {} func (*SignalHungUpReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{69} + return fileDescriptor_ws_a0747f665ef3b307, []int{64} } func (m *SignalHungUpReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalHungUpReq.Unmarshal(m, b) @@ -5332,7 +4886,7 @@ func (m *SignalHungUpReply) Reset() { *m = SignalHungUpReply{} } func (m *SignalHungUpReply) String() string { return proto.CompactTextString(m) } func (*SignalHungUpReply) ProtoMessage() {} func (*SignalHungUpReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{70} + return fileDescriptor_ws_a0747f665ef3b307, []int{65} } func (m *SignalHungUpReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalHungUpReply.Unmarshal(m, b) @@ -5367,7 +4921,7 @@ func (m *SignalRejectReq) Reset() { *m = SignalRejectReq{} } func (m *SignalRejectReq) String() string { return proto.CompactTextString(m) } func (*SignalRejectReq) ProtoMessage() {} func (*SignalRejectReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{71} + return fileDescriptor_ws_a0747f665ef3b307, []int{66} } func (m *SignalRejectReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalRejectReq.Unmarshal(m, b) @@ -5432,7 +4986,7 @@ func (m *SignalRejectReply) Reset() { *m = SignalRejectReply{} } func (m *SignalRejectReply) String() string { return proto.CompactTextString(m) } func (*SignalRejectReply) ProtoMessage() {} func (*SignalRejectReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{72} + return fileDescriptor_ws_a0747f665ef3b307, []int{67} } func (m *SignalRejectReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalRejectReply.Unmarshal(m, b) @@ -5465,7 +5019,7 @@ func (m *SignalGetRoomByGroupIDReq) Reset() { *m = SignalGetRoomByGroupI func (m *SignalGetRoomByGroupIDReq) String() string { return proto.CompactTextString(m) } func (*SignalGetRoomByGroupIDReq) ProtoMessage() {} func (*SignalGetRoomByGroupIDReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{73} + return fileDescriptor_ws_a0747f665ef3b307, []int{68} } func (m *SignalGetRoomByGroupIDReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalGetRoomByGroupIDReq.Unmarshal(m, b) @@ -5519,7 +5073,7 @@ func (m *SignalGetRoomByGroupIDReply) Reset() { *m = SignalGetRoomByGrou func (m *SignalGetRoomByGroupIDReply) String() string { return proto.CompactTextString(m) } func (*SignalGetRoomByGroupIDReply) ProtoMessage() {} func (*SignalGetRoomByGroupIDReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{74} + return fileDescriptor_ws_a0747f665ef3b307, []int{69} } func (m *SignalGetRoomByGroupIDReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalGetRoomByGroupIDReply.Unmarshal(m, b) @@ -5573,7 +5127,7 @@ func (m *SignalOnRoomParticipantConnectedReq) Reset() { *m = SignalOnRoo func (m *SignalOnRoomParticipantConnectedReq) String() string { return proto.CompactTextString(m) } func (*SignalOnRoomParticipantConnectedReq) ProtoMessage() {} func (*SignalOnRoomParticipantConnectedReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{75} + return fileDescriptor_ws_a0747f665ef3b307, []int{70} } func (m *SignalOnRoomParticipantConnectedReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalOnRoomParticipantConnectedReq.Unmarshal(m, b) @@ -5629,7 +5183,7 @@ func (m *SignalOnRoomParticipantDisconnectedReq) Reset() { func (m *SignalOnRoomParticipantDisconnectedReq) String() string { return proto.CompactTextString(m) } func (*SignalOnRoomParticipantDisconnectedReq) ProtoMessage() {} func (*SignalOnRoomParticipantDisconnectedReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{76} + return fileDescriptor_ws_a0747f665ef3b307, []int{71} } func (m *SignalOnRoomParticipantDisconnectedReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalOnRoomParticipantDisconnectedReq.Unmarshal(m, b) @@ -5684,7 +5238,7 @@ func (m *SignalGetTokenByRoomIDReq) Reset() { *m = SignalGetTokenByRoomI func (m *SignalGetTokenByRoomIDReq) String() string { return proto.CompactTextString(m) } func (*SignalGetTokenByRoomIDReq) ProtoMessage() {} func (*SignalGetTokenByRoomIDReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{77} + return fileDescriptor_ws_a0747f665ef3b307, []int{72} } func (m *SignalGetTokenByRoomIDReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalGetTokenByRoomIDReq.Unmarshal(m, b) @@ -5744,7 +5298,7 @@ func (m *SignalGetTokenByRoomIDReply) Reset() { *m = SignalGetTokenByRoo func (m *SignalGetTokenByRoomIDReply) String() string { return proto.CompactTextString(m) } func (*SignalGetTokenByRoomIDReply) ProtoMessage() {} func (*SignalGetTokenByRoomIDReply) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{78} + return fileDescriptor_ws_a0747f665ef3b307, []int{73} } func (m *SignalGetTokenByRoomIDReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalGetTokenByRoomIDReply.Unmarshal(m, b) @@ -5779,10 +5333,8 @@ func (m *SignalGetTokenByRoomIDReply) GetLiveURL() string { } type DelMsgListReq struct { - OpUserID string `protobuf:"bytes,1,opt,name=opUserID" json:"opUserID,omitempty"` UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` SeqList []uint32 `protobuf:"varint,3,rep,packed,name=seqList" json:"seqList,omitempty"` - OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -5792,7 +5344,7 @@ func (m *DelMsgListReq) Reset() { *m = DelMsgListReq{} } func (m *DelMsgListReq) String() string { return proto.CompactTextString(m) } func (*DelMsgListReq) ProtoMessage() {} func (*DelMsgListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{79} + return fileDescriptor_ws_a0747f665ef3b307, []int{74} } func (m *DelMsgListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DelMsgListReq.Unmarshal(m, b) @@ -5812,13 +5364,6 @@ func (m *DelMsgListReq) XXX_DiscardUnknown() { var xxx_messageInfo_DelMsgListReq proto.InternalMessageInfo -func (m *DelMsgListReq) GetOpUserID() string { - if m != nil { - return m.OpUserID - } - return "" -} - func (m *DelMsgListReq) GetUserID() string { if m != nil { return m.UserID @@ -5833,16 +5378,7 @@ func (m *DelMsgListReq) GetSeqList() []uint32 { return nil } -func (m *DelMsgListReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - type DelMsgListResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -5852,7 +5388,7 @@ func (m *DelMsgListResp) Reset() { *m = DelMsgListResp{} } func (m *DelMsgListResp) String() string { return proto.CompactTextString(m) } func (*DelMsgListResp) ProtoMessage() {} func (*DelMsgListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{80} + return fileDescriptor_ws_a0747f665ef3b307, []int{75} } func (m *DelMsgListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DelMsgListResp.Unmarshal(m, b) @@ -5872,20 +5408,6 @@ func (m *DelMsgListResp) XXX_DiscardUnknown() { var xxx_messageInfo_DelMsgListResp proto.InternalMessageInfo -func (m *DelMsgListResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *DelMsgListResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - type SetAppBackgroundStatusReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` IsBackground bool `protobuf:"varint,2,opt,name=isBackground" json:"isBackground,omitempty"` @@ -5898,7 +5420,7 @@ func (m *SetAppBackgroundStatusReq) Reset() { *m = SetAppBackgroundStatu func (m *SetAppBackgroundStatusReq) String() string { return proto.CompactTextString(m) } func (*SetAppBackgroundStatusReq) ProtoMessage() {} func (*SetAppBackgroundStatusReq) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{81} + return fileDescriptor_ws_a0747f665ef3b307, []int{76} } func (m *SetAppBackgroundStatusReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetAppBackgroundStatusReq.Unmarshal(m, b) @@ -5944,7 +5466,7 @@ func (m *SetAppBackgroundStatusResp) Reset() { *m = SetAppBackgroundStat func (m *SetAppBackgroundStatusResp) String() string { return proto.CompactTextString(m) } func (*SetAppBackgroundStatusResp) ProtoMessage() {} func (*SetAppBackgroundStatusResp) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{82} + return fileDescriptor_ws_a0747f665ef3b307, []int{77} } func (m *SetAppBackgroundStatusResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetAppBackgroundStatusResp.Unmarshal(m, b) @@ -5994,7 +5516,7 @@ func (m *ExtendMsgSet) Reset() { *m = ExtendMsgSet{} } func (m *ExtendMsgSet) String() string { return proto.CompactTextString(m) } func (*ExtendMsgSet) ProtoMessage() {} func (*ExtendMsgSet) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{83} + return fileDescriptor_ws_a0747f665ef3b307, []int{78} } func (m *ExtendMsgSet) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExtendMsgSet.Unmarshal(m, b) @@ -6071,7 +5593,7 @@ func (m *ExtendMsg) Reset() { *m = ExtendMsg{} } func (m *ExtendMsg) String() string { return proto.CompactTextString(m) } func (*ExtendMsg) ProtoMessage() {} func (*ExtendMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{84} + return fileDescriptor_ws_a0747f665ef3b307, []int{79} } func (m *ExtendMsg) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExtendMsg.Unmarshal(m, b) @@ -6139,7 +5661,7 @@ func (m *KeyValue) Reset() { *m = KeyValue{} } func (m *KeyValue) String() string { return proto.CompactTextString(m) } func (*KeyValue) ProtoMessage() {} func (*KeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{85} + return fileDescriptor_ws_a0747f665ef3b307, []int{80} } func (m *KeyValue) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KeyValue.Unmarshal(m, b) @@ -6192,7 +5714,7 @@ func (m *ResponsePagination) Reset() { *m = ResponsePagination{} } func (m *ResponsePagination) String() string { return proto.CompactTextString(m) } func (*ResponsePagination) ProtoMessage() {} func (*ResponsePagination) Descriptor() ([]byte, []int) { - return fileDescriptor_ws_e08a07288a333e78, []int{86} + return fileDescriptor_ws_a0747f665ef3b307, []int{81} } func (m *ResponsePagination) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ResponsePagination.Unmarshal(m, b) @@ -6236,11 +5758,6 @@ func init() { proto.RegisterType((*BlackInfo)(nil), "sdkws.BlackInfo") proto.RegisterType((*GroupRequest)(nil), "sdkws.GroupRequest") proto.RegisterType((*FriendRequest)(nil), "sdkws.FriendRequest") - proto.RegisterType((*Department)(nil), "sdkws.Department") - proto.RegisterType((*OrganizationUser)(nil), "sdkws.OrganizationUser") - proto.RegisterType((*DepartmentMember)(nil), "sdkws.DepartmentMember") - proto.RegisterType((*UserDepartmentMember)(nil), "sdkws.UserDepartmentMember") - proto.RegisterType((*UserInDepartment)(nil), "sdkws.UserInDepartment") proto.RegisterType((*PullMessageBySeqListReq)(nil), "sdkws.PullMessageBySeqListReq") proto.RegisterMapType((map[string]*SeqList)(nil), "sdkws.PullMessageBySeqListReq.GroupSeqListEntry") proto.RegisterType((*SeqList)(nil), "sdkws.seqList") @@ -6322,266 +5839,244 @@ func init() { proto.RegisterType((*ResponsePagination)(nil), "sdkws.ResponsePagination") } -func init() { proto.RegisterFile("sdkws/ws.proto", fileDescriptor_ws_e08a07288a333e78) } - -var fileDescriptor_ws_e08a07288a333e78 = []byte{ - // 4125 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x3c, 0x5b, 0x6f, 0x1c, 0x59, - 0x5a, 0x53, 0xd5, 0x17, 0x77, 0x7f, 0xed, 0x4b, 0xbb, 0x92, 0x78, 0x7a, 0xbc, 0x99, 0x60, 0x6a, - 0xa2, 0x10, 0x42, 0xc6, 0x81, 0xcc, 0xee, 0xc2, 0xce, 0xce, 0x06, 0xf9, 0x92, 0x38, 0xde, 0xa4, - 0x6d, 0x6f, 0x75, 0x32, 0x41, 0x3b, 0x23, 0x85, 0x72, 0xd7, 0x71, 0xbb, 0xc6, 0xd5, 0x55, 0xe5, - 0xba, 0x38, 0x31, 0x0f, 0x20, 0x01, 0x02, 0x24, 0x1e, 0x90, 0x10, 0x17, 0x09, 0xde, 0x78, 0x41, - 0x20, 0x34, 0x42, 0x08, 0x10, 0x12, 0x08, 0x21, 0xc4, 0x03, 0x12, 0x48, 0xcc, 0x3b, 0x12, 0x08, - 0x5e, 0x40, 0x88, 0x3f, 0x80, 0x84, 0x34, 0xe8, 0x9c, 0xef, 0x54, 0xd5, 0x39, 0x55, 0xd5, 0x97, - 0x58, 0xd6, 0x24, 0x51, 0x78, 0xf3, 0xf7, 0xd5, 0xf9, 0xbe, 0xf3, 0xdd, 0xcf, 0x77, 0x2e, 0x6d, - 0x58, 0x08, 0xad, 0xa3, 0xa7, 0xcf, 0xc2, 0x5b, 0xcf, 0xc2, 0x55, 0x3f, 0xf0, 0x22, 0x4f, 0x5b, - 0x0c, 0x49, 0x70, 0x42, 0x82, 0xa7, 0xa6, 0x6f, 0x3f, 0xf5, 0xcd, 0xc0, 0x1c, 0x86, 0xcb, 0xab, - 0xbb, 0x3e, 0x71, 0xdf, 0xdf, 0xee, 0xbe, 0xdf, 0x63, 0x9f, 0x6e, 0xf9, 0x47, 0x83, 0x5b, 0x6c, - 0xf0, 0xad, 0x84, 0x38, 0x30, 0x7d, 0x9f, 0x04, 0x9c, 0x85, 0xfe, 0xaf, 0x55, 0x68, 0x6e, 0x05, - 0x5e, 0xec, 0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3, 0x5d, 0x16, 0x58, 0x55, 0x16, 0x58, 0x29, 0x4c, 0xbf, 0xb9, 0x76, 0xff, 0xc8, 0xa5, 0xbe, - 0x46, 0x3f, 0xa4, 0xb0, 0xe8, 0xa2, 0xba, 0xec, 0xa2, 0x6b, 0x30, 0x6f, 0xfa, 0x7e, 0xd7, 0x74, - 0x07, 0x24, 0xc0, 0x49, 0x67, 0x30, 0x1d, 0x64, 0x2c, 0x2d, 0x08, 0x74, 0xa6, 0x9e, 0x17, 0x07, - 0x7d, 0xc2, 0xac, 0x5d, 0x33, 0x04, 0x0c, 0xe5, 0xe3, 0xf9, 0x24, 0x10, 0xf2, 0x18, 0x53, 0x3f, - 0x87, 0xe5, 0x21, 0x01, 0x69, 0x48, 0xd0, 0x42, 0x12, 0x47, 0xe4, 0xae, 0x6b, 0x31, 0xa5, 0x5a, - 0x4c, 0x29, 0x11, 0x45, 0x0b, 0x84, 0xed, 0x9e, 0xd8, 0x51, 0x5a, 0xae, 0x66, 0xb1, 0x40, 0x48, - 0x48, 0xfd, 0x97, 0x14, 0x98, 0xdf, 0x8b, 0xf7, 0x1d, 0xbb, 0xcf, 0x10, 0xd4, 0xf8, 0x99, 0x89, - 0x15, 0xc9, 0xc4, 0xa2, 0xa1, 0xd4, 0xd1, 0x86, 0xaa, 0xc8, 0x86, 0x5a, 0x82, 0xfa, 0x80, 0xb8, - 0x16, 0x09, 0x98, 0xe1, 0x6b, 0x06, 0x87, 0xb8, 0x42, 0xb5, 0x44, 0x21, 0xfd, 0x5f, 0x54, 0x68, - 0x7c, 0xc5, 0x22, 0xac, 0x40, 0xcb, 0x3f, 0xf4, 0x5c, 0xb2, 0x13, 0xd3, 0xe0, 0xe3, 0xb2, 0x88, - 0x28, 0xed, 0x22, 0xd4, 0xf6, 0xed, 0x20, 0x3a, 0x64, 0xde, 0x9f, 0x33, 0x10, 0xa0, 0x58, 0x32, - 0x34, 0x6d, 0x74, 0x79, 0xd3, 0x40, 0x80, 0x2b, 0xd4,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 0x1a, 0x09, 0x9a, 0x1d, 0x15, 0x9d, 0xfa, 0xe4, 0x41, 0xca, - 0x38, 0x01, 0xe5, 0x37, 0xe5, 0x4d, 0x4e, 0x4f, 0x43, 0xce, 0x31, 0x23, 0x12, 0x46, 0x42, 0xc8, - 0xa1, 0x11, 0x0a, 0x78, 0xfd, 0x63, 0xd0, 0x68, 0xe2, 0x79, 0x6e, 0x48, 0x84, 0x4b, 0x96, 0x15, - 0x68, 0x6d, 0xc4, 0x41, 0x40, 0xdc, 0x68, 0xcf, 0x1c, 0x24, 0xff, 0xad, 0x40, 0x44, 0xd1, 0x30, - 0xec, 0x65, 0xd7, 0x2c, 0x78, 0x82, 0x25, 0x60, 0xd6, 0x6f, 0x7e, 0xff, 0xc6, 0xae, 0x4f, 0xdc, - 0xa7, 0xdb, 0xdd, 0xc2, 0xff, 0x48, 0xfa, 0x76, 0xc1, 0x02, 0xfb, 0x75, 0xf6, 0xfd, 0x83, 0xff, - 0x0b, 0x00, 0x00, 0xff, 0xff, 0x32, 0x8b, 0x4b, 0xf5, 0x83, 0x49, 0x00, 0x00, +func init() { proto.RegisterFile("sdkws/ws.proto", fileDescriptor_ws_a0747f665ef3b307) } + +var fileDescriptor_ws_a0747f665ef3b307 = []byte{ + // 3765 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x5b, 0xcf, 0x6f, 0x1b, 0xd7, + 0xf1, 0xcf, 0x92, 0x22, 0x45, 0x0e, 0x25, 0x8a, 0x5a, 0xdb, 0x0a, 0xc3, 0xc4, 0x8e, 0xb0, 0xc9, + 0xd7, 0x5f, 0xc7, 0x8d, 0xe5, 0x44, 0x69, 0xd2, 0x20, 0x09, 0xda, 0x58, 0x92, 0x2d, 0x2b, 0x36, + 0x2d, 0x75, 0x69, 0x27, 0x48, 0x7b, 0x08, 0x56, 0xdc, 0x27, 0x6a, 0xa3, 0xe5, 0xee, 0x6a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x80, 0x2a, 0x7d, 0x61, 0x21, 0x58, 0xc4, + 0x10, 0x14, 0x7c, 0xd1, 0x3e, 0x2a, 0xc3, 0x42, 0x82, 0xb0, 0x6b, 0xae, 0xdf, 0x23, 0xe1, 0x43, + 0x8c, 0x33, 0x86, 0x81, 0x6a, 0x82, 0x81, 0xcd, 0x82, 0x3c, 0x51, 0x6c, 0x35, 0x56, 0x9f, 0x5c, + 0x19, 0xb8, 0xee, 0xc0, 0x26, 0x6c, 0x20, 0xed, 0x46, 0x7b, 0x2b, 0x5b, 0x4e, 0xf8, 0xd2, 0xea, + 0xdb, 0x86, 0x1d, 0x91, 0x82, 0x24, 0xae, 0xe7, 0x92, 0x58, 0x3b, 0xde, 0x4c, 0x36, 0xc3, 0x5b, + 0x45, 0x19, 0xae, 0x1f, 0x6f, 0x27, 0xaf, 0xa5, 0xfd, 0xbb, 0x04, 0xa7, 0x30, 0x2d, 0x9c, 0x1b, + 0xd9, 0xf6, 0x31, 0x25, 0x60, 0x09, 0xaa, 0x11, 0x4b, 0x36, 0xcb, 0x0b, 0xa7, 0x68, 0xca, 0x7c, + 0xd7, 0x26, 0x37, 0xc9, 0x11, 0xb1, 0x31, 0x23, 0x15, 0x3d, 0x65, 0xa8, 0x1d, 0xa8, 0xbd, 0xef, + 0x5a, 0x0e, 0x02, 0x6b, 0x06, 0x81, 0x95, 0xd0, 0xf4, 0x9b, 0x63, 0xf5, 0x0f, 0x1c, 0x9a, 0x6b, + 0x96, 0x87, 0x84, 0x16, 0x53, 0x54, 0x95, 0x53, 0x74, 0x1e, 0x9a, 0x86, 0xe7, 0x75, 0x0d, 0x67, + 0x40, 0x7c, 0xd6, 0xe8, 0x2c, 0x1b, 0x0e, 0x32, 0x97, 0x16, 0x04, 0xda, 0x52, 0xcf, 0x8d, 0xfc, + 0x3e, 0xc1, 0x68, 0x57, 0x74, 0x81, 0x43, 0xed, 0xb8, 0x1e, 0xf1, 0x85, 0x71, 0xcc, 0x86, 0x7e, + 0x86, 0xcb, 0x21, 0x01, 0x09, 0x24, 0x68, 0x21, 0x89, 0x42, 0x72, 0xd5, 0x31, 0xd1, 0xa9, 0x06, + 0x3a, 0x25, 0xb2, 0x68, 0x81, 0xb0, 0x9c, 0x23, 0x2b, 0x4c, 0xca, 0xd5, 0x1c, 0x2b, 0x10, 0x12, + 0x53, 0xfb, 0x9e, 0x02, 0xcd, 0x9d, 0x68, 0xd7, 0xb6, 0xfa, 0xc8, 0xa0, 0xc1, 0x4f, 0x43, 0xac, + 0x48, 0x21, 0x16, 0x03, 0x55, 0x1a, 0x1f, 0xa8, 0xb2, 0x1c, 0xa8, 0x25, 0xa8, 0x0e, 0x88, 0x63, + 0x12, 0x1f, 0x03, 0x5f, 0xd1, 0x39, 0xc5, 0x1d, 0xaa, 0xc4, 0x0e, 0x69, 0x7f, 0x2e, 0x41, 0xed, + 0x01, 0x77, 0x61, 0x19, 0x1a, 0xde, 0xbe, 0xeb, 0x90, 0x5b, 0x11, 0x05, 0x1f, 0xef, 0x8b, 0xc8, + 0x52, 0x4f, 0x43, 0x65, 0xd7, 0xf2, 0xc3, 0x7d, 0xcc, 0xfe, 0xbc, 0xce, 0x08, 0xca, 0x25, 0x43, + 0xc3, 0x62, 0x29, 0xaf, 0xeb, 0x8c, 0xe0, 0x0e, 0xd5, 0x92, 0x0c, 0xc9, 0x53, 0x41, 0x3d, 0x37, + 0x15, 0xe4, 0x11, 0x04, 0x85, 0x08, 0xba, 0x08, 0xad, 0x81, 0xed, 0xee, 0x1a, 0xb6, 0x4e, 0xfa, + 0x47, 0xdd, 0x60, 0xb0, 0xed, 0x85, 0x98, 0xee, 0x8a, 0x9e, 0xe3, 0xd3, 0xf8, 0x60, 0x17, 0x4d, + 0x63, 0x84, 0x85, 0xbc, 0xac, 0x27, 0xb4, 0xf6, 0x0f, 0x05, 0x80, 0x0d, 0x3b, 0x0c, 0x71, 0x66, + 0x2e, 0x53, 0xf2, 0x73, 0xd9, 0x12, 0x54, 0x7d, 0x32, 0x34, 0xfc, 0x83, 0x78, 0xa8, 0x31, 0x2a, + 0xe3, 0x58, 0x39, 0xe7, 0xd8, 0x65, 0x80, 0x3d, 0x6c, 0x87, 0xda, 0xc1, 0x90, 0x37, 0x56, 0x17, + 0x56, 0x70, 0xe2, 0x5f, 0x89, 0x33, 0xac, 0x0b, 0x22, 0x74, 0xec, 0x1a, 0xa6, 0xc9, 0x87, 0x48, + 0x85, 0x8d, 0xdd, 0x84, 0x51, 0x30, 0x42, 0xaa, 0x13, 0x46, 0xc8, 0x6c, 0x02, 0xa8, 0xbf, 0x28, + 0x50, 0x5f, 0xb3, 0x8d, 0xfe, 0xc1, 0x94, 0xee, 0xca, 0x6e, 0x95, 0x72, 0x6e, 0xbd, 0x0e, 0xf3, + 0xbb, 0xd4, 0x5c, 0xec, 0x02, 0x7a, 0xde, 0x58, 0x3d, 0xc3, 0x3d, 0x93, 0x07, 0x91, 0x2e, 0xcb, + 0xca, 0x2e, 0xce, 0x1c, 0xef, 0x62, 0x65, 0x82, 0x8b, 0xc9, 0xbc, 0x40, 0xcb, 0xe7, 0x1c, 0x96, + 0x4f, 0x9d, 0x1c, 0x46, 0x24, 0x08, 0xd5, 0x17, 0xa1, 0x16, 0xc5, 0xdd, 0x53, 0x26, 0x75, 0x2f, + 0x11, 0x53, 0x57, 0xf8, 0x5c, 0x87, 0x3a, 0x25, 0xd4, 0x69, 0x71, 0x9d, 0x64, 0xc2, 0xd4, 0x53, + 0x11, 0x3a, 0xb3, 0xed, 0x1b, 0x8e, 0x69, 0x13, 0x9d, 0x04, 0x91, 0x1d, 0xf2, 0x5a, 0x2b, 0xf1, + 0x18, 0x72, 0x0e, 0xbb, 0xc1, 0x80, 0xcf, 0x7b, 0x9c, 0xa2, 0x51, 0x60, 0x72, 0xf4, 0x13, 0x73, + 0x31, 0x65, 0xd0, 0x01, 0xec, 0x93, 0x43, 0x8c, 0x7e, 0x15, 0xa3, 0x1f, 0x93, 0x69, 0x9b, 0x3c, + 0x3a, 0x2c, 0xc9, 0x12, 0x8f, 0xa6, 0x8f, 0xd1, 0x68, 0xa0, 0xc6, 0xd2, 0x97, 0x72, 0x72, 0xeb, + 0x2a, 0xb9, 0x30, 0x43, 0xae, 0x30, 0xe7, 0xca, 0x67, 0xa3, 0xa8, 0x7c, 0x7e, 0x52, 0x86, 0x79, + 0x36, 0xa8, 0xe2, 0x14, 0x9c, 0xa3, 0xe8, 0x77, 0x87, 0x12, 0xce, 0x04, 0x0e, 0xf5, 0x85, 0x52, + 0xb7, 0xe4, 0x32, 0x26, 0xf1, 0x28, 0x58, 0x29, 0x7d, 0x4d, 0x2a, 0x67, 0x22, 0x2b, 0x6e, 0x65, + 0x53, 0x2c, 0x6b, 0x02, 0x87, 0x16, 0x82, 0xd0, 0x95, 0xb0, 0x94, 0xd0, 0x54, 0x37, 0x74, 0x93, + 0xf6, 0x19, 0x9a, 0x04, 0x0e, 0xcd, 0x52, 0xe8, 0xc6, 0x6d, 0xb3, 0x50, 0xa7, 0x0c, 0x66, 0x99, + 0xb7, 0xcb, 0xa6, 0xb3, 0x84, 0xce, 0x61, 0xa3, 0x3e, 0x11, 0x1b, 0x20, 0x61, 0x43, 0x1e, 0x7e, + 0x8d, 0xdc, 0xf0, 0x7b, 0x16, 0xe6, 0x99, 0x9d, 0xcc, 0x74, 0x26, 0x31, 0x65, 0x84, 0xcd, 0x67, + 0x11, 0x26, 0x63, 0xa4, 0x39, 0x06, 0x23, 0x0b, 0xc9, 0xf8, 0xfa, 0xa7, 0x02, 0x8f, 0xef, 0x44, + 0xb6, 0xdd, 0x25, 0x41, 0x60, 0x0c, 0xc8, 0xda, 0xa8, 0x47, 0x0e, 0x6f, 0x5a, 0x41, 0xa8, 0x93, + 0xc3, 0xb1, 0x53, 0x54, 0x1b, 0x66, 0x03, 0x26, 0xd5, 0x2e, 0x2f, 0x97, 0x2f, 0xcc, 0xeb, 0x31, + 0xa9, 0xde, 0x86, 0x39, 0x1c, 0x46, 0xdc, 0x48, 0x7b, 0x66, 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0xce, 0xec, 0x20, 0x0b, + 0x52, 0xa0, 0x8b, 0xe2, 0xda, 0x0f, 0x15, 0x58, 0xcc, 0x95, 0x45, 0xbc, 0x39, 0xa3, 0x03, 0x2c, + 0xb9, 0x39, 0xa3, 0x84, 0x80, 0xdc, 0x52, 0x16, 0xb9, 0xb6, 0x75, 0x24, 0x3e, 0xc0, 0xe4, 0xe4, + 0x18, 0xd4, 0xcc, 0x8c, 0x45, 0xcd, 0xdf, 0x15, 0x58, 0x2a, 0x5e, 0x57, 0x3c, 0x8a, 0xb1, 0xff, + 0x50, 0x81, 0xf6, 0xb8, 0x79, 0xe5, 0x0b, 0x4b, 0x41, 0x8a, 0xfb, 0x64, 0x69, 0xf6, 0x28, 0xc6, + 0xfe, 0x54, 0x0c, 0x7b, 0x61, 0x42, 0xd6, 0x7e, 0x54, 0x8a, 0x7d, 0x4f, 0x16, 0x99, 0x8f, 0xa0, + 0xef, 0xea, 0x45, 0x68, 0x31, 0x17, 0x84, 0x27, 0x1b, 0xec, 0x3a, 0x28, 0xc7, 0xd7, 0xbe, 0x19, + 0xc7, 0x49, 0x58, 0x84, 0x7c, 0x5e, 0xd8, 0xd4, 0x7e, 0x91, 0x60, 0x2d, 0x59, 0xa2, 0x3f, 0x94, + 0xf1, 0x4e, 0xd1, 0x22, 0x2c, 0xab, 0x04, 0xb4, 0x24, 0xdb, 0x85, 0xff, 0x75, 0xb4, 0x24, 0x71, + 0x12, 0x96, 0x92, 0xda, 0x07, 0x0a, 0x3c, 0x31, 0x76, 0x6b, 0x34, 0x31, 0x62, 0xc2, 0x22, 0xaa, + 0x24, 0x2f, 0xa2, 0x32, 0x2e, 0x95, 0x4f, 0x36, 0xf8, 0x7f, 0xa9, 0xc0, 0x93, 0x13, 0x16, 0xad, + 0x99, 0x4c, 0x29, 0xd3, 0x66, 0x2a, 0xd3, 0xa9, 0x92, 0x74, 0x1b, 0x76, 0x6c, 0x9c, 0xd3, 0xe1, + 0x53, 0x16, 0x87, 0x8f, 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0xc7, 0x18, 0xc4, 0xbf, 0xdd, 0x12, 0x59, 0x14, 0x62, 0xbd, 0xf4, 0x74, 0x9a, 0x9d, 0x68, 0x08, + 0x9c, 0xb5, 0xa7, 0xbf, 0x71, 0x76, 0xdb, 0x23, 0xce, 0x7b, 0x5b, 0xdd, 0xec, 0x8f, 0xc4, 0x5f, + 0xc7, 0xbf, 0xbb, 0x55, 0x64, 0xbd, 0xf4, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x54, 0x95, + 0x23, 0x6a, 0x3e, 0x00, 0x00, } diff --git a/pkg/proto/sdkws/ws.proto b/pkg/proto/sdkws/ws.proto index baa0eb2ee..cc369a3c0 100644 --- a/pkg/proto/sdkws/ws.proto +++ b/pkg/proto/sdkws/ws.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import "Open-IM-Server/pkg/proto/sdk_ws/wrappers.proto"; -option go_package = "Open_IM/pkg/proto/sdk_ws;sdkws"; +import "Open-IM-Server/pkg/proto/sdkws/wrappers.proto"; +option go_package = "Open_IM/pkg/proto/sdkws;sdkws"; package sdkws; From ec7f44358c68d90872469a2ac6e712f8490fcc1f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 09:14:50 +0800 Subject: [PATCH 05/48] Error code standardization --- internal/common/notification/extend_msg.go | 100 ++++ internal/common/notification/friend.go | 174 ++++++ internal/common/notification/group.go | 622 ++++++++++++++++++++ internal/common/notification/msg.go | 48 ++ internal/common/notification/super_group.go | 24 + internal/rpc/msg/extend_msg_callback.go | 104 ++++ 6 files changed, 1072 insertions(+) create mode 100644 internal/common/notification/extend_msg.go create mode 100644 internal/common/notification/friend.go create mode 100644 internal/common/notification/group.go create mode 100644 internal/common/notification/msg.go create mode 100644 internal/common/notification/super_group.go create mode 100644 internal/rpc/msg/extend_msg_callback.go diff --git a/internal/common/notification/extend_msg.go b/internal/common/notification/extend_msg.go new file mode 100644 index 000000000..5a3b78a07 --- /dev/null +++ b/internal/common/notification/extend_msg.go @@ -0,0 +1,100 @@ +package notification + +import ( + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/log" + "Open_IM/pkg/proto/msg" + sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" + "context" +) + +func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32, + req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) { + var m apistruct.ReactionMessageModifierNotification + m.SourceID = req.SourceID + m.OpUserID = req.OpUserID + m.SessionType = req.SessionType + keyMap := make(map[string]*sdkws.KeyValue) + for _, valueResp := range resp.Result { + if valueResp.ErrCode == 0 { + keyMap[valueResp.KeyValue.TypeKey] = valueResp.KeyValue + } + } + if len(keyMap) == 0 { + log.NewWarn(operationID, "all key set failed can not send notification", *req) + return + } + m.SuccessReactionExtensionList = keyMap + m.ClientMsgID = req.ClientMsgID + m.IsReact = resp.IsReact + m.IsExternalExtensions = req.IsExternalExtensions + m.MsgFirstModifyTime = resp.MsgFirstModifyTime + messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache) +} +func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, sessionType int32, + req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) { + var m apistruct.ReactionMessageDeleteNotification + m.SourceID = req.SourceID + m.OpUserID = req.OpUserID + m.SessionType = req.SessionType + keyMap := make(map[string]*sdkws.KeyValue) + for _, valueResp := range resp.Result { + if valueResp.ErrCode == 0 { + keyMap[valueResp.KeyValue.TypeKey] = valueResp.KeyValue + } + } + if len(keyMap) == 0 { + log.NewWarn(operationID, "all key set failed can not send notification", *req) + return + } + m.SuccessReactionExtensionList = keyMap + m.ClientMsgID = req.ClientMsgID + m.MsgFirstModifyTime = req.MsgFirstModifyTime + + messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache) +} +func messageReactionSender(operationID, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) { + options := make(map[string]bool, 5) + utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false) + utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false) + utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false) + utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false) + utils.SetSwitchFromOptions(options, constant.IsReactionFromCache, isReactionFromCache) + if !isHistory { + utils.SetSwitchFromOptions(options, constant.IsHistory, false) + utils.SetSwitchFromOptions(options, constant.IsPersistent, false) + } + pbData := msg.SendMsgReq{ + OperationID: operationID, + MsgData: &sdkws.MsgData{ + SendID: sendID, + ClientMsgID: utils.GetMsgID(sendID), + SessionType: sessionType, + MsgFrom: constant.SysMsgType, + ContentType: contentType, + Content: []byte(content), + // ForceList: params.ForceList, + CreateTime: utils.GetCurrentTimestampByMill(), + Options: options, + }, + } + switch sessionType { + case constant.SingleChatType, constant.NotificationChatType: + pbData.MsgData.RecvID = sourceID + case constant.GroupChatType, constant.SuperGroupChatType: + pbData.MsgData.GroupID = sourceID + } + etcdConn, err := rpc.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName) + if err != nil { + return + } + client := msg.NewMsgClient(etcdConn) + reply, err := client.SendMsg(context.Background(), &pbData) + if err != nil { + log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), err.Error()) + } else if reply.ErrCode != 0 { + log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), reply.ErrCode, reply.ErrMsg) + } +} diff --git a/internal/common/notification/friend.go b/internal/common/notification/friend.go new file mode 100644 index 000000000..2ade47709 --- /dev/null +++ b/internal/common/notification/friend.go @@ -0,0 +1,174 @@ +package notification + +import ( + "Open_IM/internal/common/check" + "Open_IM/internal/rpc/msg" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" + pbFriend "Open_IM/pkg/proto/friend" + sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" + "context" + "github.com/golang/protobuf/jsonpb" + "github.com/golang/protobuf/proto" +) + +func getFromToUserNickname(fromUserID, toUserID string) (string, string, error) { + users, err := check.GetUsersInfo(context.Background(), fromUserID, toUserID) + if err != nil { + return "", "", nil + } + if users[0].UserID == fromUserID { + return users[0].Nickname, users[1].Nickname, nil + } + return users[1].Nickname, users[0].Nickname, nil + +} + +func friendNotification(operationID, fromUserID, toUserID string, contentType int32, m proto.Message) { + log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType) + var err error + var tips sdkws.TipsComm + tips.Detail, err = proto.Marshal(m) + if err != nil { + log.Error(operationID, "Marshal failed ", err.Error(), m.String()) + return + } + + marshaler := jsonpb.Marshaler{ + OrigName: true, + EnumsAsInts: false, + EmitDefaults: false, + } + + tips.JsonDetail, _ = marshaler.MarshalToString(m) + + fromUserNickname, toUserNickname, err := getFromToUserNickname(fromUserID, toUserID) + if err != nil { + log.Error(operationID, "getFromToUserNickname failed ", err.Error(), fromUserID, toUserID) + return + } + cn := config.Config.Notification + switch contentType { + case constant.FriendApplicationNotification: + tips.DefaultTips = fromUserNickname + cn.FriendApplication.DefaultTips.Tips + case constant.FriendApplicationApprovedNotification: + tips.DefaultTips = fromUserNickname + cn.FriendApplicationApproved.DefaultTips.Tips + case constant.FriendApplicationRejectedNotification: + tips.DefaultTips = fromUserNickname + cn.FriendApplicationRejected.DefaultTips.Tips + case constant.FriendAddedNotification: + tips.DefaultTips = cn.FriendAdded.DefaultTips.Tips + case constant.FriendDeletedNotification: + tips.DefaultTips = cn.FriendDeleted.DefaultTips.Tips + toUserNickname + case constant.FriendRemarkSetNotification: + tips.DefaultTips = fromUserNickname + cn.FriendRemarkSet.DefaultTips.Tips + case constant.BlackAddedNotification: + tips.DefaultTips = cn.BlackAdded.DefaultTips.Tips + case constant.BlackDeletedNotification: + tips.DefaultTips = cn.BlackDeleted.DefaultTips.Tips + toUserNickname + case constant.UserInfoUpdatedNotification: + tips.DefaultTips = cn.UserInfoUpdated.DefaultTips.Tips + case constant.FriendInfoUpdatedNotification: + tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname + default: + log.Error(operationID, "contentType failed ", contentType) + return + } + + var n msg.NotificationMsg + n.SendID = fromUserID + n.RecvID = toUserID + n.ContentType = contentType + n.SessionType = constant.SingleChatType + n.MsgFrom = constant.SysMsgType + n.OperationID = operationID + n.Content, err = proto.Marshal(&tips) + if err != nil { + log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) + return + } + msg.Notification(&n) +} + +func FriendApplicationAddNotification(ctx context.Context, req *pbFriend.AddFriendReq) { + FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}} + FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID + FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID + friendNotification(tracelog.GetOperationID(ctx), req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips) +} + +func FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { + FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}} + FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID + FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID + FriendApplicationApprovedTips.HandleMsg = req.HandleMsg + friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips) +} + +func FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { + FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}} + FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID + FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID + FriendApplicationApprovedTips.HandleMsg = req.HandleMsg + friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips) +} + +func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) { + friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}} + user, err := check.GetUsersInfo(context.Background(), opUserID) + if err != nil { + return + } + friendAddedTips.OpUser.UserID = user[0].UserID + friendAddedTips.OpUser.Ex = user[0].Ex + friendAddedTips.OpUser.Nickname = user[0].Nickname + friendAddedTips.OpUser.FaceURL = user[0].FaceURL + + friend, err := check.GetFriendsInfo(ctx, fromUserID, toUserID) + if err != nil { + return + } + friendAddedTips.Friend = friend + friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips) +} + +func FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) { + friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}} + friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID + friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID + friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips) +} + +func FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) { + friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}} + friendInfoChangedTips.FromToUserID.FromUserID = fromUserID + friendInfoChangedTips.FromToUserID.ToUserID = toUserID + friendNotification(tracelog.GetOperationID(ctx), fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips) +} + +func BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) { + blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}} + blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID + blackAddedTips.FromToUserID.ToUserID = req.BlackUserID + friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips) +} + +func BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) { + blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}} + blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID + blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID + friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips) +} + +// send to myself +func UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) { + selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} + friendNotification(tracelog.GetOperationID(ctx), opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) +} + +func FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { + selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} + friendNotification(tracelog.GetOperationID(ctx), opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips) +} diff --git a/internal/common/notification/group.go b/internal/common/notification/group.go new file mode 100644 index 000000000..c3982ed6d --- /dev/null +++ b/internal/common/notification/group.go @@ -0,0 +1,622 @@ +package notification + +import ( + "Open_IM/internal/rpc/msg" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" + "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tokenverify" + utils2 "Open_IM/pkg/common/utils" + pbGroup "Open_IM/pkg/proto/group" + "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" + "context" + "github.com/golang/protobuf/jsonpb" + "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/types/known/wrapperspb" +) + +//message GroupCreatedTips{ +// GroupInfo Group = 1; +// GroupMemberFullInfo Creator = 2; +// repeated GroupMemberFullInfo MemberList = 3; +// uint64 OperationTime = 4; +//} creator->group + +func setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + if tokenverify.IsManagerUserID(opUserID) { + u, err := imdb.GetUserByUserID(opUserID) + if err != nil { + return utils.Wrap(err, "GetUserByUserID failed") + } + utils.CopyStructFields(groupMemberInfo, u) + groupMemberInfo.GroupID = groupID + } else { + u, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, opUserID) + if err == nil { + if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, u); err != nil { + return utils.Wrap(err, "") + } + } + user, err := imdb.GetUserByUserID(opUserID) + if err != nil { + return utils.Wrap(err, "") + } + groupMemberInfo.GroupID = groupID + groupMemberInfo.UserID = user.UserID + groupMemberInfo.Nickname = user.Nickname + groupMemberInfo.AppMangerLevel = user.AppMangerLevel + groupMemberInfo.FaceURL = user.FaceURL + } + return nil +} + +func setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error { + group, err := imdb.GetGroupInfoByGroupID(groupID) + if err != nil { + return utils.Wrap(err, "GetGroupInfoByGroupID failed") + } + err = utils2.GroupDBCopyOpenIM(groupInfo, group) + if err != nil { + log.NewWarn("", "GroupDBCopyOpenIM failed ", groupID, err.Error()) + return nil + } + return nil +} + +func setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + groupMember, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID) + if err == nil { + return utils.Wrap(utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember), "") + } + + user, err := imdb.GetUserByUserID(userID) + if err != nil { + return utils.Wrap(err, "") + } + groupMemberInfo.GroupID = groupID + groupMemberInfo.UserID = user.UserID + groupMemberInfo.Nickname = user.Nickname + groupMemberInfo.AppMangerLevel = user.AppMangerLevel + groupMemberInfo.FaceURL = user.FaceURL + return nil +} + +func setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + groupMember, err := imdb.GetGroupOwnerInfoByGroupID(groupID) + if err != nil { + return utils.Wrap(err, "") + } + if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember); err != nil { + return utils.Wrap(err, "") + } + return nil +} + +func setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error { + user, err := imdb.GetUserByUserID(userID) + if err != nil { + return utils.Wrap(err, "") + } + utils2.UserDBCopyOpenIMPublicUser(publicUserInfo, user) + return nil +} + +func groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) { + log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID) + + var err error + var tips sdkws.TipsComm + tips.Detail, err = proto.Marshal(m) + if err != nil { + log.Error(operationID, "Marshal failed ", err.Error(), m.String()) + return + } + marshaler := jsonpb.Marshaler{ + OrigName: true, + EnumsAsInts: false, + EmitDefaults: false, + } + + tips.JsonDetail, _ = marshaler.MarshalToString(m) + var nickname string + + from, err := imdb.GetUserByUserID(sendID) + if err != nil { + log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID) + } + if from != nil { + nickname = from.Nickname + } + + to, err := imdb.GetUserByUserID(recvUserID) + if err != nil { + log.NewWarn(operationID, "GetUserByUserID failed ", err.Error(), recvUserID) + } + toNickname := "" + if to != nil { + toNickname = to.Nickname + } + + cn := config.Config.Notification + switch contentType { + case constant.GroupCreatedNotification: + tips.DefaultTips = nickname + " " + cn.GroupCreated.DefaultTips.Tips + case constant.GroupInfoSetNotification: + tips.DefaultTips = nickname + " " + cn.GroupInfoSet.DefaultTips.Tips + case constant.JoinGroupApplicationNotification: + tips.DefaultTips = nickname + " " + cn.JoinGroupApplication.DefaultTips.Tips + case constant.MemberQuitNotification: + tips.DefaultTips = nickname + " " + cn.MemberQuit.DefaultTips.Tips + case constant.GroupApplicationAcceptedNotification: // + tips.DefaultTips = toNickname + " " + cn.GroupApplicationAccepted.DefaultTips.Tips + case constant.GroupApplicationRejectedNotification: // + tips.DefaultTips = toNickname + " " + cn.GroupApplicationRejected.DefaultTips.Tips + case constant.GroupOwnerTransferredNotification: // + tips.DefaultTips = toNickname + " " + cn.GroupOwnerTransferred.DefaultTips.Tips + case constant.MemberKickedNotification: // + tips.DefaultTips = toNickname + " " + cn.MemberKicked.DefaultTips.Tips + case constant.MemberInvitedNotification: // + tips.DefaultTips = toNickname + " " + cn.MemberInvited.DefaultTips.Tips + case constant.MemberEnterNotification: + tips.DefaultTips = toNickname + " " + cn.MemberEnter.DefaultTips.Tips + case constant.GroupDismissedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupDismissed.DefaultTips.Tips + case constant.GroupMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMuted.DefaultTips.Tips + case constant.GroupCancelMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupCancelMuted.DefaultTips.Tips + case constant.GroupMemberMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberMuted.DefaultTips.Tips + case constant.GroupMemberCancelMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberCancelMuted.DefaultTips.Tips + case constant.GroupMemberInfoSetNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberInfoSet.DefaultTips.Tips + case constant.GroupMemberSetToAdminNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToAdmin.DefaultTips.Tips + case constant.GroupMemberSetToOrdinaryUserNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips + default: + log.Error(operationID, "contentType failed ", contentType) + return + } + + var n msg.NotificationMsg + n.SendID = sendID + if groupID != "" { + n.RecvID = groupID + group, err := imdb.GetGroupInfoByGroupID(groupID) + if err != nil { + log.NewError(operationID, "GetGroupInfoByGroupID failed ", err.Error(), groupID) + } + switch group.GroupType { + case constant.NormalGroup: + n.SessionType = constant.GroupChatType + default: + n.SessionType = constant.SuperGroupChatType + } + } else { + n.RecvID = recvUserID + n.SessionType = constant.SingleChatType + } + n.ContentType = contentType + n.OperationID = operationID + n.Content, err = proto.Marshal(&tips) + if err != nil { + log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) + return + } + msg.Notification(&n) +} + +// 创建群后调用 +func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) { + GroupCreatedTips := sdkws.GroupCreatedTips{Group: &sdkws.GroupInfo{}, + OpUser: &sdkws.GroupMemberFullInfo{}, GroupOwnerUser: &sdkws.GroupMemberFullInfo{}} + if err := setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil { + log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser) + return + } + err := setGroupInfo(groupID, GroupCreatedTips.Group) + if err != nil { + log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group) + return + } + imdb.GetGroupOwnerInfoByGroupID(groupID) + if err := setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil { + log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID) + return + } + for _, v := range initMemberList { + var groupMemberInfo sdkws.GroupMemberFullInfo + if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v) + continue + } + GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo) + if len(GroupCreatedTips.MemberList) == constant.MaxNotificationNum { + break + } + } + groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID) +} + +// 群信息改变后掉用 +// groupName := "" +// +// notification := "" +// introduction := "" +// faceURL := "" +func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) { + GroupInfoChangedTips := sdkws.GroupInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + GroupInfoChangedTips.Group.GroupName = groupName + GroupInfoChangedTips.Group.Notification = notification + GroupInfoChangedTips.Group.Introduction = introduction + GroupInfoChangedTips.Group.FaceURL = faceURL + if needVerification != nil { + GroupInfoChangedTips.Group.NeedVerification = needVerification.Value + } + + if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID) +} + +func GroupMutedNotification(operationID, opUserID, groupID string) { + tips := sdkws.GroupMutedTips{Group: &sdkws.GroupInfo{}, + OpUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, tips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID) +} + +func GroupCancelMutedNotification(operationID, opUserID, groupID string) { + tips := sdkws.GroupCancelMutedTips{Group: &sdkws.GroupInfo{}, + OpUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, tips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID) +} + +func GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) { + tips := sdkws.GroupMemberMutedTips{Group: &sdkws.GroupInfo{}, + OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} + tips.MutedSeconds = mutedSeconds + if err := setGroupInfo(groupID, tips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + return + } + groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID) +} + +func GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberUserID string) { + tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, + OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, tips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + return + } + groupNotification(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID) +} + +func GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) { + if notificationType != constant.GroupMemberSetToAdminNotification && notificationType != constant.GroupMemberSetToOrdinaryUserNotification { + log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType) + return + } + tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, + OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, tips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + return + } + groupNotification(notificationType, &tips, opUserID, groupID, "", operationID) +} + +func GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) { + tips := sdkws.GroupMemberCancelMutedTips{Group: &sdkws.GroupInfo{}, + OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, tips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + return + } + groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID) +} + +// message ReceiveJoinApplicationTips{ +// GroupInfo Group = 1; +// PublicUserInfo Applicant = 2; +// string Reason = 3; +// } apply->all managers GroupID string `protobuf:"bytes,1,opt,name=GroupID" json:"GroupID,omitempty"` +// +// ReqMessage string `protobuf:"bytes,2,opt,name=ReqMessage" json:"ReqMessage,omitempty"` +// OpUserID string `protobuf:"bytes,3,opt,name=OpUserID" json:"OpUserID,omitempty"` +// OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"` +// +// 申请进群后调用 +func JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) { + JoinGroupApplicationTips := sdkws.JoinGroupApplicationTips{Group: &sdkws.GroupInfo{}, Applicant: &sdkws.PublicUserInfo{}} + err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group) + if err != nil { + log.Error(utils.OperationID(ctx), "setGroupInfo failed ", err.Error(), req.GroupID) + return + } + if err = setPublicUserInfo(utils.OpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { + log.Error(utils.OperationID(ctx), "setPublicUserInfo failed ", err.Error(), utils.OpUserID(ctx)) + return + } + JoinGroupApplicationTips.ReqMsg = req.ReqMessage + + managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) + if err != nil { + log.NewError(utils.OperationID(ctx), "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID) + return + } + for _, v := range managerList { + groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, utils.OpUserID(ctx), "", v.UserID, utils.OperationID(ctx)) + log.NewInfo(utils.OperationID(ctx), "Notification ", v) + } +} + +func MemberQuitNotification(req *pbGroup.QuitGroupReq) { + MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil { + log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) + return + } + if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberQuitTips.QuitUser); err != nil { + log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID) + return + } + + groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID) +} + +// message ApplicationProcessedTips{ +// GroupInfo Group = 1; +// GroupMemberFullInfo OpUser = 2; +// int32 Result = 3; +// string Reason = 4; +// } +// +// 处理进群请求后调用 +func GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseReq) { + GroupApplicationAcceptedTips := sdkws.GroupApplicationAcceptedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} + if err := setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil { + log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationAcceptedTips.Group) + return + } + if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { + log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser) + return + } + + groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", req.FromUserID, req.OperationID) + adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) + if err != nil { + log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) + return + } + for _, v := range adminList { + if v.UserID == req.OpUserID { + continue + } + GroupApplicationAcceptedTips.ReceiverAs = 1 + groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", v.UserID, req.OperationID) + } +} + +func GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseReq) { + GroupApplicationRejectedTips := sdkws.GroupApplicationRejectedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} + if err := setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil { + log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationRejectedTips.Group) + return + } + if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { + log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser) + return + } + groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", req.FromUserID, req.OperationID) + adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) + if err != nil { + log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) + return + } + for _, v := range adminList { + if v.UserID == req.OpUserID { + continue + } + GroupApplicationRejectedTips.ReceiverAs = 1 + groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", v.UserID, req.OperationID) + } +} + +func GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) { + GroupOwnerTransferredTips := sdkws.GroupOwnerTransferredTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, NewGroupOwner: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil { + log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) + return + } + if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { + log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) + return + } + if err := setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil { + log.Error(req.OperationID, "setGroupMemberInfo failed", req.GroupID, req.NewOwnerUserID) + return + } + groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID) +} + +func GroupDismissedNotification(req *pbGroup.DismissGroupReq) { + tips := sdkws.GroupDismissedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(req.GroupID, tips.Group); err != nil { + log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) + return + } + if err := setOpUserInfo(req.OpUserID, req.GroupID, tips.OpUser); err != nil { + log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) + return + } + groupNotification(constant.GroupDismissedNotification, &tips, req.OpUserID, req.GroupID, "", req.OperationID) +} + +// message MemberKickedTips{ +// GroupInfo Group = 1; +// GroupMemberFullInfo OpUser = 2; +// GroupMemberFullInfo KickedUser = 3; +// uint64 OperationTime = 4; +// } +// +// 被踢后调用 +func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) { + MemberKickedTips := sdkws.MemberKickedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil { + log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) + return + } + if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil { + log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID) + return + } + for _, v := range kickedUserIDList { + var groupMemberInfo sdkws.GroupMemberFullInfo + if err := setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil { + log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.GroupID, v) + continue + } + MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo) + } + groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, req.GroupID, "", req.OperationID) + // + //for _, v := range kickedUserIDList { + // groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID) + //} +} + +// message MemberInvitedTips{ +// GroupInfo Group = 1; +// GroupMemberFullInfo OpUser = 2; +// GroupMemberFullInfo InvitedUser = 3; +// uint64 OperationTime = 4; +// } +// +// 被邀请进群后调用 +func MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) { + MemberInvitedTips := sdkws.MemberInvitedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, MemberInvitedTips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + for _, v := range invitedUserIDList { + var groupMemberInfo sdkws.GroupMemberFullInfo + if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID) + continue + } + MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo) + } + groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID) +} + +//message GroupInfoChangedTips{ +// int32 ChangedType = 1; //bitwise operators: 1:groupName; 10:Notification 100:Introduction; 1000:FaceUrl +// GroupInfo Group = 2; +// GroupMemberFullInfo OpUser = 3; +//} + +//message MemberLeaveTips{ +// GroupInfo Group = 1; +// GroupMemberFullInfo LeaverUser = 2; +// uint64 OperationTime = 3; +//} + +//群成员退群后调用 + +// message MemberEnterTips{ +// GroupInfo Group = 1; +// GroupMemberFullInfo EntrantUser = 2; +// uint64 OperationTime = 3; +// } +// +// 群成员主动申请进群,管理员同意后调用, +func MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { + MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil { + log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberEnterTips.Group) + return + } + if err := setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil { + log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser) + return + } + groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID) +} + +func MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) { + MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, MemberEnterTips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group) + return + } + if err := setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser) + return + } + groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID) +} diff --git a/internal/common/notification/msg.go b/internal/common/notification/msg.go new file mode 100644 index 000000000..a846ce738 --- /dev/null +++ b/internal/common/notification/msg.go @@ -0,0 +1,48 @@ +package notification + +import ( + "Open_IM/internal/rpc/msg" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/log" + sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" + "github.com/golang/protobuf/jsonpb" + "github.com/golang/protobuf/proto" +) + +func DeleteMessageNotification(opUserID, userID string, seqList []uint32, operationID string) { + DeleteMessageTips := sdkws.DeleteMessageTips{OpUserID: opUserID, UserID: userID, SeqList: seqList} + MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips) +} + +func MessageNotification(operationID, sendID, recvID string, contentType int32, m proto.Message) { + log.Debug(operationID, utils.GetSelfFuncName(), "args: ", m.String(), contentType) + var err error + var tips sdkws.TipsComm + tips.Detail, err = proto.Marshal(m) + if err != nil { + log.Error(operationID, "Marshal failed ", err.Error(), m.String()) + return + } + + marshaler := jsonpb.Marshaler{ + OrigName: true, + EnumsAsInts: false, + EmitDefaults: false, + } + + tips.JsonDetail, _ = marshaler.MarshalToString(m) + var n msg.NotificationMsg + n.SendID = sendID + n.RecvID = recvID + n.ContentType = contentType + n.SessionType = constant.SingleChatType + n.MsgFrom = constant.SysMsgType + n.OperationID = operationID + n.Content, err = proto.Marshal(&tips) + if err != nil { + log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) + return + } + msg.Notification(&n) +} diff --git a/internal/common/notification/super_group.go b/internal/common/notification/super_group.go new file mode 100644 index 000000000..19d08dd98 --- /dev/null +++ b/internal/common/notification/super_group.go @@ -0,0 +1,24 @@ +package notification + +import ( + "Open_IM/internal/rpc/msg" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/log" + //sdk "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" + //"github.com/golang/protobuf/jsonpb" + //"github.com/golang/protobuf/proto" +) + +func SuperGroupNotification(operationID, sendID, recvID string) { + n := &msg.NotificationMsg{ + SendID: sendID, + RecvID: recvID, + MsgFrom: constant.SysMsgType, + ContentType: constant.SuperGroupUpdateNotification, + SessionType: constant.SingleChatType, + OperationID: operationID, + } + log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content)) + msg.Notification(n) +} diff --git a/internal/rpc/msg/extend_msg_callback.go b/internal/rpc/msg/extend_msg_callback.go new file mode 100644 index 000000000..eefcb419e --- /dev/null +++ b/internal/rpc/msg/extend_msg_callback.go @@ -0,0 +1,104 @@ +package msg + +import ( + cbApi "Open_IM/pkg/call_back_struct" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/http" + "Open_IM/pkg/common/log" + "Open_IM/pkg/proto/msg" + "Open_IM/pkg/utils" + http2 "net/http" +) + +func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensionsReq) *cbApi.CallbackBeforeSetMessageReactionExtResp { + callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} + log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) + req := cbApi.CallbackBeforeSetMessageReactionExtReq{ + OperationID: setReq.OperationID, + CallbackCommand: constant.CallbackBeforeSetMessageReactionExtensionCommand, + SourceID: setReq.SourceID, + OpUserID: setReq.OpUserID, + SessionType: setReq.SessionType, + ReactionExtensionList: setReq.ReactionExtensionList, + ClientMsgID: setReq.ClientMsgID, + IsReact: setReq.IsReact, + IsExternalExtensions: setReq.IsExternalExtensions, + MsgFirstModifyTime: setReq.MsgFirstModifyTime, + } + resp := &cbApi.CallbackBeforeSetMessageReactionExtResp{CommonCallbackResp: &callbackResp} + defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp) + if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetMessageReactionExtensionCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { + callbackResp.ErrCode = http2.StatusInternalServerError + callbackResp.ErrMsg = err.Error() + } + return resp + +} + +func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReactionExtensionsReq) *cbApi.CallbackDeleteMessageReactionExtResp { + callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} + log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) + req := cbApi.CallbackDeleteMessageReactionExtReq{ + OperationID: setReq.OperationID, + CallbackCommand: constant.CallbackBeforeDeleteMessageReactionExtensionsCommand, + SourceID: setReq.SourceID, + OpUserID: setReq.OpUserID, + SessionType: setReq.SessionType, + ReactionExtensionList: setReq.ReactionExtensionList, + ClientMsgID: setReq.ClientMsgID, + IsExternalExtensions: setReq.IsExternalExtensions, + MsgFirstModifyTime: setReq.MsgFirstModifyTime, + } + resp := &cbApi.CallbackDeleteMessageReactionExtResp{CommonCallbackResp: &callbackResp} + defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp) + if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeDeleteMessageReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { + callbackResp.ErrCode = http2.StatusInternalServerError + callbackResp.ErrMsg = err.Error() + } + return resp +} +func callbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) *cbApi.CallbackGetMessageListReactionExtResp { + callbackResp := cbApi.CommonCallbackResp{OperationID: getReq.OperationID} + log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), getReq.String()) + req := cbApi.CallbackGetMessageListReactionExtReq{ + OperationID: getReq.OperationID, + CallbackCommand: constant.CallbackGetMessageListReactionExtensionsCommand, + SourceID: getReq.SourceID, + OpUserID: getReq.OpUserID, + SessionType: getReq.SessionType, + TypeKeyList: getReq.TypeKeyList, + MessageKeyList: getReq.MessageReactionKeyList, + } + resp := &cbApi.CallbackGetMessageListReactionExtResp{CommonCallbackResp: &callbackResp} + defer log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), req, *resp) + if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackGetMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { + callbackResp.ErrCode = http2.StatusInternalServerError + callbackResp.ErrMsg = err.Error() + } + return resp +} +func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensionsReq) *cbApi.CallbackAddMessageReactionExtResp { + callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} + log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) + req := cbApi.CallbackAddMessageReactionExtReq{ + OperationID: setReq.OperationID, + CallbackCommand: constant.CallbackAddMessageListReactionExtensionsCommand, + SourceID: setReq.SourceID, + OpUserID: setReq.OpUserID, + SessionType: setReq.SessionType, + ReactionExtensionList: setReq.ReactionExtensionList, + ClientMsgID: setReq.ClientMsgID, + IsReact: setReq.IsReact, + IsExternalExtensions: setReq.IsExternalExtensions, + MsgFirstModifyTime: setReq.MsgFirstModifyTime, + } + resp := &cbApi.CallbackAddMessageReactionExtResp{CommonCallbackResp: &callbackResp} + defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp, *resp.CommonCallbackResp, resp.IsReact, resp.MsgFirstModifyTime) + if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAddMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { + callbackResp.ErrCode = http2.StatusInternalServerError + callbackResp.ErrMsg = err.Error() + } + return resp + +} From 217d6380f70e1b12021ce28e741b34433ae75626 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 09:19:56 +0800 Subject: [PATCH 06/48] Error code standardization --- internal/rpc/msg/delete.go | 6 +++--- internal/rpc/msg/extend_msg.go | 8 ++++---- internal/rpc/msg/msg_status.go | 4 ++-- internal/rpc/msg/query_msg.go | 2 +- internal/rpc/msg/send_msg.go | 10 +++++----- internal/rpc/msg/send_pull.go | 2 +- internal/rpc/msg/server.go | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/rpc/msg/delete.go b/internal/rpc/msg/delete.go index 954126134..ee2c15d96 100644 --- a/internal/rpc/msg/delete.go +++ b/internal/rpc/msg/delete.go @@ -12,7 +12,7 @@ import ( "time" ) -func (rpc *rpcChat) DelMsgList(_ context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) { +func (rpc *msgServer) DelMsgList(_ context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) resp := &common.DelMsgListResp{} select { @@ -30,7 +30,7 @@ func (rpc *rpcChat) DelMsgList(_ context.Context, req *common.DelMsgListReq) (*c log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil } -func (rpc *rpcChat) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) { +func (rpc *msgServer) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) if !tokenverify.CheckAccess(ctx, req.OpUserID, req.UserID) { log.NewError(req.OperationID, "CheckAccess false ", req.OpUserID, req.UserID) @@ -55,7 +55,7 @@ func (rpc *rpcChat) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroup return resp, nil } -func (rpc *rpcChat) ClearMsg(_ context.Context, req *pbChat.ClearMsgReq) (*pbChat.ClearMsgResp, error) { +func (rpc *msgServer) ClearMsg(_ context.Context, req *pbChat.ClearMsgReq) (*pbChat.ClearMsgResp, error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc req: ", req.String()) if req.OpUserID != req.UserID && !tokenverify.IsManagerUserID(req.UserID) { errMsg := "No permission" + req.OpUserID + req.UserID diff --git a/internal/rpc/msg/extend_msg.go b/internal/rpc/msg/extend_msg.go index 043ff67b7..fa4af83b2 100644 --- a/internal/rpc/msg/extend_msg.go +++ b/internal/rpc/msg/extend_msg.go @@ -14,7 +14,7 @@ import ( "time" ) -func (rpc *rpcChat) SetMessageReactionExtensions(ctx context.Context, req *msg.SetMessageReactionExtensionsReq) (resp *msg.SetMessageReactionExtensionsResp, err error) { +func (rpc *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.SetMessageReactionExtensionsReq) (resp *msg.SetMessageReactionExtensionsResp, err error) { log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String()) var rResp msg.SetMessageReactionExtensionsResp rResp.ClientMsgID = req.ClientMsgID @@ -216,7 +216,7 @@ func setDeleteKeyResultInfo(r *msg.DeleteMessageListReactionExtensionsResp, errC _ = db.DB.UnLockMessageTypeKey(clientMsgID, typeKey) } -func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *msg.GetMessageListReactionExtensionsReq) (resp *msg.GetMessageListReactionExtensionsResp, err error) { +func (rpc *msgServer) GetMessageListReactionExtensions(ctx context.Context, req *msg.GetMessageListReactionExtensionsReq) (resp *msg.GetMessageListReactionExtensionsResp, err error) { log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String()) var rResp msg.GetMessageListReactionExtensionsResp for _, messageValue := range req.MessageReactionKeyList { @@ -272,11 +272,11 @@ func (rpc *rpcChat) GetMessageListReactionExtensions(ctx context.Context, req *m } -func (rpc *rpcChat) AddMessageReactionExtensions(ctx context.Context, req *msg.ModifyMessageReactionExtensionsReq) (resp *msg.ModifyMessageReactionExtensionsResp, err error) { +func (rpc *msgServer) AddMessageReactionExtensions(ctx context.Context, req *msg.ModifyMessageReactionExtensionsReq) (resp *msg.ModifyMessageReactionExtensionsResp, err error) { return } -func (rpc *rpcChat) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) { +func (rpc *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) { log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String()) var rResp msg.DeleteMessageListReactionExtensionsResp callbackResp := notification.callbackDeleteMessageReactionExtensions(req) diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go index 698e98a3d..6a38def31 100644 --- a/internal/rpc/msg/msg_status.go +++ b/internal/rpc/msg/msg_status.go @@ -11,7 +11,7 @@ import ( goRedis "github.com/go-redis/redis/v8" ) -func (rpc *rpcChat) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgStatusReq) (resp *pbMsg.SetSendMsgStatusResp, err error) { +func (rpc *msgServer) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgStatusReq) (resp *pbMsg.SetSendMsgStatusResp, err error) { resp = &pbMsg.SetSendMsgStatusResp{} log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String()) if err := db.DB.SetSendMsgStatus(req.Status, req.OperationID); err != nil { @@ -24,7 +24,7 @@ func (rpc *rpcChat) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgSta return resp, nil } -func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) { +func (rpc *msgServer) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) { log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String()) resp = &pbMsg.GetSendMsgStatusResp{} status, err := db.DB.GetSendMsgStatus(req.OperationID) diff --git a/internal/rpc/msg/query_msg.go b/internal/rpc/msg/query_msg.go index 1bdc98fac..e0f763f92 100644 --- a/internal/rpc/msg/query_msg.go +++ b/internal/rpc/msg/query_msg.go @@ -10,7 +10,7 @@ import ( go_redis "github.com/go-redis/redis/v8" ) -func (rpc *rpcChat) GetSuperGroupMsg(context context.Context, req *msg.GetSuperGroupMsgReq) (*msg.GetSuperGroupMsgResp, error) { +func (rpc *msgServer) GetSuperGroupMsg(context context.Context, req *msg.GetSuperGroupMsgReq) (*msg.GetSuperGroupMsgResp, error) { log.Debug(req.OperationID, utils.GetSelfFuncName(), req.String()) resp := new(msg.GetSuperGroupMsgResp) redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(req.GroupID, []uint32{req.Seq}, req.OperationID) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 6da381df9..380f91d7f 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -107,7 +107,7 @@ func groupIsMuted(ctx context.Context, groupID string) (bool, error) { return false, nil } -func (rpc *rpcChat) messageVerification(ctx context.Context, data *pbChat.SendMsgReq) (bool, int32, string, []string) { +func (rpc *msgServer) messageVerification(ctx context.Context, data *pbChat.SendMsgReq) (bool, int32, string, []string) { switch data.MsgData.SessionType { case constant.SingleChatType: if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { @@ -282,7 +282,7 @@ func (rpc *rpcChat) messageVerification(ctx context.Context, data *pbChat.SendMs } } -func (rpc *rpcChat) encapsulateMsgData(msg *sdkws.MsgData) { +func (rpc *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { msg.ServerMsgID = GetMsgID(msg.SendID) msg.SendTime = utils.GetCurrentTimestampByMill() switch msg.ContentType { @@ -331,7 +331,7 @@ func (rpc *rpcChat) encapsulateMsgData(msg *sdkws.MsgData) { } } -func (rpc *rpcChat) sendMsgToWriter(ctx context.Context, m *pbChat.MsgDataToMQ, key string, status string) error { +func (rpc *msgServer) sendMsgToWriter(ctx context.Context, m *pbChat.MsgDataToMQ, key string, status string) error { switch status { case constant.OnlineStatus: if m.MsgData.ContentType == constant.SignalingNotification { @@ -502,7 +502,7 @@ func valueCopy(pb *pbChat.SendMsgReq) *pbChat.SendMsgReq { return &pbChat.SendMsgReq{Token: pb.Token, OperationID: pb.OperationID, MsgData: &msgData} } -func (rpc *rpcChat) sendMsgToGroup(ctx context.Context, list []string, pb pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) { +func (rpc *msgServer) sendMsgToGroup(ctx context.Context, list []string, pb pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) { // log.Debug(pb.OperationID, "split userID ", list) offlinePushInfo := sdkws.OfflinePushInfo{} if pb.MsgData.OfflinePushInfo != nil { @@ -538,7 +538,7 @@ func (rpc *rpcChat) sendMsgToGroup(ctx context.Context, list []string, pb pbChat wg.Done() } -func (rpc *rpcChat) sendMsgToGroupOptimization(ctx context.Context, list []string, groupPB *pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) { +func (rpc *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []string, groupPB *pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) { msgToMQGroup := pbChat.MsgDataToMQ{Token: groupPB.Token, OperationID: groupPB.OperationID, MsgData: groupPB.MsgData} tempOptions := make(map[string]bool, 1) for k, v := range groupPB.MsgData.Options { diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index 04159886a..77b204f7f 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -21,7 +21,7 @@ func (m *msgServer) SendMsg(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat return returnMsg(&replay, pb, errCode, errMsg, "", 0) } t1 := time.Now() - rpc.encapsulateMsgData(pb.MsgData) + m.encapsulateMsgData(pb.MsgData) log.Debug(pb.OperationID, "encapsulateMsgData ", " cost time: ", time.Since(t1)) msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData} // callback diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 659a70a3a..ea2187127 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -32,9 +32,9 @@ type deleteMsg struct { OperationID string } -func NewRpcChatServer(port int) *rpcChat { +func NewRpcChatServer(port int) *msgServer { log.NewPrivateLog(constant.LogFileName) - rc := rpcChat{ + rc := msgServer{ rpcPort: port, rpcRegisterName: config.Config.RpcRegisterName.OpenImMsgName, etcdSchema: config.Config.Etcd.EtcdSchema, @@ -73,7 +73,7 @@ func (rpc *rpcChat) initPrometheus() { promePkg.NewWorkSuperGroupChatMsgProcessFailedCounter() } -func (rpc *rpcChat) Run() { +func (rpc *msgServer) Run() { log.Info("", "rpcChat init...") listenIP := "" if config.Config.ListenIP == "" { From ac1032800f0644f434697123de3e707dcb9444f7 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 10:03:16 +0800 Subject: [PATCH 07/48] Error code standardization --- internal/rpc/msg/query_msg.go | 47 ----------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 internal/rpc/msg/query_msg.go diff --git a/internal/rpc/msg/query_msg.go b/internal/rpc/msg/query_msg.go deleted file mode 100644 index e0f763f92..000000000 --- a/internal/rpc/msg/query_msg.go +++ /dev/null @@ -1,47 +0,0 @@ -package msg - -import ( - commonDB "Open_IM/pkg/common/db" - "Open_IM/pkg/common/log" - promePkg "Open_IM/pkg/common/prometheus" - "Open_IM/pkg/proto/msg" - "Open_IM/pkg/utils" - "context" - go_redis "github.com/go-redis/redis/v8" -) - -func (rpc *msgServer) GetSuperGroupMsg(context context.Context, req *msg.GetSuperGroupMsgReq) (*msg.GetSuperGroupMsgResp, error) { - log.Debug(req.OperationID, utils.GetSelfFuncName(), req.String()) - resp := new(msg.GetSuperGroupMsgResp) - redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(req.GroupID, []uint32{req.Seq}, req.OperationID) - if err != nil { - if err != go_redis.Nil { - promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList) - } else { - log.Debug(req.OperationID, "get message from redis is nil", failedSeqList) - } - msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(req.GroupID, failedSeqList, req.OperationID) - if err1 != nil { - promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - log.Error(req.OperationID, "GetSuperGroupMsg data error", req.String(), err.Error()) - resp.ErrCode = 201 - resp.ErrMsg = err.Error() - return resp, nil - } else { - promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - redisMsgList = append(redisMsgList, msgList...) - for _, m := range msgList { - resp.MsgData = m - } - - } - } else { - promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - for _, m := range redisMsgList { - resp.MsgData = m - } - } - log.Debug(req.OperationID, utils.GetSelfFuncName(), resp.String()) - return resp, nil -} From 52e393dc458c5a4edfc9fd311ea46e6a9fc55b96 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 13 Feb 2023 10:33:54 +0800 Subject: [PATCH 08/48] msg status --- internal/rpc/msg/msg_status.go | 38 ++++------------ internal/rpc/msg/query_msg.go | 80 +++++++++++++++------------------ internal/rpc/msg/server.go | 2 + internal/rpc/msg/utils.go | 16 +++++++ pkg/common/db/controller/msg.go | 4 ++ 5 files changed, 65 insertions(+), 75 deletions(-) create mode 100644 internal/rpc/msg/utils.go diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go index 6a38def31..fe05f5194 100644 --- a/internal/rpc/msg/msg_status.go +++ b/internal/rpc/msg/msg_status.go @@ -1,46 +1,24 @@ package msg import ( - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db" - "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" pbMsg "Open_IM/pkg/proto/msg" - "Open_IM/pkg/utils" "context" - - goRedis "github.com/go-redis/redis/v8" ) -func (rpc *msgServer) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgStatusReq) (resp *pbMsg.SetSendMsgStatusResp, err error) { - resp = &pbMsg.SetSendMsgStatusResp{} - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String()) - if err := db.DB.SetSendMsgStatus(req.Status, req.OperationID); err != nil { - log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) - resp.ErrCode = constant.ErrDatabase.ErrCode - resp.ErrMsg = err.Error() - return resp, nil +func (s *msgServer) SetSendMsgStatus(ctx context.Context, req *pbMsg.SetSendMsgStatusReq) (*pbMsg.SetSendMsgStatusResp, error) { + resp := &pbMsg.SetSendMsgStatusResp{} + if err := s.MsgInterface.SetSendMsgStatus(ctx, tracelog.GetOperationID(ctx), req.Status); err != nil { + return nil, err } - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String()) return resp, nil } -func (rpc *msgServer) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) { - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String()) +func (s *msgServer) GetSendMsgStatus(ctx context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) { resp = &pbMsg.GetSendMsgStatusResp{} - status, err := db.DB.GetSendMsgStatus(req.OperationID) + resp.Status, err = s.MsgInterface.GetSendMsgStatus(ctx, tracelog.GetOperationID(ctx)) if err != nil { - resp.Status = constant.MsgStatusNotExist - if err == goRedis.Nil { - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.OperationID, "not exist") - return resp, nil - } else { - log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) - resp.ErrMsg = err.Error() - resp.ErrCode = constant.ErrDB.ErrCode - return resp, nil - } + return nil, err } - resp.Status = int32(status) - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String()) return resp, nil } diff --git a/internal/rpc/msg/query_msg.go b/internal/rpc/msg/query_msg.go index e0f763f92..66f2f0810 100644 --- a/internal/rpc/msg/query_msg.go +++ b/internal/rpc/msg/query_msg.go @@ -1,47 +1,37 @@ package msg -import ( - commonDB "Open_IM/pkg/common/db" - "Open_IM/pkg/common/log" - promePkg "Open_IM/pkg/common/prometheus" - "Open_IM/pkg/proto/msg" - "Open_IM/pkg/utils" - "context" - go_redis "github.com/go-redis/redis/v8" -) - -func (rpc *msgServer) GetSuperGroupMsg(context context.Context, req *msg.GetSuperGroupMsgReq) (*msg.GetSuperGroupMsgResp, error) { - log.Debug(req.OperationID, utils.GetSelfFuncName(), req.String()) - resp := new(msg.GetSuperGroupMsgResp) - redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(req.GroupID, []uint32{req.Seq}, req.OperationID) - if err != nil { - if err != go_redis.Nil { - promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList) - } else { - log.Debug(req.OperationID, "get message from redis is nil", failedSeqList) - } - msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(req.GroupID, failedSeqList, req.OperationID) - if err1 != nil { - promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - log.Error(req.OperationID, "GetSuperGroupMsg data error", req.String(), err.Error()) - resp.ErrCode = 201 - resp.ErrMsg = err.Error() - return resp, nil - } else { - promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - redisMsgList = append(redisMsgList, msgList...) - for _, m := range msgList { - resp.MsgData = m - } - - } - } else { - promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - for _, m := range redisMsgList { - resp.MsgData = m - } - } - log.Debug(req.OperationID, utils.GetSelfFuncName(), resp.String()) - return resp, nil -} +//func (rpc *msgServer) GetSuperGroupMsg(context context.Context, req *msg.GetSuperGroupMsgReq) (*msg.GetSuperGroupMsgResp, error) { +// log.Debug(req.OperationID, utils.GetSelfFuncName(), req.String()) +// resp := new(msg.GetSuperGroupMsgResp) +// redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(req.GroupID, []uint32{req.Seq}, req.OperationID) +// if err != nil { +// if err != go_redis.Nil { +// promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) +// log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList) +// } else { +// log.Debug(req.OperationID, "get message from redis is nil", failedSeqList) +// } +// msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(req.GroupID, failedSeqList, req.OperationID) +// if err1 != nil { +// promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) +// log.Error(req.OperationID, "GetSuperGroupMsg data error", req.String(), err.Error()) +// resp.ErrCode = 201 +// resp.ErrMsg = err.Error() +// return resp, nil +// } else { +// promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) +// redisMsgList = append(redisMsgList, msgList...) +// for _, m := range msgList { +// resp.MsgData = m +// } +// +// } +// } else { +// promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) +// for _, m := range redisMsgList { +// resp.MsgData = m +// } +// } +// log.Debug(req.OperationID, utils.GetSelfFuncName(), resp.String()) +// return resp, nil +//} diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index ea2187127..b62822cf0 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -5,6 +5,7 @@ import ( "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/db/controller" "Open_IM/pkg/common/kafka" "Open_IM/pkg/common/log" @@ -23,6 +24,7 @@ import ( type msgServer struct { *rpcserver.RpcServer + MsgInterface controller.MsgInterface } type deleteMsg struct { diff --git a/internal/rpc/msg/utils.go b/internal/rpc/msg/utils.go new file mode 100644 index 000000000..fd0f4e9b3 --- /dev/null +++ b/internal/rpc/msg/utils.go @@ -0,0 +1,16 @@ +package msg + +import ( + "Open_IM/pkg/utils" + "github.com/go-redis/redis/v8" + "gorm.io/gorm" +) + +func IsNotFound(err error) bool { + switch utils.Unwrap(err) { + case gorm.ErrRecordNotFound, redis.Nil: + return true + default: + return false + } +} diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index 15cbe872a..fe8bf604f 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -18,6 +18,10 @@ type MsgInterface interface { DelMsgLogic(ctx context.Context, userID string, seqList []uint32) error DelMsgBySeqListInOneDoc(ctx context.Context, docID string, seqList []uint32) (unExistSeqList []uint32, err error) ReplaceMsgToBlankByIndex(docID string, index int) (replaceMaxSeq uint32, err error) + + // status + SetSendMsgStatus(ctx context.Context, id string, status int32) error + GetSendMsgStatus(ctx context.Context, id string) (int32, error) // 不存在返回 constant.MsgStatusNotExist } type MsgDatabaseInterface interface { From 991a4d1d956f9d9510b2faa833f97265562cd0b3 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 13 Feb 2023 11:24:13 +0800 Subject: [PATCH 09/48] msg del --- internal/rpc/msg/delete.go | 80 ++++++++------------------------ internal/rpc/msg/msg_status.go | 13 ++++-- internal/rpc/msg/notification.go | 7 +++ pkg/common/db/controller/msg.go | 5 ++ 4 files changed, 41 insertions(+), 64 deletions(-) create mode 100644 internal/rpc/msg/notification.go diff --git a/internal/rpc/msg/delete.go b/internal/rpc/msg/delete.go index ee2c15d96..44b506df6 100644 --- a/internal/rpc/msg/delete.go +++ b/internal/rpc/msg/delete.go @@ -1,83 +1,43 @@ package msg import ( - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db" - "Open_IM/pkg/common/log" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/proto/msg" common "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" "context" - "time" ) -func (rpc *msgServer) DelMsgList(_ context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) { - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) +func (s *msgServer) DelMsgList(ctx context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) { resp := &common.DelMsgListResp{} - select { - case rpc.delMsgCh <- deleteMsg{ - UserID: req.UserID, - OpUserID: req.OpUserID, - SeqList: req.SeqList, - OperationID: req.OperationID, - }: - case <-time.After(1 * time.Second): - resp.ErrCode = constant.ErrSendLimit.ErrCode - resp.ErrMsg = constant.ErrSendLimit.ErrMsg - return resp, nil + if err := s.MsgInterface.DelMsgFromCache(ctx, req.UserID, req.SeqList); err != nil { + return nil, err } - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) + DeleteMessageNotification(ctx, req.UserID, req.SeqList) return resp, nil } -func (rpc *msgServer) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) { - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) - if !tokenverify.CheckAccess(ctx, req.OpUserID, req.UserID) { - log.NewError(req.OperationID, "CheckAccess false ", req.OpUserID, req.UserID) - return &msg.DelSuperGroupMsgResp{ErrCode: constant.ErrNoPermission.ErrCode, ErrMsg: constant.ErrNoPermission.ErrMsg}, nil - } + +func (s *msgServer) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) { resp := &msg.DelSuperGroupMsgResp{} - groupMaxSeq, err := db.DB.GetGroupMaxSeq(req.GroupID) - if err != nil { - log.NewError(req.OperationID, "GetGroupMaxSeq false ", req.OpUserID, req.UserID, req.GroupID) - resp.ErrCode = constant.ErrDB.ErrCode - resp.ErrMsg = err.Error() - return resp, nil + if err := tokenverify.CheckAdmin(ctx); err != nil { + return nil, err } - err = db.DB.SetGroupUserMinSeq(req.GroupID, req.UserID, groupMaxSeq) + maxSeq, err := s.MsgInterface.GetGroupMaxSeq(ctx, req.GroupID) if err != nil { - log.NewError(req.OperationID, "SetGroupUserMinSeq false ", req.OpUserID, req.UserID, req.GroupID) - resp.ErrCode = constant.ErrDB.ErrCode - resp.ErrMsg = err.Error() - return resp, nil + return nil, err + } + if err := s.MsgInterface.SetGroupUserMinSeq(ctx, req.GroupID, maxSeq); err != nil { + return nil, err } - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil } -func (rpc *msgServer) ClearMsg(_ context.Context, req *pbChat.ClearMsgReq) (*pbChat.ClearMsgResp, error) { - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc req: ", req.String()) - if req.OpUserID != req.UserID && !tokenverify.IsManagerUserID(req.UserID) { - errMsg := "No permission" + req.OpUserID + req.UserID - log.Error(req.OperationID, errMsg) - return &pbChat.ClearMsgResp{ErrCode: constant.ErrNoPermission.ErrCode, ErrMsg: errMsg}, nil +func (s *msgServer) ClearMsg(ctx context.Context, req *msg.ClearMsgReq) (*msg.ClearMsgResp, error) { + resp := &msg.ClearMsgResp{} + if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil { + return nil, err } - log.Debug(req.OperationID, "CleanUpOneUserAllMsgFromRedis args", req.UserID) - err := db.DB.CleanUpOneUserAllMsgFromRedis(req.UserID, req.OperationID) - if err != nil { - errMsg := "CleanUpOneUserAllMsgFromRedis failed " + err.Error() + req.OperationID + req.UserID - log.Error(req.OperationID, errMsg) - return &pbChat.ClearMsgResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil + if err := s.MsgInterface.DelUserAllSeq(ctx, req.UserID); err != nil { + return nil, err } - log.Debug(req.OperationID, "CleanUpUserMsgFromMongo args", req.UserID) - err = db.DB.CleanUpUserMsgFromMongo(req.UserID, req.OperationID) - if err != nil { - errMsg := "CleanUpUserMsgFromMongo failed " + err.Error() + req.OperationID + req.UserID - log.Error(req.OperationID, errMsg) - return &pbChat.ClearMsgResp{ErrCode: constant.ErrDatabase.ErrCode, ErrMsg: errMsg}, nil - } - - resp := pbChat.ClearMsgResp{ErrCode: 0} - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) - return &resp, nil + return resp, nil } diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go index fe05f5194..fb0ed2edf 100644 --- a/internal/rpc/msg/msg_status.go +++ b/internal/rpc/msg/msg_status.go @@ -1,6 +1,7 @@ package msg import ( + "Open_IM/pkg/common/constant" "Open_IM/pkg/common/tracelog" pbMsg "Open_IM/pkg/proto/msg" "context" @@ -14,11 +15,15 @@ func (s *msgServer) SetSendMsgStatus(ctx context.Context, req *pbMsg.SetSendMsgS return resp, nil } -func (s *msgServer) GetSendMsgStatus(ctx context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) { - resp = &pbMsg.GetSendMsgStatusResp{} - resp.Status, err = s.MsgInterface.GetSendMsgStatus(ctx, tracelog.GetOperationID(ctx)) - if err != nil { +func (s *msgServer) GetSendMsgStatus(ctx context.Context, req *pbMsg.GetSendMsgStatusReq) (*pbMsg.GetSendMsgStatusResp, error) { + resp := &pbMsg.GetSendMsgStatusResp{} + status, err := s.MsgInterface.GetSendMsgStatus(ctx, tracelog.GetOperationID(ctx)) + if IsNotFound(err) { + resp.Status = constant.MsgStatusNotExist + return resp, nil + } else if err != nil { return nil, err } + resp.Status = status return resp, nil } diff --git a/internal/rpc/msg/notification.go b/internal/rpc/msg/notification.go new file mode 100644 index 000000000..439c2e3b2 --- /dev/null +++ b/internal/rpc/msg/notification.go @@ -0,0 +1,7 @@ +package msg + +import "context" + +func DeleteMessageNotification(ctx context.Context, userID string, seqs []uint32) { + panic("todo") +} diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index fe8bf604f..3445e8dd1 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -22,6 +22,11 @@ type MsgInterface interface { // status SetSendMsgStatus(ctx context.Context, id string, status int32) error GetSendMsgStatus(ctx context.Context, id string) (int32, error) // 不存在返回 constant.MsgStatusNotExist + // delete + DelMsgFromCache(ctx context.Context, userID string, seqs []uint32) error + GetGroupMaxSeq(ctx context.Context, groupID string) (uint32, error) + SetGroupUserMinSeq(ctx context.Context, groupID string, seq uint32) error + DelUserAllSeq(ctx context.Context, userID string) error // redis and mongodb } type MsgDatabaseInterface interface { From 03a7048d31323508675012f040eac0e59638ec51 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 13 Feb 2023 11:24:45 +0800 Subject: [PATCH 10/48] msg del --- internal/rpc/msg/query_msg.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 internal/rpc/msg/query_msg.go diff --git a/internal/rpc/msg/query_msg.go b/internal/rpc/msg/query_msg.go deleted file mode 100644 index e69de29bb..000000000 From 6b47c471f7fc6c130236574f27cb4b0285dba460 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 15:52:41 +0800 Subject: [PATCH 11/48] Error code standardization --- internal/rpc/msg/callback.go | 10 +- internal/rpc/msg/send_msg.go | 27 +- internal/rpc/msg/send_pull.go | 496 ++++++++++++++++------------------ internal/rpc/msg/utils.go | 27 +- 4 files changed, 252 insertions(+), 308 deletions(-) diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index 3ebddc9ef..c6848a82f 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -33,7 +33,7 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbapi.CommonCallbackReq return req } -func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { +func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) error { callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable { return callbackResp @@ -65,7 +65,7 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackRes return callbackResp } -func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { +func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) error { callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable { return callbackResp @@ -88,7 +88,7 @@ func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp return callbackResp } -func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { +func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) error { callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackBeforeSendGroupMsg.Enable { return callbackResp @@ -117,7 +117,7 @@ func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp return callbackResp } -func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { +func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) error { callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable { return callbackResp @@ -140,7 +140,7 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp return callbackResp } -func callbackMsgModify(msg *pbChat.SendMsgReq) cbapi.CommonCallbackResp { +func callbackMsgModify(msg *pbChat.SendMsgReq) (err error) { log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackMsgModify.Enable || msg.MsgData.ContentType != constant.Text { diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 380f91d7f..dc1f9b481 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -66,24 +66,6 @@ type MsgCallBackResp struct { } } -func isMessageHasReadEnabled(pb *msg.SendMsgReq) (bool, int32, string) { - switch pb.MsgData.ContentType { - case constant.HasReadReceipt: - if config.Config.SingleMessageHasReadReceiptEnable { - return true, 0, "" - } else { - return false, constant.ErrMessageHasReadDisable.ErrCode, constant.ErrMessageHasReadDisable.ErrMsg - } - case constant.GroupHasReadReceipt: - if config.Config.GroupMessageHasReadReceiptEnable { - return true, 0, "" - } else { - return false, constant.ErrMessageHasReadDisable.ErrCode, constant.ErrMessageHasReadDisable.ErrMsg - } - } - return true, 0, "" -} - func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (isMute bool, isAdmin bool, err error) { groupMemberInfo, err := rocksCache.GetGroupMemberInfoFromCache(ctx, groupID, userID) if err != nil { @@ -107,7 +89,7 @@ func groupIsMuted(ctx context.Context, groupID string) (bool, error) { return false, nil } -func (rpc *msgServer) messageVerification(ctx context.Context, data *pbChat.SendMsgReq) (bool, int32, string, []string) { +func (rpc *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgReq) ([]string, error) { switch data.MsgData.SessionType { case constant.SingleChatType: if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { @@ -314,12 +296,10 @@ func (rpc *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, false) utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false) case constant.HasReadReceipt: - log.Info("", "this is a test start", msg, msg.Options) utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false) utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false) utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, false) utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false) - log.Info("", "this is a test end", msg, msg.Options) case constant.Typing: utils.SetSwitchFromOptions(msg.Options, constant.IsHistory, false) utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false) @@ -379,11 +359,10 @@ func returnMsg(replay *pbChat.SendMsgResp, pb *pbChat.SendMsgReq, errCode int32, return replay, nil } -func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *pbChat.SendMsgReq) bool { +func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *pbChat.SendMsgReq) (bool, error) { opt, err := db.DB.GetUserGlobalMsgRecvOpt(userID) if err != nil { log.NewError(pb.OperationID, "GetUserGlobalMsgRecvOpt from redis err", userID, pb.String(), err.Error()) - } switch opt { case constant.ReceiveMessage: @@ -538,7 +517,7 @@ func (rpc *msgServer) sendMsgToGroup(ctx context.Context, list []string, pb pbCh wg.Done() } -func (rpc *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []string, groupPB *pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) { +func (rpc *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []string, groupPB *msg.SendMsgReq, sendTag *bool, wg *sync.WaitGroup) { msgToMQGroup := pbChat.MsgDataToMQ{Token: groupPB.Token, OperationID: groupPB.OperationID, MsgData: groupPB.MsgData} tempOptions := make(map[string]bool, 1) for k, v := range groupPB.MsgData.Options { diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index 77b204f7f..8998d2438 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -4,309 +4,265 @@ import ( "Open_IM/pkg/common/constant" promePkg "Open_IM/pkg/common/prometheus" pbConversation "Open_IM/pkg/proto/conversation" - pbChat "Open_IM/pkg/proto/msg" + "Open_IM/pkg/proto/msg" "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" "context" go_redis "github.com/go-redis/redis/v8" + "github.com/golang/protobuf/proto" "strings" "sync" - "time" ) -func (m *msgServer) SendMsg(ctx context.Context, pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) { - replay := pbChat.SendMsgResp{} +func (m *msgServer) sendMsgSuperGroupChat(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, err error) { + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter) + // callback + if err = callbackBeforeSendGroupMsg(req); err != nil { + return nil, err + } - flag, errCode, errMsg := isMessageHasReadEnabled(pb) - if !flag { - return returnMsg(&replay, pb, errCode, errMsg, "", 0) + if _, err = m.messageVerification(ctx, req); err != nil { + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) + return nil, err + } + msgToMQSingle := msg.MsgDataToMQ{MsgData: req.MsgData} + err = m.MsgInterface.MsgToMQ(ctx, msgToMQSingle.MsgData.GroupID, &msgToMQSingle) + if err != nil { + return nil, err } - t1 := time.Now() - m.encapsulateMsgData(pb.MsgData) - log.Debug(pb.OperationID, "encapsulateMsgData ", " cost time: ", time.Since(t1)) - msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData} // callback - t1 = time.Now() - callbackResp := callbackMsgModify(pb) - log.Debug(pb.OperationID, "callbackMsgModify ", callbackResp, "cost time: ", time.Since(t1)) - if callbackResp.ErrCode != 0 { - log.Error(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify resp: ", callbackResp) + if err = callbackAfterSendGroupMsg(req); err != nil { + return nil, err } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackResp: ", callbackResp) - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 - } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify result", "end rpc and return", pb.MsgData) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) + + promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter) + resp.SendTime = msgToMQSingle.MsgData.SendTime + resp.ServerMsgID = msgToMQSingle.MsgData.ServerMsgID + resp.ClientMsgID = msgToMQSingle.MsgData.ClientMsgID + return resp, nil +} +func (m *msgServer) sendMsgNotification(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, err error) { + msgToMQSingle := msg.MsgDataToMQ{MsgData: req.MsgData} + err = m.MsgInterface.MsgToMQ(ctx, msgToMQSingle.MsgData.RecvID, &msgToMQSingle) + if err != nil { + return nil, err } - switch pb.MsgData.SessionType { - case constant.SingleChatType: - promePkg.PromeInc(promePkg.SingleChatMsgRecvSuccessCounter) - // callback - t1 = time.Now() - callbackResp := callbackBeforeSendSingleMsg(pb) - log.Debug(pb.OperationID, "callbackBeforeSendSingleMsg ", " cost time: ", time.Since(t1)) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp) + if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself + err = m.MsgInterface.MsgToMQ(ctx, msgToMQSingle.MsgData.SendID, &msgToMQSingle) + if err != nil { + return nil, err } - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 - } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp) - promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) + } + + resp.SendTime = msgToMQSingle.MsgData.SendTime + resp.ServerMsgID = msgToMQSingle.MsgData.ServerMsgID + resp.ClientMsgID = msgToMQSingle.MsgData.ClientMsgID + return resp, nil +} + +func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, err error) { + promePkg.PromeInc(promePkg.SingleChatMsgRecvSuccessCounter) + if err = callbackBeforeSendSingleMsg(req); err != nil { + return nil, err + } + _, err = m.messageVerification(ctx, req) + if err != nil { + return nil, err + } + isSend, err := modifyMessageByUserMessageReceiveOpt(req.MsgData.RecvID, req.MsgData.SendID, constant.SingleChatType, req) + if err != nil { + return nil, err + } + msgToMQSingle := msg.MsgDataToMQ{MsgData: req.MsgData} + if isSend { + err = m.MsgInterface.MsgToMQ(ctx, req.MsgData.RecvID, &msgToMQSingle) + if err != nil { + return nil, constant.ErrInternalServer.Wrap("insert to mq") } - t1 = time.Now() - flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb) - log.Debug(pb.OperationID, "messageVerification ", flag, " cost time: ", time.Since(t1)) - if !flag { - return returnMsg(&replay, pb, errCode, errMsg, "", 0) + } + if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself + err = m.MsgInterface.MsgToMQ(ctx, req.MsgData.SendID, &msgToMQSingle) + if err != nil { + return nil, constant.ErrInternalServer.Wrap("insert to mq") } - t1 = time.Now() - isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb) - log.Info(pb.OperationID, "modifyMessageByUserMessageReceiveOpt ", " cost time: ", time.Since(t1)) - if isSend { - msgToMQSingle.MsgData = pb.MsgData - log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) - t1 = time.Now() - err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) - log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) - if err1 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err :RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String(), err1.Error()) - promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } + } + err = callbackAfterSendSingleMsg(req) + if err != nil { + return nil, err + } + promePkg.PromeInc(promePkg.SingleChatMsgProcessSuccessCounter) + resp.SendTime = msgToMQSingle.MsgData.SendTime + resp.ServerMsgID = msgToMQSingle.MsgData.ServerMsgID + resp.ClientMsgID = msgToMQSingle.MsgData.ClientMsgID + return resp, nil +} + +func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, err error) { + // callback + promePkg.PromeInc(promePkg.GroupChatMsgRecvSuccessCounter) + err = callbackBeforeSendGroupMsg(req) + if err != nil { + return nil, err + } + + var memberUserIDList []string + if memberUserIDList, err = m.messageVerification(ctx, req); err != nil { + promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) + return nil, err + } + + var addUidList []string + switch req.MsgData.ContentType { + case constant.MemberKickedNotification: + var tips sdkws.TipsComm + var memberKickedTips sdkws.MemberKickedTips + err := proto.Unmarshal(req.MsgData.Content, &tips) + if err != nil { + } - if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself - t1 = time.Now() - err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) - log.Info(pb.OperationID, "sendMsgToWriter ", " cost time: ", time.Since(t1)) - if err2 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) - promePkg.PromeInc(promePkg.SingleChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } + err = proto.Unmarshal(tips.Detail, &memberKickedTips) + if err != nil { + } - // callback - t1 = time.Now() - callbackResp = callbackAfterSendSingleMsg(pb) - log.Info(pb.OperationID, "callbackAfterSendSingleMsg ", " cost time: ", time.Since(t1)) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSingleMsg resp: ", callbackResp) + + for _, v := range memberKickedTips.KickedUserList { + addUidList = append(addUidList, v.UserID) } - promePkg.PromeInc(promePkg.SingleChatMsgProcessSuccessCounter) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) - case constant.GroupChatType: - // callback - promePkg.PromeInc(promePkg.GroupChatMsgRecvSuccessCounter) - callbackResp := callbackBeforeSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg resp:", callbackResp) + case constant.MemberQuitNotification: + addUidList = append(addUidList, req.MsgData.SendID) + + default: + } + if len(addUidList) > 0 { + memberUserIDList = append(memberUserIDList, addUidList...) + } + + //split parallel send + var wg sync.WaitGroup + var sendTag bool + var split = 20 + msgToMQSingle := msg.MsgDataToMQ{MsgData: req.MsgData} + mErr := make(map[string]error, 0) + remain := len(memberUserIDList) % split + for i := 0; i < len(memberUserIDList)/split; i++ { + wg.Add(1) + tmp := valueCopy(req) + go m.sendMsgToGroupOptimization(ctx, memberUserIDList[i*split:(i+1)*split], tmp, &sendTag, &wg) + } + if remain > 0 { + wg.Add(1) + tmp := valueCopy(req) + go m.sendMsgToGroupOptimization(ctx, memberUserIDList[split*(len(memberUserIDList)/split):], tmp, &sendTag, &wg) + } + + wg.Wait() + + // callback + err = callbackAfterSendGroupMsg(req) + if err != nil { + return nil, err + } + + for _, v := range mErr { + if v != nil { + return nil, v } - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 + } + + if req.MsgData.ContentType == constant.AtText { + go func() { + var conversationReq pbConversation.ModifyConversationFieldReq + var tag bool + var atUserID []string + conversation := pbConversation.Conversation{ + OwnerUserID: req.MsgData.SendID, + ConversationID: utils.GetConversationIDBySessionType(pb.MsgData.GroupID, constant.GroupChatType), + ConversationType: constant.GroupChatType, + GroupID: req.MsgData.GroupID, } - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp) - promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) - } - var memberUserIDList []string - if flag, errCode, errMsg, memberUserIDList = rpc.messageVerification(ctx, pb); !flag { - promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, errCode, errMsg, "", 0) - } - log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList, "len: ", len(memberUserIDList)) - var addUidList []string - switch pb.MsgData.ContentType { - case constant.MemberKickedNotification: - var tips sdkws.TipsComm - var memberKickedTips sdkws.MemberKickedTips - err := proto.Unmarshal(pb.MsgData.Content, &tips) + conversationReq.Conversation = &conversation + conversationReq.OperationID = pb.OperationID + conversationReq.FieldType = constant.FieldGroupAtType + tagAll := utils.IsContain(constant.AtAllString, req.MsgData.AtUserIDList) + if tagAll { + atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList) + if len(atUserID) == 0 { //just @everyone + conversationReq.UserIDList = memberUserIDList + conversation.GroupAtType = constant.AtAll + } else { //@Everyone and @other people + conversationReq.UserIDList = atUserID + conversation.GroupAtType = constant.AtAllAtMe + tag = true + } + } else { + conversationReq.UserIDList = req.MsgData.AtUserIDList + conversation.GroupAtType = constant.AtMe + } + etcdConn, err := rpc.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName) if err != nil { - log.Error(pb.OperationID, "Unmarshal err", err.Error()) + errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" + log.NewError(pb.OperationID, errMsg) + return } - err = proto.Unmarshal(tips.Detail, &memberKickedTips) + client := pbConversation.NewConversationClient(etcdConn) + conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) if err != nil { - log.Error(pb.OperationID, "Unmarshal err", err.Error()) + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) + } else if conversationReply.CommonResp.ErrCode != 0 { + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) } - log.Info(pb.OperationID, "data is ", memberKickedTips) - for _, v := range memberKickedTips.KickedUserList { - addUidList = append(addUidList, v.UserID) + if tag { + conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList) + conversation.GroupAtType = constant.AtAll + etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID) + if etcdConn == nil { + errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" + log.NewError(pb.OperationID, errMsg) + return + } + client := pbConversation.NewConversationClient(etcdConn) + conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) + if err != nil { + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) + } else if conversationReply.CommonResp.ErrCode != 0 { + log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) + } } - case constant.MemberQuitNotification: - addUidList = append(addUidList, pb.MsgData.SendID) + }() + } - default: - } - if len(addUidList) > 0 { - memberUserIDList = append(memberUserIDList, addUidList...) - } - m := make(map[string][]string, 2) - m[constant.OnlineStatus] = memberUserIDList - t1 = time.Now() + promePkg.PromeInc(promePkg.GroupChatMsgProcessSuccessCounter) + resp.SendTime = msgToMQSingle.MsgData.SendTime + resp.ServerMsgID = msgToMQSingle.MsgData.ServerMsgID + resp.ClientMsgID = msgToMQSingle.MsgData.ClientMsgID + return resp, nil - //split parallel send - var wg sync.WaitGroup - var sendTag bool - var split = 20 - for k, v := range m { - remain := len(v) % split - for i := 0; i < len(v)/split; i++ { - wg.Add(1) - tmp := valueCopy(pb) - // go rpc.sendMsgToGroup(v[i*split:(i+1)*split], *pb, k, &sendTag, &wg) - go rpc.sendMsgToGroupOptimization(ctx, v[i*split:(i+1)*split], tmp, k, &sendTag, &wg) - } - if remain > 0 { - wg.Add(1) - tmp := valueCopy(pb) - // go rpc.sendMsgToGroup(v[split*(len(v)/split):], *pb, k, &sendTag, &wg) - go rpc.sendMsgToGroupOptimization(ctx, v[split*(len(v)/split):], tmp, k, &sendTag, &wg) - } - } - log.Debug(pb.OperationID, "send msg cost time22 ", time.Since(t1), pb.MsgData.ClientMsgID, "uidList : ", len(addUidList)) - //wg.Add(1) - //go rpc.sendMsgToGroup(addUidList, *pb, constant.OnlineStatus, &sendTag, &wg) - wg.Wait() - t1 = time.Now() - // callback - callbackResp = callbackAfterSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendGroupMsg resp: ", callbackResp) - } - if !sendTag { - log.NewWarn(pb.OperationID, "send tag is ", sendTag) - promePkg.PromeInc(promePkg.GroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } else { - if pb.MsgData.ContentType == constant.AtText { - go func() { - var conversationReq pbConversation.ModifyConversationFieldReq - var tag bool - var atUserID []string - conversation := pbConversation.Conversation{ - OwnerUserID: pb.MsgData.SendID, - ConversationID: utils.GetConversationIDBySessionType(pb.MsgData.GroupID, constant.GroupChatType), - ConversationType: constant.GroupChatType, - GroupID: pb.MsgData.GroupID, - } - conversationReq.Conversation = &conversation - conversationReq.OperationID = pb.OperationID - conversationReq.FieldType = constant.FieldGroupAtType - tagAll := utils.IsContain(constant.AtAllString, pb.MsgData.AtUserIDList) - if tagAll { - atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList) - if len(atUserID) == 0 { //just @everyone - conversationReq.UserIDList = memberUserIDList - conversation.GroupAtType = constant.AtAll - } else { //@Everyone and @other people - conversationReq.UserIDList = atUserID - conversation.GroupAtType = constant.AtAllAtMe - tag = true - } - } else { - conversationReq.UserIDList = pb.MsgData.AtUserIDList - conversation.GroupAtType = constant.AtMe - } - etcdConn, err := rpc.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName) - if err != nil { - errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(pb.OperationID, errMsg) - return - } - client := pbConversation.NewConversationClient(etcdConn) - conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) - if err != nil { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) - } else if conversationReply.CommonResp.ErrCode != 0 { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) - } - if tag { - conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList) - conversation.GroupAtType = constant.AtAll - etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID) - if etcdConn == nil { - errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(pb.OperationID, errMsg) - return - } - client := pbConversation.NewConversationClient(etcdConn) - conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) - if err != nil { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) - } else if conversationReply.CommonResp.ErrCode != 0 { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) - } - } - }() - } - log.Debug(pb.OperationID, "send msg cost time3 ", time.Since(t1), pb.MsgData.ClientMsgID) - promePkg.PromeInc(promePkg.GroupChatMsgProcessSuccessCounter) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) - } +} +func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, error error) { + resp = &msg.SendMsgResp{} + flag := isMessageHasReadEnabled(req.MsgData) + if !flag { + return nil, constant.ErrMessageHasReadDisable.Wrap() + } + m.encapsulateMsgData(req.MsgData) + if err := callbackMsgModify(req); err != nil { + return nil, err + } + switch req.MsgData.SessionType { + case constant.SingleChatType: + return m.sendMsgSingleChat(ctx, req) + case constant.GroupChatType: + return m.sendMsgGroupChat(ctx, req) case constant.NotificationChatType: - t1 = time.Now() - msgToMQSingle.MsgData = pb.MsgData - log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) - err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.RecvID, constant.OnlineStatus) - if err1 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String()) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - - if msgToMQSingle.MsgData.SendID != msgToMQSingle.MsgData.RecvID { //Filter messages sent to yourself - err2 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.SendID, constant.OnlineStatus) - if err2 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:SendID", msgToMQSingle.MsgData.SendID, msgToMQSingle.String()) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - } - - log.Debug(pb.OperationID, "send msg cost time ", time.Since(t1), pb.MsgData.ClientMsgID) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) + return m.sendMsgNotification(ctx, req) case constant.SuperGroupChatType: - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter) - // callback - callbackResp := callbackBeforeSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg resp: ", callbackResp) - } - if callbackResp.ActionCode != constant.ActionAllow { - if callbackResp.ErrCode == 0 { - callbackResp.ErrCode = 201 - } - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSuperGroupMsg result", "end rpc and return", callbackResp) - return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0) - } - if flag, errCode, errMsg, _ = rpc.messageVerification(ctx, pb); !flag { - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, errCode, errMsg, "", 0) - } - msgToMQSingle.MsgData = pb.MsgData - log.NewInfo(msgToMQSingle.OperationID, msgToMQSingle) - err1 := rpc.sendMsgToWriter(ctx, &msgToMQSingle, msgToMQSingle.MsgData.GroupID, constant.OnlineStatus) - if err1 != nil { - log.NewError(msgToMQSingle.OperationID, "kafka send msg err:RecvID", msgToMQSingle.MsgData.RecvID, msgToMQSingle.String()) - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessFailedCounter) - return returnMsg(&replay, pb, 201, "kafka send msg err", "", 0) - } - // callback - callbackResp = callbackAfterSendGroupMsg(pb) - if callbackResp.ErrCode != 0 { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "callbackAfterSendSuperGroupMsg resp: ", callbackResp) - } - promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgProcessSuccessCounter) - return returnMsg(&replay, pb, 0, "", msgToMQSingle.MsgData.ServerMsgID, msgToMQSingle.MsgData.SendTime) - + return m.sendMsgSuperGroupChat(ctx, req) default: - return returnMsg(&replay, pb, 203, "unknown sessionType", "", 0) + return nil, constant.ErrArgs.Wrap("unknown sessionType") } } -func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) { +func (m *msgServer) GetMaxAndMinSeq(_ context.Context, in *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) { log.NewInfo(in.OperationID, "rpc getMaxAndMinSeq is arriving", in.String()) resp := new(sdkws.GetMaxAndMinSeqResp) m := make(map[string]*sdkws.MaxAndMinSeq) diff --git a/internal/rpc/msg/utils.go b/internal/rpc/msg/utils.go index fd0f4e9b3..1bc863994 100644 --- a/internal/rpc/msg/utils.go +++ b/internal/rpc/msg/utils.go @@ -1,16 +1,25 @@ package msg import ( - "Open_IM/pkg/utils" - "github.com/go-redis/redis/v8" - "gorm.io/gorm" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/proto/sdkws" ) -func IsNotFound(err error) bool { - switch utils.Unwrap(err) { - case gorm.ErrRecordNotFound, redis.Nil: - return true - default: - return false +func isMessageHasReadEnabled(msgData *sdkws.MsgData) bool { + switch msgData.ContentType { + case constant.HasReadReceipt: + if config.Config.SingleMessageHasReadReceiptEnable { + return true + } else { + return false + } + case constant.GroupHasReadReceipt: + if config.Config.GroupMessageHasReadReceiptEnable { + return true + } else { + return false + } } + return true } From d2309aab3230f928f071bf50e170c3a3785deb98 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 16:15:16 +0800 Subject: [PATCH 12/48] Error code standardization --- internal/rpc/msg/send_msg.go | 62 ++++++++--------------------------- internal/rpc/msg/send_pull.go | 50 +++++++++++++--------------- 2 files changed, 37 insertions(+), 75 deletions(-) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index dc1f9b481..c1ceb3133 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -7,6 +7,7 @@ import ( rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/log" "Open_IM/pkg/common/tokenverify" + "Open_IM/pkg/common/tracelog" cacheRpc "Open_IM/pkg/proto/cache" "Open_IM/pkg/proto/msg" pbPush "Open_IM/pkg/proto/push" @@ -359,7 +360,7 @@ func returnMsg(replay *pbChat.SendMsgResp, pb *pbChat.SendMsgReq, errCode int32, return replay, nil } -func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *pbChat.SendMsgReq) (bool, error) { +func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *msg.SendMsgReq) (bool, error) { opt, err := db.DB.GetUserGlobalMsgRecvOpt(userID) if err != nil { log.NewError(pb.OperationID, "GetUserGlobalMsgRecvOpt from redis err", userID, pb.String(), err.Error()) @@ -481,44 +482,8 @@ func valueCopy(pb *pbChat.SendMsgReq) *pbChat.SendMsgReq { return &pbChat.SendMsgReq{Token: pb.Token, OperationID: pb.OperationID, MsgData: &msgData} } -func (rpc *msgServer) sendMsgToGroup(ctx context.Context, list []string, pb pbChat.SendMsgReq, status string, sendTag *bool, wg *sync.WaitGroup) { - // log.Debug(pb.OperationID, "split userID ", list) - offlinePushInfo := sdkws.OfflinePushInfo{} - if pb.MsgData.OfflinePushInfo != nil { - offlinePushInfo = *pb.MsgData.OfflinePushInfo - } - msgData := sdkws.MsgData{} - msgData = *pb.MsgData - msgData.OfflinePushInfo = &offlinePushInfo - - groupPB := pbChat.SendMsgReq{Token: pb.Token, OperationID: pb.OperationID, MsgData: &msgData} - msgToMQGroup := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: &msgData} - for _, v := range list { - options := make(map[string]bool, 10) - for key, value := range pb.MsgData.Options { - options[key] = value - } - groupPB.MsgData.RecvID = v - groupPB.MsgData.Options = options - isSend := modifyMessageByUserMessageReceiveOpt(v, msgData.GroupID, constant.GroupChatType, &groupPB) - if isSend { - msgToMQGroup.MsgData = groupPB.MsgData - // log.Debug(groupPB.OperationID, "sendMsgToWriter, ", v, groupID, msgToMQGroup.String()) - err := rpc.sendMsgToWriter(ctx, &msgToMQGroup, v, status) - if err != nil { - log.NewError(msgToMQGroup.OperationID, "kafka send msg err:UserId", v, msgToMQGroup.String()) - } else { - *sendTag = true - } - } else { - log.Debug(groupPB.OperationID, "not sendMsgToWriter, ", v) - } - } - wg.Done() -} - -func (rpc *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []string, groupPB *msg.SendMsgReq, sendTag *bool, wg *sync.WaitGroup) { - msgToMQGroup := pbChat.MsgDataToMQ{Token: groupPB.Token, OperationID: groupPB.OperationID, MsgData: groupPB.MsgData} +func (m *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []string, groupPB *msg.SendMsgReq, wg *sync.WaitGroup) error { + msgToMQGroup := msg.MsgDataToMQ{OperationID: tracelog.GetOperationID(ctx), MsgData: groupPB.MsgData} tempOptions := make(map[string]bool, 1) for k, v := range groupPB.MsgData.Options { tempOptions[k] = v @@ -530,21 +495,22 @@ func (rpc *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []str options[k] = v } groupPB.MsgData.Options = options - isSend := modifyMessageByUserMessageReceiveOpt(v, groupPB.MsgData.GroupID, constant.GroupChatType, groupPB) + isSend, err := modifyMessageByUserMessageReceiveOpt(v, groupPB.MsgData.GroupID, constant.GroupChatType, groupPB) + if err != nil { + wg.Done() + return err + } if isSend { if v == "" || groupPB.MsgData.SendID == "" { - log.Error(msgToMQGroup.OperationID, "sendMsgToGroupOptimization userID nil ", msgToMQGroup.String()) - continue + return constant.ErrArgs.Wrap("userID or groupPB.MsgData.SendID is empty") } - err := rpc.sendMsgToWriter(ctx, &msgToMQGroup, v, status) + err := m.MsgInterface.MsgToMQ(ctx, v, &msgToMQGroup) if err != nil { - log.NewError(msgToMQGroup.OperationID, "kafka send msg err:UserId", v, msgToMQGroup.String()) - } else { - *sendTag = true + wg.Done() + return err } - } else { - log.Debug(groupPB.OperationID, "not sendMsgToWriter, ", v) } } wg.Done() + return nil } diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index 8998d2438..1900cbe85 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -10,7 +10,6 @@ import ( "context" go_redis "github.com/go-redis/redis/v8" "github.com/golang/protobuf/proto" - "strings" "sync" ) @@ -142,12 +141,21 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( var sendTag bool var split = 20 msgToMQSingle := msg.MsgDataToMQ{MsgData: req.MsgData} - mErr := make(map[string]error, 0) + mErr := make([]error, 0) + var mutex sync.RWMutex remain := len(memberUserIDList) % split for i := 0; i < len(memberUserIDList)/split; i++ { wg.Add(1) tmp := valueCopy(req) - go m.sendMsgToGroupOptimization(ctx, memberUserIDList[i*split:(i+1)*split], tmp, &sendTag, &wg) + go func() { + err := m.sendMsgToGroupOptimization(ctx, memberUserIDList[i*split:(i+1)*split], tmp, &sendTag, &wg) + if err != nil { + mutex.Lock() + mErr = append(mErr, err) + mutex.Unlock() + } + + }() } if remain > 0 { wg.Add(1) @@ -176,16 +184,15 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( var atUserID []string conversation := pbConversation.Conversation{ OwnerUserID: req.MsgData.SendID, - ConversationID: utils.GetConversationIDBySessionType(pb.MsgData.GroupID, constant.GroupChatType), + ConversationID: utils.GetConversationIDBySessionType(req.MsgData.GroupID, constant.GroupChatType), ConversationType: constant.GroupChatType, GroupID: req.MsgData.GroupID, } conversationReq.Conversation = &conversation - conversationReq.OperationID = pb.OperationID conversationReq.FieldType = constant.FieldGroupAtType tagAll := utils.IsContain(constant.AtAllString, req.MsgData.AtUserIDList) if tagAll { - atUserID = utils.DifferenceString([]string{constant.AtAllString}, pb.MsgData.AtUserIDList) + atUserID = utils.DifferenceString([]string{constant.AtAllString}, req.MsgData.AtUserIDList) if len(atUserID) == 0 { //just @everyone conversationReq.UserIDList = memberUserIDList conversation.GroupAtType = constant.AtAll @@ -198,46 +205,35 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( conversationReq.UserIDList = req.MsgData.AtUserIDList conversation.GroupAtType = constant.AtMe } - etcdConn, err := rpc.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName) + + _, err := m.ModifyConversationField(context.Background(), &conversationReq) if err != nil { - errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(pb.OperationID, errMsg) return } - client := pbConversation.NewConversationClient(etcdConn) - conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) - if err != nil { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) - } else if conversationReply.CommonResp.ErrCode != 0 { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) - } + if tag { conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList) conversation.GroupAtType = constant.AtAll - etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, pb.OperationID) - if etcdConn == nil { - errMsg := pb.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(pb.OperationID, errMsg) - return - } - client := pbConversation.NewConversationClient(etcdConn) - conversationReply, err := client.ModifyConversationField(context.Background(), &conversationReq) + _, err := m.ModifyConversationField(context.Background(), &conversationReq) if err != nil { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), err.Error()) - } else if conversationReply.CommonResp.ErrCode != 0 { - log.NewError(conversationReq.OperationID, "ModifyConversationField rpc failed, ", conversationReq.String(), conversationReply.String()) + return } } }() } + // promePkg.PromeInc(promePkg.GroupChatMsgProcessSuccessCounter) resp.SendTime = msgToMQSingle.MsgData.SendTime resp.ServerMsgID = msgToMQSingle.MsgData.ServerMsgID resp.ClientMsgID = msgToMQSingle.MsgData.ClientMsgID return resp, nil +} + +func (m *msgServer) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) { } + func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, error error) { resp = &msg.SendMsgResp{} flag := isMessageHasReadEnabled(req.MsgData) From b607cc806a51e849a139806937fa07f12067d0ae Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 16:16:47 +0800 Subject: [PATCH 13/48] Error code standardization --- internal/rpc/msg/send_msg.go | 11 +---------- internal/rpc/msg/send_pull.go | 5 ++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index c1ceb3133..3d0fce02c 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -351,19 +351,10 @@ func GetMsgID(sendID string) string { return utils.Md5(t + "-" + sendID + "-" + strconv.Itoa(rand.Int())) } -func returnMsg(replay *pbChat.SendMsgResp, pb *pbChat.SendMsgReq, errCode int32, errMsg, serverMsgID string, sendTime int64) (*pbChat.SendMsgResp, error) { - replay.ErrCode = errCode - replay.ErrMsg = errMsg - replay.ServerMsgID = serverMsgID - replay.ClientMsgID = pb.MsgData.ClientMsgID - replay.SendTime = sendTime - return replay, nil -} - func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *msg.SendMsgReq) (bool, error) { opt, err := db.DB.GetUserGlobalMsgRecvOpt(userID) if err != nil { - log.NewError(pb.OperationID, "GetUserGlobalMsgRecvOpt from redis err", userID, pb.String(), err.Error()) + return false, err } switch opt { case constant.ReceiveMessage: diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index 1900cbe85..d08fd9d50 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -138,7 +138,6 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( //split parallel send var wg sync.WaitGroup - var sendTag bool var split = 20 msgToMQSingle := msg.MsgDataToMQ{MsgData: req.MsgData} mErr := make([]error, 0) @@ -148,7 +147,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( wg.Add(1) tmp := valueCopy(req) go func() { - err := m.sendMsgToGroupOptimization(ctx, memberUserIDList[i*split:(i+1)*split], tmp, &sendTag, &wg) + err := m.sendMsgToGroupOptimization(ctx, memberUserIDList[i*split:(i+1)*split], tmp, &wg) if err != nil { mutex.Lock() mErr = append(mErr, err) @@ -160,7 +159,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( if remain > 0 { wg.Add(1) tmp := valueCopy(req) - go m.sendMsgToGroupOptimization(ctx, memberUserIDList[split*(len(memberUserIDList)/split):], tmp, &sendTag, &wg) + go m.sendMsgToGroupOptimization(ctx, memberUserIDList[split*(len(memberUserIDList)/split):], tmp, &wg) } wg.Wait() From 7414c20dd2a299c71e361ad75d69548d62563416 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 16:17:52 +0800 Subject: [PATCH 14/48] Error code standardization --- internal/rpc/msg/send_msg.go | 47 ++---------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 3d0fce02c..b9f81ff81 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -11,14 +11,12 @@ import ( cacheRpc "Open_IM/pkg/proto/cache" "Open_IM/pkg/proto/msg" pbPush "Open_IM/pkg/proto/push" - pbRelay "Open_IM/pkg/proto/relay" sdkws "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" "errors" "math/rand" "strconv" - "strings" "sync" "time" @@ -415,48 +413,7 @@ func modifyMessageByUserMessageReceiveOptoptimization(userID, sourceID string, s return true } -func getOnlineAndOfflineUserIDList(memberList []string, m map[string][]string, operationID string) { - var onllUserIDList, offlUserIDList []string - var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult - req := &pbRelay.GetUsersOnlineStatusReq{} - req.UserIDList = memberList - req.OperationID = operationID - req.OpUserID = config.Config.Manager.AppManagerUid[0] - flag := false - grpcCons := rpc.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), operationID) - for _, v := range grpcCons { - client := pbRelay.NewRelayClient(v) - reply, err := client.GetUsersOnlineStatus(context.Background(), req) - if err != nil { - log.NewError(operationID, "GetUsersOnlineStatus rpc err", req.String(), err.Error()) - continue - } else { - if reply.ErrCode == 0 { - wsResult = append(wsResult, reply.SuccessResult...) - } - } - } - log.NewInfo(operationID, "call GetUsersOnlineStatus rpc server is success", wsResult) - //Online data merge of each node - for _, v1 := range memberList { - flag = false - - for _, v2 := range wsResult { - if v2.UserID == v1 { - flag = true - onllUserIDList = append(onllUserIDList, v1) - } - - } - if !flag { - offlUserIDList = append(offlUserIDList, v1) - } - } - m[constant.OnlineStatus] = onllUserIDList - m[constant.OfflineStatus] = offlUserIDList -} - -func valueCopy(pb *pbChat.SendMsgReq) *pbChat.SendMsgReq { +func valueCopy(pb *msg.SendMsgReq) *msg.SendMsgReq { offlinePushInfo := sdkws.OfflinePushInfo{} if pb.MsgData.OfflinePushInfo != nil { offlinePushInfo = *pb.MsgData.OfflinePushInfo @@ -470,7 +427,7 @@ func valueCopy(pb *pbChat.SendMsgReq) *pbChat.SendMsgReq { options[key] = value } msgData.Options = options - return &pbChat.SendMsgReq{Token: pb.Token, OperationID: pb.OperationID, MsgData: &msgData} + return &msg.SendMsgReq{MsgData: &msgData} } func (m *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []string, groupPB *msg.SendMsgReq, wg *sync.WaitGroup) error { From 8fd81edc44fefa0635840a864b5bfd0ef3c4cb10 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 16:18:38 +0800 Subject: [PATCH 15/48] Error code standardization --- internal/rpc/msg/send_msg.go | 58 ------------------------------------ 1 file changed, 58 deletions(-) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index b9f81ff81..e12f4440a 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -10,7 +10,6 @@ import ( "Open_IM/pkg/common/tracelog" cacheRpc "Open_IM/pkg/proto/cache" "Open_IM/pkg/proto/msg" - pbPush "Open_IM/pkg/proto/push" sdkws "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" @@ -310,40 +309,6 @@ func (rpc *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { } } -func (rpc *msgServer) sendMsgToWriter(ctx context.Context, m *pbChat.MsgDataToMQ, key string, status string) error { - switch status { - case constant.OnlineStatus: - if m.MsgData.ContentType == constant.SignalingNotification { - rpcPushMsg := pbPush.PushMsgReq{OperationID: m.OperationID, MsgData: m.MsgData, PushToUserID: key} - grpcConn, err := rpc.GetConn(ctx, config.Config.RpcRegisterName.OpenImPushName) - if err != nil { - return err - } - msgClient := pbPush.NewPushMsgServiceClient(grpcConn) - _, err = msgClient.PushMsg(context.Background(), &rpcPushMsg) - if err != nil { - log.Error(rpcPushMsg.OperationID, "rpc send failed", rpcPushMsg.OperationID, "push data", rpcPushMsg.String(), "err", err.Error()) - return err - } else { - return nil - } - } - pid, offset, err := rpc.messageWriter.SendMessage(m, key, m.OperationID) - if err != nil { - log.Error(m.OperationID, "kafka send failed", "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key, status) - } else { - // log.NewWarn(m.OperationID, "sendMsgToWriter client msgID ", m.MsgData.ClientMsgID) - } - return err - case constant.OfflineStatus: - pid, offset, err := rpc.messageWriter.SendMessage(m, key, m.OperationID) - if err != nil { - log.Error(m.OperationID, "kafka send failed", "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key, status) - } - return err - } - return errors.New("status error") -} func GetMsgID(sendID string) string { t := time.Now().Format("2006-01-02 15:04:05") return utils.Md5(t + "-" + sendID + "-" + strconv.Itoa(rand.Int())) @@ -390,29 +355,6 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i return true } -func modifyMessageByUserMessageReceiveOptoptimization(userID, sourceID string, sessionType int, operationID string, options *map[string]bool) bool { - conversationID := utils.GetConversationIDBySessionType(sourceID, sessionType) - opt, err := db.DB.GetSingleConversationRecvMsgOpt(userID, conversationID) - if err != nil && err != go_redis.Nil { - log.NewError(operationID, "GetSingleConversationMsgOpt from redis err", userID, conversationID, err.Error()) - return true - } - - switch opt { - case constant.ReceiveMessage: - return true - case constant.NotReceiveMessage: - return false - case constant.ReceiveNotNotifyMessage: - if *options == nil { - *options = make(map[string]bool, 10) - } - utils.SetSwitchFromOptions(*options, constant.IsOfflinePush, false) - return true - } - return true -} - func valueCopy(pb *msg.SendMsgReq) *msg.SendMsgReq { offlinePushInfo := sdkws.OfflinePushInfo{} if pb.MsgData.OfflinePushInfo != nil { From 884d28b9a82eecf61473f92728ab1f5d7ff494ed Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 13 Feb 2023 16:36:05 +0800 Subject: [PATCH 16/48] msg send pull --- internal/rpc/msg/send_pull.go | 176 +++++++++++++++++--------------- pkg/common/db/controller/msg.go | 6 ++ 2 files changed, 99 insertions(+), 83 deletions(-) diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index 8998d2438..480603da9 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -8,7 +8,6 @@ import ( "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" - go_redis "github.com/go-redis/redis/v8" "github.com/golang/protobuf/proto" "strings" "sync" @@ -262,98 +261,109 @@ func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg } } -func (m *msgServer) GetMaxAndMinSeq(_ context.Context, in *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) { - log.NewInfo(in.OperationID, "rpc getMaxAndMinSeq is arriving", in.String()) +func (m *msgServer) GetMaxAndMinSeq(ctx context.Context, req *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) { resp := new(sdkws.GetMaxAndMinSeqResp) - m := make(map[string]*sdkws.MaxAndMinSeq) - var maxSeq, minSeq uint64 - var err1, err2 error - maxSeq, err1 = commonDB.DB.GetUserMaxSeq(in.UserID) - minSeq, err2 = commonDB.DB.GetUserMinSeq(in.UserID) - if (err1 != nil && err1 != go_redis.Nil) || (err2 != nil && err2 != go_redis.Nil) { - log.NewError(in.OperationID, "getMaxSeq from redis error", in.String()) - if err1 != nil { - log.NewError(in.OperationID, utils.GetSelfFuncName(), err1.Error()) - } - if err2 != nil { - log.NewError(in.OperationID, utils.GetSelfFuncName(), err2.Error()) - } - resp.ErrCode = 200 - resp.ErrMsg = "redis get err" - return resp, nil + m2 := make(map[string]*sdkws.MaxAndMinSeq) + maxSeq, err := m.MsgInterface.GetUserMaxSeq(ctx, req.UserID) + if err != nil { + return nil, err + } + minSeq, err := m.MsgInterface.GetUserMinSeq(ctx, req.UserID) + if err != nil { + return nil, err } - resp.MaxSeq = uint32(maxSeq) - resp.MinSeq = uint32(minSeq) - for _, groupID := range in.GroupIDList { - x := new(sdkws.MaxAndMinSeq) - maxSeq, _ := commonDB.DB.GetGroupMaxSeq(groupID) - minSeq, _ := commonDB.DB.GetGroupUserMinSeq(groupID, in.UserID) - x.MaxSeq = uint32(maxSeq) - x.MinSeq = uint32(minSeq) - m[groupID] = x + resp.MaxSeq = maxSeq + resp.MinSeq = minSeq + if len(req.GroupIDList) > 0 { + resp.GroupMaxAndMinSeq = make(map[string]*sdkws.MaxAndMinSeq) + for _, groupID := range req.GroupIDList { + maxSeq, err := m.MsgInterface.GetGroupMaxSeq(ctx, groupID) + if err != nil { + return nil, err + } + minSeq, err := m.MsgInterface.GetGroupMinSeq(ctx, groupID) + if err != nil { + return nil, err + } + m2[groupID] = &sdkws.MaxAndMinSeq{ + MaxSeq: maxSeq, + MinSeq: minSeq, + } + } } - resp.GroupMaxAndMinSeq = m return resp, nil } -func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *sdkws.PullMessageBySeqListReq) (*sdkws.PullMessageBySeqListResp, error) { - log.NewInfo(in.OperationID, "rpc PullMessageBySeqList is arriving", in.String()) - resp := new(sdkws.PullMessageBySeqListResp) - m := make(map[string]*sdkws.MsgDataList) - redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(in.UserID, in.SeqList, in.OperationID) +func (m *msgServer) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqListReq) (*sdkws.PullMessageBySeqListResp, error) { + resp := &sdkws.PullMessageBySeqListResp{GroupMsgDataList: make(map[string]*sdkws.MsgDataList)} + msgs, err := m.MsgInterface.GetMessageListBySeq(ctx, req.UserID, req.SeqList) if err != nil { - if err != go_redis.Nil { - promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList) - } else { - log.Debug(in.OperationID, "get message from redis is nil", failedSeqList) - } - msgList, err1 := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, failedSeqList, in.OperationID) - if err1 != nil { - promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error()) - resp.ErrCode = 201 - resp.ErrMsg = err1.Error() - return resp, nil - } else { - promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - redisMsgList = append(redisMsgList, msgList...) - resp.List = redisMsgList - } - } else { - promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - resp.List = redisMsgList + return nil, err } - - for k, v := range in.GroupSeqList { - x := new(sdkws.MsgDataList) - redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(k, v.SeqList, in.OperationID) + resp.List = msgs + for userID, list := range req.GroupSeqList { + msgs, err := m.MsgInterface.GetMessageListBySeq(ctx, userID, list.SeqList) if err != nil { - if err != go_redis.Nil { - promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList) - } else { - log.Debug(in.OperationID, "get message from redis is nil", failedSeqList) - } - msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, in.OperationID) - if err1 != nil { - promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err1.Error()) - resp.ErrCode = 201 - resp.ErrMsg = err1.Error() - return resp, nil - } else { - promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - redisMsgList = append(redisMsgList, msgList...) - x.MsgDataList = redisMsgList - m[k] = x - } - } else { - promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - x.MsgDataList = redisMsgList - m[k] = x + return nil, err + } + resp.GroupMsgDataList[userID] = &sdkws.MsgDataList{ + MsgDataList: msgs, } } - resp.GroupMsgDataList = m + + //redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(req.UserID, req.SeqList, req.OperationID) + //if err != nil { + // if err != go_redis.Nil { + // promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) + // log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList) + // } else { + // log.Debug(req.OperationID, "get message from redis is nil", failedSeqList) + // } + // msgList, err1 := commonDB.DB.GetMsgBySeqListMongo2(req.UserID, failedSeqList, req.OperationID) + // if err1 != nil { + // promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) + // log.Error(req.OperationID, "PullMessageBySeqList data error", req.String(), err1.Error()) + // resp.ErrCode = 201 + // resp.ErrMsg = err1.Error() + // return resp, nil + // } else { + // promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) + // redisMsgList = append(redisMsgList, msgList...) + // resp.List = redisMsgList + // } + //} else { + // promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) + // resp.List = redisMsgList + //} + // + //for k, v := range req.GroupSeqList { + // x := new(sdkws.MsgDataList) + // redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(k, v.SeqList, req.OperationID) + // if err != nil { + // if err != go_redis.Nil { + // promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) + // log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList) + // } else { + // log.Debug(req.OperationID, "get message from redis is nil", failedSeqList) + // } + // msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, req.OperationID) + // if err1 != nil { + // promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) + // log.Error(req.OperationID, "PullMessageBySeqList data error", req.String(), err1.Error()) + // resp.ErrCode = 201 + // resp.ErrMsg = err1.Error() + // return resp, nil + // } else { + // promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) + // redisMsgList = append(redisMsgList, msgList...) + // x.MsgDataList = redisMsgList + // m[k] = x + // } + // } else { + // promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) + // x.MsgDataList = redisMsgList + // m[k] = x + // } + //} return resp, nil } diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index 3445e8dd1..cf10162cc 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -3,6 +3,7 @@ package controller import ( "Open_IM/pkg/proto/msg" pbMsg "Open_IM/pkg/proto/msg" + "Open_IM/pkg/proto/sdkws" "context" ) @@ -25,8 +26,13 @@ type MsgInterface interface { // delete DelMsgFromCache(ctx context.Context, userID string, seqs []uint32) error GetGroupMaxSeq(ctx context.Context, groupID string) (uint32, error) + GetGroupMinSeq(ctx context.Context, groupID string) (uint32, error) SetGroupUserMinSeq(ctx context.Context, groupID string, seq uint32) error DelUserAllSeq(ctx context.Context, userID string) error // redis and mongodb + GetUserMaxSeq(ctx context.Context, userID string) (uint32, error) + GetUserMinSeq(ctx context.Context, userID string) (uint32, error) + + GetMessageListBySeq(ctx context.Context, userID string, seqs []uint32) ([]*sdkws.MsgData, error) } type MsgDatabaseInterface interface { From 048d4b83e125adf15f637b4696e7d85d8cd16e19 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 13 Feb 2023 17:44:22 +0800 Subject: [PATCH 17/48] rpc start --- cmd/rpc/group/main.go | 34 ++--- internal/rpc/group/group.go | 206 ++++++++++++++++-------------- internal/startrpc/start.go | 66 ++++++++++ pkg/common/db/cache/redis.go | 6 + pkg/common/db/unrelation/mongo.go | 6 + 5 files changed, 206 insertions(+), 112 deletions(-) create mode 100644 internal/startrpc/start.go diff --git a/cmd/rpc/group/main.go b/cmd/rpc/group/main.go index 8a5f26cfd..ad9ba151c 100644 --- a/cmd/rpc/group/main.go +++ b/cmd/rpc/group/main.go @@ -2,25 +2,25 @@ package main import ( "Open_IM/internal/rpc/group" + "Open_IM/internal/startrpc" "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - promePkg "Open_IM/pkg/common/prometheus" - "flag" - "fmt" ) func main() { - defaultPorts := config.Config.RpcPort.OpenImGroupPort - rpcPort := flag.Int("port", defaultPorts[0], "get RpcGroupPort from cmd,default 16000 as port") - prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.GroupPrometheusPort[0], "groupPrometheusPort default listen port") - flag.Parse() - fmt.Println("start group rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n") - rpcServer := group.NewGroupServer(*rpcPort) - go func() { - err := promePkg.StartPromeSrv(*prometheusPort) - if err != nil { - panic(err) - } - }() - rpcServer.Run() + //defaultPorts := config.Config.RpcPort.OpenImGroupPort + //rpcPort := flag.Int("port", defaultPorts[0], "get RpcGroupPort from cmd,default 16000 as port") + //prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.GroupPrometheusPort[0], "groupPrometheusPort default listen port") + //flag.Parse() + //fmt.Println("start group rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n") + //rpcServer := group.NewGroupServer(*rpcPort) + //go func() { + // err := promePkg.StartPromeSrv(*prometheusPort) + // if err != nil { + // panic(err) + // } + //}() + //rpcServer.Run() + + startrpc.StartRpc(config.Config.RpcPort.OpenImGroupPort[0], config.Config.RpcRegisterName.OpenImGroupName, config.Config.Prometheus.GroupPrometheusPort[0], group.Start) + } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 397c5fc63..85119fd82 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -2,18 +2,13 @@ package group import ( "Open_IM/internal/common/check" - "Open_IM/internal/common/network" chat "Open_IM/internal/rpc/msg" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/controller" "Open_IM/pkg/common/db/relation" relationTb "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/db/unrelation" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/middleware" - promePkg "Open_IM/pkg/common/prometheus" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" discoveryRegistry "Open_IM/pkg/discoveryregistry" @@ -22,107 +17,128 @@ import ( "Open_IM/pkg/utils" "context" "fmt" - grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "google.golang.org/grpc" "gorm.io/gorm" "math/big" "math/rand" - "net" "strconv" "strings" "time" - - "github.com/OpenIMSDK/openKeeper" - "google.golang.org/grpc" ) -type groupServer struct { - rpcPort int - rpcRegisterName string - schema string - zkAddr []string - GroupInterface controller.GroupInterface - registerCenter discoveryRegistry.SvcDiscoveryRegistry - user *check.UserCheck +func Start(server *grpc.Server) { + //err := mysql.InitConn().AutoMigrateModel(&groupModel) + //if err != nil { + // panic("db init err:" + err.Error()) + //} + //mongo.InitMongo() + //redis.InitRedis() + pbGroup.RegisterGroupServer(server, &groupServer{ + GroupInterface: controller.NewGroupInterface(nil, cache.NewRedis().GetClient(), unrelation.NewMongo().GetClient()), + registerCenter: nil, + user: check.NewUserCheck(), + }) } -func NewGroupServer(port int) *groupServer { - log.NewPrivateLog(constant.LogFileName) - g := groupServer{ - rpcPort: port, - rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName, - schema: config.Config.Zookeeper.Schema, - zkAddr: config.Config.Zookeeper.ZkAddr, - } - //mysql init - var mysql relation.Mysql - var mongo unrelation.Mongo - var groupModel relationTb.GroupModel - var redis cache.RedisClient - err := mysql.InitConn().AutoMigrateModel(&groupModel) - if err != nil { - panic("db init err:" + err.Error()) - } - mongo.InitMongo() - redis.InitRedis() - mongo.CreateSuperGroupIndex() - zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, 10, "", "") - if err != nil { - panic(err.Error()) - } - registerIP, err := network.GetRpcRegisterIP(config.Config.RpcRegisterIP) - g.registerCenter = zkClient - err = g.registerCenter.Register(config.Config.RpcRegisterName.OpenImGroupName, registerIP, port) - if err != nil { - panic(err.Error()) - } - - //conns, err := g.registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName) - g.GroupInterface = controller.NewGroupInterface(mysql.GormConn(), redis.GetClient(), mongo.GetClient()) - g.user = check.NewUserCheck() - return &g +type groupServer struct { + //rpcPort int + //rpcRegisterName string + //schema string + //zkAddr []string + GroupInterface controller.GroupInterface + registerCenter discoveryRegistry.SvcDiscoveryRegistry + user *check.UserCheck } -func (s *groupServer) Run() { - operationID := utils.OperationIDGenerator() - log.NewInfo(operationID, "group rpc start ") - address := network.GetListenIP(config.Config.ListenIP) + ":" + strconv.Itoa(s.rpcPort) - //listener network - listener, err := net.Listen("tcp", address) - if err != nil { - panic("listening err:" + err.Error() + s.rpcRegisterName) - } - log.NewInfo(operationID, "listen network success, ", address, listener) - - defer listener.Close() - //grpc server - recvSize := 1024 * 1024 * constant.GroupRPCRecvSize - sendSize := 1024 * 1024 * constant.GroupRPCSendSize - var grpcOpts = []grpc.ServerOption{ - grpc.MaxRecvMsgSize(recvSize), - grpc.MaxSendMsgSize(sendSize), - grpc.UnaryInterceptor(middleware.RpcServerInterceptor), - } - if config.Config.Prometheus.Enable { - promePkg.NewGrpcRequestCounter() - promePkg.NewGrpcRequestFailedCounter() - promePkg.NewGrpcRequestSuccessCounter() - grpcOpts = append(grpcOpts, []grpc.ServerOption{ - // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), - grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), - grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), - }...) - } - srv := grpc.NewServer(grpcOpts...) - defer srv.GracefulStop() - //Service registers with etcd - pbGroup.RegisterGroupServer(srv, s) - err = srv.Serve(listener) - if err != nil { - log.NewError(operationID, "Serve failed ", err.Error()) - return - } - log.NewInfo(operationID, "group rpc success") -} +// +//type groupServer struct { +// rpcPort int +// rpcRegisterName string +// schema string +// zkAddr []string +// GroupInterface controller.GroupInterface +// registerCenter discoveryRegistry.SvcDiscoveryRegistry +// user *check.UserCheck +//} +// +//func NewGroupServer(port int) *groupServer { +// log.NewPrivateLog(constant.LogFileName) +// g := groupServer{ +// rpcPort: port, +// rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName, +// schema: config.Config.Zookeeper.Schema, +// zkAddr: config.Config.Zookeeper.ZkAddr, +// } +// //mysql init +// var mysql relation.Mysql +// var mongo unrelation.Mongo +// var groupModel relationTb.GroupModel +// var redis cache.RedisClient +// err := mysql.InitConn().AutoMigrateModel(&groupModel) +// if err != nil { +// panic("db init err:" + err.Error()) +// } +// mongo.InitMongo() +// redis.InitRedis() +// mongo.CreateSuperGroupIndex() +// zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, 10, "", "") +// if err != nil { +// panic(err.Error()) +// } +// registerIP, err := network.GetRpcRegisterIP(config.Config.RpcRegisterIP) +// g.registerCenter = zkClient +// err = g.registerCenter.Register(config.Config.RpcRegisterName.OpenImGroupName, registerIP, port) +// if err != nil { +// panic(err.Error()) +// } +// +// //conns, err := g.registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName) +// g.GroupInterface = controller.NewGroupInterface(mysql.GormConn(), redis.GetClient(), mongo.GetClient()) +// g.user = check.NewUserCheck() +// return &g +//} +// +//func (s *groupServer) Run() { +// operationID := utils.OperationIDGenerator() +// log.NewInfo(operationID, "group rpc start ") +// address := network.GetListenIP(config.Config.ListenIP) + ":" + strconv.Itoa(s.rpcPort) +// //listener network +// listener, err := net.Listen("tcp", address) +// if err != nil { +// panic("listening err:" + err.Error() + s.rpcRegisterName) +// } +// log.NewInfo(operationID, "listen network success, ", address, listener) +// +// defer listener.Close() +// //grpc server +// recvSize := 1024 * 1024 * constant.GroupRPCRecvSize +// sendSize := 1024 * 1024 * constant.GroupRPCSendSize +// var grpcOpts = []grpc.ServerOption{ +// grpc.MaxRecvMsgSize(recvSize), +// grpc.MaxSendMsgSize(sendSize), +// grpc.UnaryInterceptor(middleware.RpcServerInterceptor), +// } +// if config.Config.Prometheus.Enable { +// promePkg.NewGrpcRequestCounter() +// promePkg.NewGrpcRequestFailedCounter() +// promePkg.NewGrpcRequestSuccessCounter() +// grpcOpts = append(grpcOpts, []grpc.ServerOption{ +// // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), +// grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), +// grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), +// }...) +// } +// srv := grpc.NewServer(grpcOpts...) +// defer srv.GracefulStop() +// //Service registers with etcd +// pbGroup.RegisterGroupServer(srv, s) +// err = srv.Serve(listener) +// if err != nil { +// log.NewError(operationID, "Serve failed ", err.Error()) +// return +// } +// log.NewInfo(operationID, "group rpc success") +//} func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error { if !tokenverify.IsAppManagerUid(ctx) { @@ -145,7 +161,7 @@ func (s *groupServer) GetUsernameMap(ctx context.Context, userIDs []string, comp if err != nil { return nil, err } - return utils.SliceToMapAny(users, func(e *open_im_sdk.PublicUserInfo) (string, string) { + return utils.SliceToMapAny(users, func(e *sdkws.PublicUserInfo) (string, string) { return e.UserID, e.Nickname }), nil } diff --git a/internal/startrpc/start.go b/internal/startrpc/start.go new file mode 100644 index 000000000..841ee3cbc --- /dev/null +++ b/internal/startrpc/start.go @@ -0,0 +1,66 @@ +package startrpc + +import ( + "Open_IM/internal/common/network" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/log" + "Open_IM/pkg/common/middleware" + promePkg "Open_IM/pkg/common/prometheus" + "flag" + "fmt" + "github.com/OpenIMSDK/openKeeper" + grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "google.golang.org/grpc" + "net" +) + +func StartRpc(rpcPort int, rpcRegisterName string, prometheusPort int, fn func(server *grpc.Server), options ...grpc.ServerOption) { + flagRpcPort := flag.Int("port", rpcPort, "get RpcGroupPort from cmd,default 16000 as port") + flagPrometheusPort := flag.Int("prometheus_port", prometheusPort, "groupPrometheusPort default listen port") + flag.Parse() + rpcPort = *flagRpcPort + prometheusPort = *flagPrometheusPort + fmt.Println("start group rpc server, port: ", rpcPort, ", OpenIM version: ", constant.CurrentVersion) + log.NewPrivateLog(constant.LogFileName) + listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, rpcPort)) + if err != nil { + panic(err) + } + defer listener.Close() + zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, 10, "", "") + if err != nil { + panic(err.Error()) + } + registerIP, err := network.GetRpcRegisterIP(config.Config.RpcRegisterIP) + if err != nil { + panic(err) + } + options = append(options, grpc.UnaryInterceptor(middleware.RpcServerInterceptor)) // ctx 中间件 + if config.Config.Prometheus.Enable { + promePkg.NewGrpcRequestCounter() + promePkg.NewGrpcRequestFailedCounter() + promePkg.NewGrpcRequestSuccessCounter() + options = append(options, []grpc.ServerOption{ + // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), + grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), + grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), + }...) + } + srv := grpc.NewServer(options...) + defer srv.GracefulStop() + fn(srv) + err = zkClient.Register(rpcRegisterName, registerIP, rpcPort) + if err != nil { + panic(err.Error()) + } + if config.Config.Prometheus.Enable { + err := promePkg.StartPromeSrv(prometheusPort) + if err != nil { + panic(err) + } + } + if err := srv.Serve(listener); err != nil { + panic(err) + } +} diff --git a/pkg/common/db/cache/redis.go b/pkg/common/db/cache/redis.go index 82523eb0f..fbafdd83e 100644 --- a/pkg/common/db/cache/redis.go +++ b/pkg/common/db/cache/redis.go @@ -50,6 +50,12 @@ type Cache interface { // native redis operate +func NewRedis() *RedisClient { + o := &RedisClient{} + o.InitRedis() + return o +} + type RedisClient struct { rdb redis.UniversalClient } diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go index 75ae8c1b5..7500214ae 100644 --- a/pkg/common/db/unrelation/mongo.go +++ b/pkg/common/db/unrelation/mongo.go @@ -13,6 +13,12 @@ import ( "time" ) +func NewMongo() *Mongo { + mgo := &Mongo{} + mgo.InitMongo() + return mgo +} + type Mongo struct { db *mongo.Client } From a9dec0c8329ad4a6073479e4870902989d0c970d Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 17:48:01 +0800 Subject: [PATCH 18/48] Error code standardization --- internal/rpc/msg/send_msg.go | 299 ++++++++++++++++------------------ pkg/common/constant/errors.go | 12 ++ 2 files changed, 155 insertions(+), 156 deletions(-) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index e12f4440a..f2c0ee3a4 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -3,23 +3,15 @@ package msg import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db" - rocksCache "Open_IM/pkg/common/db/rocks_cache" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" - cacheRpc "Open_IM/pkg/proto/cache" "Open_IM/pkg/proto/msg" sdkws "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" - "errors" "math/rand" "strconv" "sync" "time" - - go_redis "github.com/go-redis/redis/v8" ) var ( @@ -64,203 +56,180 @@ type MsgCallBackResp struct { } } -func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (isMute bool, isAdmin bool, err error) { - groupMemberInfo, err := rocksCache.GetGroupMemberInfoFromCache(ctx, groupID, userID) +func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (isMute bool, err error) { + groupMemberInfo, err := GetGroupMemberInfo(ctx, groupID, userID) if err != nil { - return false, false, utils.Wrap(err, "") + return false, err } - - if groupMemberInfo.MuteEndTime.Unix() >= time.Now().Unix() { - return true, groupMemberInfo.RoleLevel > constant.GroupOrdinaryUsers, nil + if groupMemberInfo.MuteEndTime >= time.Now().Unix() { + return true, nil } - return false, groupMemberInfo.RoleLevel > constant.GroupOrdinaryUsers, nil + return false, nil } -func groupIsMuted(ctx context.Context, groupID string) (bool, error) { - groupInfo, err := rocksCache.GetGroupInfoFromCache(ctx, groupID) +// 如果禁言了,再看下是否群管理员 +func groupIsMuted(ctx context.Context, groupID string, userID string) (bool, bool, error) { + groupInfo, err := GetGroupInfo(ctx, groupID) if err != nil { - return false, utils.Wrap(err, "GetGroupInfoFromCache failed") + return false, false, err } + if groupInfo.Status == constant.GroupStatusMuted { - return true, nil + groupMemberInfo, err := GetGroupMemberInfo(ctx, groupID, userID) + if err != nil { + return false, false, err + } + return true, groupMemberInfo.RoleLevel > constant.GroupOrdinaryUsers, nil } - return false, nil + return false, false, nil } +func GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) { + +} + +func GetGroupInfo(ctx context.Context, groupID string) (sdkws.GroupInfo, error) { + +} + +func GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { + +} +func GetSuperGroupMsg(ctx context.Context, groupID string, seq uint32) (*sdkws.MsgData, error) { + +} func (rpc *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgReq) ([]string, error) { switch data.MsgData.SessionType { case constant.SingleChatType: if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { - return true, 0, "", nil + return nil, nil } if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { - return true, 0, "", nil + return nil, nil } - log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify) - reqGetBlackIDListFromCache := &cacheRpc.GetBlackIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} - etcdConn, err := rpc.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImCacheName) + black, err := IsBlocked(data.MsgData.SendID, data.MsgData.RecvID) if err != nil { - errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(data.OperationID, errMsg) - return true, 0, "", nil + return nil, err } - - cacheClient := cacheRpc.NewCacheClient(etcdConn) - cacheResp, err := cacheClient.GetBlackIDListFromCache(context.Background(), reqGetBlackIDListFromCache) - if err != nil { - log.NewError(data.OperationID, "GetBlackIDListFromCache rpc call failed ", err.Error()) - } else { - if cacheResp.CommonResp.ErrCode != 0 { - log.NewError(data.OperationID, "GetBlackIDListFromCache rpc logic call failed ", cacheResp.String()) - } else { - if utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) { - return false, 600, "in black list", nil - } - } + if black { + return nil, constant.ErrBlockedByPeer.Wrap() } - log.NewDebug(data.OperationID, *config.Config.MessageVerify.FriendVerify) if *config.Config.MessageVerify.FriendVerify { - reqGetFriendIDListFromCache := &cacheRpc.GetFriendIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} - etcdConn, err := rpc.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImCacheName) + friend, err := IsFriend(data.MsgData.SendID, data.MsgData.RecvID) if err != nil { - errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(data.OperationID, errMsg) - return true, 0, "", nil + return nil, err } - cacheClient := cacheRpc.NewCacheClient(etcdConn) - cacheResp, err := cacheClient.GetFriendIDListFromCache(context.Background(), reqGetFriendIDListFromCache) - if err != nil { - log.NewError(data.OperationID, "GetFriendIDListFromCache rpc call failed ", err.Error()) - } else { - if cacheResp.CommonResp.ErrCode != 0 { - log.NewError(data.OperationID, "GetFriendIDListFromCache rpc logic call failed ", cacheResp.String()) - } else { - if !utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) { - return false, 601, "not friend", nil - } - } + if !friend { + return nil, constant.ErrNotPeersFriend.Wrap() } - return true, 0, "", nil - } else { - return true, 0, "", nil + return nil, nil } + return nil, nil case constant.GroupChatType: - userIDList, err := utils.GetGroupMemberUserIDList(ctx, data.MsgData.GroupID, data.OperationID) + if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { + return nil, nil + } + userIDList, err := GetGroupMemberIDs(ctx, data.MsgData.GroupID) if err != nil { - errMsg := data.OperationID + err.Error() - log.NewError(data.OperationID, errMsg) - return false, 201, errMsg, nil + return nil, err } - if tokenverify.IsManagerUserID(data.MsgData.SendID) { - return true, 0, "", userIDList + if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { + return userIDList, nil } if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { - return true, 0, "", userIDList - } else { - if !utils.IsContain(data.MsgData.SendID, userIDList) { - //return returnMsg(&replay, pb, 202, "you are not in group", "", 0) - return false, 202, "you are not in group", nil - } + return userIDList, nil + } + if !utils.IsContain(data.MsgData.SendID, userIDList) { + return nil, constant.ErrNotInGroupYet.Wrap() } - isMute, isAdmin, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) + isMute, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { - errMsg := data.OperationID + err.Error() - return false, 223, errMsg, nil + return nil, err } if isMute { - return false, 224, "you are muted", nil - } - if isAdmin { - return true, 0, "", userIDList + return nil, constant.ErrMutedInGroup.Wrap() } - isMute, err = groupIsMuted(ctx, data.MsgData.GroupID) + + isMute, isAdmin, err := groupIsMuted(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { - errMsg := data.OperationID + err.Error() - return false, 223, errMsg, nil + return nil, err + } + if isAdmin { + return userIDList, nil } + if isMute { - return false, 225, "group id muted", nil + return nil, constant.ErrMutedGroup.Wrap() } - return true, 0, "", userIDList + return userIDList, nil case constant.SuperGroupChatType: - groupInfo, err := rocksCache.GetGroupInfoFromCache(ctx, data.MsgData.GroupID) + groupInfo, err := GetGroupInfo(ctx, data.MsgData.GroupID) if err != nil { - return false, 201, err.Error(), nil + return nil, err } - if data.MsgData.ContentType == constant.AdvancedRevoke { revokeMessage := new(MessageRevoked) err := utils.JsonStringToStruct(string(data.MsgData.Content), revokeMessage) if err != nil { - log.Error(data.OperationID, "json unmarshal err:", err.Error()) - return false, 201, err.Error(), nil + return nil, constant.ErrArgs.Wrap() } - log.Debug(data.OperationID, "revoke message is", *revokeMessage) + if revokeMessage.RevokerID != revokeMessage.SourceMessageSendID { - req := pbChat.GetSuperGroupMsgReq{OperationID: data.OperationID, Seq: revokeMessage.Seq, GroupID: data.MsgData.GroupID} - resp, err := rpc.GetSuperGroupMsg(context.Background(), &req) + resp, err := GetSuperGroupMsg(ctx, data.MsgData.GroupID, revokeMessage.Seq) if err != nil { - log.Error(data.OperationID, "GetSuperGroupMsgReq err:", err.Error()) - } else if resp.ErrCode != 0 { - log.Error(data.OperationID, "GetSuperGroupMsgReq err:", resp.ErrCode, resp.ErrMsg) + return nil, err + } + if resp.ClientMsgID == revokeMessage.ClientMsgID && resp.Seq == revokeMessage.Seq { + revokeMessage.SourceMessageSendTime = resp.SendTime + revokeMessage.SourceMessageSenderNickname = resp.SenderNickname + revokeMessage.SourceMessageSendID = resp.SendID + data.MsgData.Content = []byte(utils.StructToJsonString(revokeMessage)) } else { - if resp.MsgData != nil && resp.MsgData.ClientMsgID == revokeMessage.ClientMsgID && resp.MsgData.Seq == revokeMessage.Seq { - revokeMessage.SourceMessageSendTime = resp.MsgData.SendTime - revokeMessage.SourceMessageSenderNickname = resp.MsgData.SenderNickname - revokeMessage.SourceMessageSendID = resp.MsgData.SendID - log.Debug(data.OperationID, "new revoke message is ", revokeMessage) - data.MsgData.Content = []byte(utils.StructToJsonString(revokeMessage)) - } else { - return false, 201, errors.New("msg err").Error(), nil - } + return nil, constant.ErrData.Wrap("MsgData") } } } if groupInfo.GroupType == constant.SuperGroup { - return true, 0, "", nil + return nil, nil + } + + userIDList, err := GetGroupMemberIDs(ctx, data.MsgData.GroupID) + if err != nil { + return nil, err + } + if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { + return nil, nil + } + if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { + return userIDList, nil } else { - userIDList, err := utils.GetGroupMemberUserIDList(ctx, data.MsgData.GroupID, data.OperationID) - if err != nil { - errMsg := data.OperationID + err.Error() - log.NewError(data.OperationID, errMsg) - return false, 201, errMsg, nil - } - if tokenverify.IsManagerUserID(data.MsgData.SendID) { - return true, 0, "", userIDList - } - if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { - return true, 0, "", userIDList - } else { - if !utils.IsContain(data.MsgData.SendID, userIDList) { - //return returnMsg(&replay, pb, 202, "you are not in group", "", 0) - return false, 202, "you are not in group", nil - } - } - isMute, isAdmin, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) - if err != nil { - errMsg := data.OperationID + err.Error() - return false, 223, errMsg, nil - } - if isMute { - return false, 224, "you are muted", nil - } - if isAdmin { - return true, 0, "", userIDList - } - isMute, err = groupIsMuted(ctx, data.MsgData.GroupID) - if err != nil { - errMsg := data.OperationID + err.Error() - return false, 223, errMsg, nil - } - if isMute { - return false, 225, "group id muted", nil + if !utils.IsContain(data.MsgData.SendID, userIDList) { + return nil, constant.ErrNotInGroupYet.Wrap() } - return true, 0, "", userIDList } + isMute, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) + if err != nil { + return nil, err + } + if isMute { + return nil, constant.ErrMutedInGroup.Wrap() + } + + isMute, isAdmin, err := groupIsMuted(ctx, data.MsgData.GroupID, data.MsgData.SendID) + if err != nil { + return nil, err + } + if isAdmin { + return userIDList, nil + } + if isMute { + return nil, constant.ErrMutedGroup.Wrap() + } + return userIDList, nil + default: - return true, 0, "", nil + return nil, nil } - } func (rpc *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { msg.ServerMsgID = GetMsgID(msg.SendID) @@ -314,45 +283,63 @@ func GetMsgID(sendID string) string { return utils.Md5(t + "-" + sendID + "-" + strconv.Itoa(rand.Int())) } +func GetUserGlobalMsgRecvOpt(userID string) (int32, error) { + +} + +// possibleBlackUserID是否被userID拉黑,也就是是否在userID的黑名单中 +func IsBlocked(possibleBlackUserID, userID string) (bool, error) { + +} + +// possibleFriendUserID是否在userID的好友中 +func IsFriend(possibleFriendUserID, userID string) (bool, error) { + +} + +// 没找到不返回错误 +func GetSingleConversationRecvMsgOpt(userID, conversationID string) (int32, error) { + +} + func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *msg.SendMsgReq) (bool, error) { - opt, err := db.DB.GetUserGlobalMsgRecvOpt(userID) + opt, err := GetUserGlobalMsgRecvOpt(userID) if err != nil { return false, err } switch opt { case constant.ReceiveMessage: case constant.NotReceiveMessage: - return false + return false, nil case constant.ReceiveNotNotifyMessage: if pb.MsgData.Options == nil { pb.MsgData.Options = make(map[string]bool, 10) } utils.SetSwitchFromOptions(pb.MsgData.Options, constant.IsOfflinePush, false) - return true + return true, nil } conversationID := utils.GetConversationIDBySessionType(sourceID, sessionType) - singleOpt, sErr := db.DB.GetSingleConversationRecvMsgOpt(userID, conversationID) - if sErr != nil && sErr != go_redis.Nil { - log.NewError(pb.OperationID, "GetSingleConversationMsgOpt from redis err", conversationID, pb.String(), sErr.Error()) - return true + singleOpt, err := GetSingleConversationRecvMsgOpt(userID, conversationID) + if err != nil { + return false, err } switch singleOpt { case constant.ReceiveMessage: - return true + return true, nil case constant.NotReceiveMessage: if utils.IsContainInt(int(pb.MsgData.ContentType), ExcludeContentType) { return true } - return false + return false, nil case constant.ReceiveNotNotifyMessage: if pb.MsgData.Options == nil { pb.MsgData.Options = make(map[string]bool, 10) } utils.SetSwitchFromOptions(pb.MsgData.Options, constant.IsOfflinePush, false) - return true + return true, nil } - return true + return true, nil } func valueCopy(pb *msg.SendMsgReq) *msg.SendMsgReq { diff --git a/pkg/common/constant/errors.go b/pkg/common/constant/errors.go index fc5984946..c1a8af9a4 100644 --- a/pkg/common/constant/errors.go +++ b/pkg/common/constant/errors.go @@ -46,6 +46,13 @@ var ( ErrDB = ErrDatabase ErrSendLimit = ErrInternalServer + + ErrBlockedByPeer = &ErrInfo{BlockedByPeer, "BlockedByPeer", ""} + //不是对方的好友 + ErrNotPeersFriend = &ErrInfo{NotPeersFriend, "NotPeersFriend", ""} + // + ErrMutedInGroup = &ErrInfo{MutedInGroup, "MutedInGroup", ""} + ErrMutedGroup = &ErrInfo{MutedGroup, "MutedGroup", ""} ) const ( @@ -93,6 +100,8 @@ const ( RelationshipAlreadyError = 92001 //已经是好友关系(或者黑名单) NotRelationshipYetError = 92002 //不是好友关系(或者黑名单) CanNotAddYourselfError = 92003 //不能添加自己为好友 + BlockedByPeer = 92004 //被对方拉黑 + NotPeersFriend = 92005 //不是对方的好友 ) // 群组错误码 @@ -104,6 +113,9 @@ const ( OwnerNotAllowedQuitError = 93004 //群主不能退群 GroupTypeNotSupport = 93005 GroupNoOwner = 93006 + + MutedInGroup = 93007 //群成员被禁言 + MutedGroup = 93008 //群被禁言 ) // 用户错误码 From d7ea41fa1a9a41e19aaae64b8ee2e7a9219f8779 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 13 Feb 2023 18:14:26 +0800 Subject: [PATCH 19/48] msg rpc --- internal/common/check/group.go | 12 ++++--- internal/common/check/user.go | 14 ++++---- internal/common/notification/conversation.go | 4 +-- internal/rpc/msg/delete.go | 14 ++++---- internal/rpc/msg/extend_msg.go | 34 +++++++++--------- internal/rpc/msg/msg_status.go | 8 ++--- internal/rpc/msg/send_msg.go | 38 +++++++++++--------- internal/rpc/msg/server.go | 20 +++++------ pkg/common/db/controller/msg.go | 1 + pkg/common/db/localcache/group.go | 4 +-- 10 files changed, 80 insertions(+), 69 deletions(-) diff --git a/internal/common/check/group.go b/internal/common/check/group.go index 43ed85d1a..c2465a848 100644 --- a/internal/common/check/group.go +++ b/internal/common/check/group.go @@ -2,16 +2,20 @@ package check import ( sdkws "Open_IM/pkg/proto/sdkws" + "context" "errors" ) -type GroupChecker struct { +type GroupChecker struct{} + +func NewGroupChecker() GroupChecker { + return GroupChecker{} } -func NewGroupChecker() *GroupChecker { - return &GroupChecker{} +func (GroupChecker) GetGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) { + return nil, errors.New("TODO:GetUserInfo") } -func (g *GroupChecker) GetGroupInfo(groupID string) (*sdkws.GroupInfo, error) { +func (GroupChecker) GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { return nil, errors.New("TODO:GetUserInfo") } diff --git a/internal/common/check/user.go b/internal/common/check/user.go index af5954c91..77c3d493d 100644 --- a/internal/common/check/user.go +++ b/internal/common/check/user.go @@ -10,28 +10,28 @@ import ( // return nil, errors.New("TODO:GetUserInfo") //} -func NewUserCheck() *UserCheck { - return &UserCheck{} +func NewUserCheck() UserCheck { + return UserCheck{} } type UserCheck struct{} -func (u *UserCheck) GetUsersInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.UserInfo, error) { +func (UserCheck) GetUsersInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.UserInfo, error) { return nil, errors.New("todo") } -func (u *UserCheck) GetUsersInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.UserInfo, error) { +func (UserCheck) GetUsersInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.UserInfo, error) { return nil, errors.New("todo") } -func (u *UserCheck) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) { +func (UserCheck) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) { return nil, errors.New("todo") } -func (u *UserCheck) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) { +func (UserCheck) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) { return nil, errors.New("todo") } -func (u *UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) { +func (UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) { return nil, errors.New("todo") } diff --git a/internal/common/notification/conversation.go b/internal/common/notification/conversation.go index 88d56f10a..167203783 100644 --- a/internal/common/notification/conversation.go +++ b/internal/common/notification/conversation.go @@ -1,4 +1,4 @@ -package msg +package notification import ( "Open_IM/pkg/common/config" @@ -70,7 +70,7 @@ func ConversationChangeNotification(ctx context.Context, userID string) { SetConversationNotification(operationID, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) } -//会话未读数同步 +// 会话未读数同步 func ConversationUnreadChangeNotification(context context.Context, userID, conversationID string, updateUnreadCountTime int64) { log.NewInfo(operationID, utils.GetSelfFuncName()) ConversationChangedTips := &sdkws.ConversationUpdateTips{ diff --git a/internal/rpc/msg/delete.go b/internal/rpc/msg/delete.go index 44b506df6..d2e5e7b84 100644 --- a/internal/rpc/msg/delete.go +++ b/internal/rpc/msg/delete.go @@ -7,36 +7,36 @@ import ( "context" ) -func (s *msgServer) DelMsgList(ctx context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) { +func (m *msgServer) DelMsgList(ctx context.Context, req *common.DelMsgListReq) (*common.DelMsgListResp, error) { resp := &common.DelMsgListResp{} - if err := s.MsgInterface.DelMsgFromCache(ctx, req.UserID, req.SeqList); err != nil { + if err := m.MsgInterface.DelMsgFromCache(ctx, req.UserID, req.SeqList); err != nil { return nil, err } DeleteMessageNotification(ctx, req.UserID, req.SeqList) return resp, nil } -func (s *msgServer) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) { +func (m *msgServer) DelSuperGroupMsg(ctx context.Context, req *msg.DelSuperGroupMsgReq) (*msg.DelSuperGroupMsgResp, error) { resp := &msg.DelSuperGroupMsgResp{} if err := tokenverify.CheckAdmin(ctx); err != nil { return nil, err } - maxSeq, err := s.MsgInterface.GetGroupMaxSeq(ctx, req.GroupID) + maxSeq, err := m.MsgInterface.GetGroupMaxSeq(ctx, req.GroupID) if err != nil { return nil, err } - if err := s.MsgInterface.SetGroupUserMinSeq(ctx, req.GroupID, maxSeq); err != nil { + if err := m.MsgInterface.SetGroupUserMinSeq(ctx, req.GroupID, maxSeq); err != nil { return nil, err } return resp, nil } -func (s *msgServer) ClearMsg(ctx context.Context, req *msg.ClearMsgReq) (*msg.ClearMsgResp, error) { +func (m *msgServer) ClearMsg(ctx context.Context, req *msg.ClearMsgReq) (*msg.ClearMsgResp, error) { resp := &msg.ClearMsgResp{} if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil { return nil, err } - if err := s.MsgInterface.DelUserAllSeq(ctx, req.UserID); err != nil { + if err := m.MsgInterface.DelUserAllSeq(ctx, req.UserID); err != nil { return nil, err } return resp, nil diff --git a/internal/rpc/msg/extend_msg.go b/internal/rpc/msg/extend_msg.go index fa4af83b2..5d32729f2 100644 --- a/internal/rpc/msg/extend_msg.go +++ b/internal/rpc/msg/extend_msg.go @@ -14,8 +14,8 @@ import ( "time" ) -func (rpc *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.SetMessageReactionExtensionsReq) (resp *msg.SetMessageReactionExtensionsResp, err error) { - log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String()) +func (m *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg.SetMessageReactionExtensionsReq) (resp *msg.SetMessageReactionExtensionsResp, err error) { + log.Debug(req.OperationID, utils.GetSelfFuncName(), "m args is:", req.String()) var rResp msg.SetMessageReactionExtensionsResp rResp.ClientMsgID = req.ClientMsgID rResp.MsgFirstModifyTime = req.MsgFirstModifyTime @@ -72,7 +72,7 @@ func (rpc *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg log.Debug(req.OperationID, "redis handle firstly", req.String()) rResp.MsgFirstModifyTime = utils.GetCurrentTimestampByMill() for k, v := range req.ReactionExtensionList { - err := rpc.dMessageLocker.LockMessageTypeKey(req.ClientMsgID, k) + err := m.dMessageLocker.LockMessageTypeKey(req.ClientMsgID, k) if err != nil { setKeyResultInfo(&rResp, 100, err.Error(), req.ClientMsgID, k, v) continue @@ -91,7 +91,7 @@ func (rpc *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg log.Error(req.OperationID, "SetMessageReactionExpire err:", err.Error(), req.String()) } } else { - err := rpc.dMessageLocker.LockGlobalMessage(req.ClientMsgID) + err := m.dMessageLocker.LockGlobalMessage(req.ClientMsgID) if err != nil { rResp.ErrCode = 100 rResp.ErrMsg = err.Error() @@ -149,7 +149,7 @@ func (rpc *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg rResp.Result = append(rResp.Result, temp) } } - lockErr := rpc.dMessageLocker.UnLockGlobalMessage(req.ClientMsgID) + lockErr := m.dMessageLocker.UnLockGlobalMessage(req.ClientMsgID) if lockErr != nil { log.Error(req.OperationID, "UnLockGlobalMessage err:", lockErr.Error()) } @@ -159,7 +159,7 @@ func (rpc *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg log.Debug(req.OperationID, "redis handle secondly", req.String()) for k, v := range req.ReactionExtensionList { - err := rpc.dMessageLocker.LockMessageTypeKey(req.ClientMsgID, k) + err := m.dMessageLocker.LockMessageTypeKey(req.ClientMsgID, k) if err != nil { setKeyResultInfo(&rResp, 100, err.Error(), req.ClientMsgID, k, v) continue @@ -195,7 +195,7 @@ func (rpc *msgServer) SetMessageReactionExtensions(ctx context.Context, req *msg } else { notification.ExtendMessageUpdatedNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, true) } - log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String()) + log.Debug(req.OperationID, utils.GetSelfFuncName(), "m return is:", rResp.String()) return &rResp, nil } @@ -216,8 +216,8 @@ func setDeleteKeyResultInfo(r *msg.DeleteMessageListReactionExtensionsResp, errC _ = db.DB.UnLockMessageTypeKey(clientMsgID, typeKey) } -func (rpc *msgServer) GetMessageListReactionExtensions(ctx context.Context, req *msg.GetMessageListReactionExtensionsReq) (resp *msg.GetMessageListReactionExtensionsResp, err error) { - log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String()) +func (m *msgServer) GetMessageListReactionExtensions(ctx context.Context, req *msg.GetMessageListReactionExtensionsReq) (resp *msg.GetMessageListReactionExtensionsResp, err error) { + log.Debug(req.OperationID, utils.GetSelfFuncName(), "m args is:", req.String()) var rResp msg.GetMessageListReactionExtensionsResp for _, messageValue := range req.MessageReactionKeyList { var oneMessage msg.SingleMessageExtensionResult @@ -267,17 +267,17 @@ func (rpc *msgServer) GetMessageListReactionExtensions(ctx context.Context, req } rResp.SingleMessageResult = append(rResp.SingleMessageResult, &oneMessage) } - log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String()) + log.Debug(req.OperationID, utils.GetSelfFuncName(), "m return is:", rResp.String()) return &rResp, nil } -func (rpc *msgServer) AddMessageReactionExtensions(ctx context.Context, req *msg.ModifyMessageReactionExtensionsReq) (resp *msg.ModifyMessageReactionExtensionsResp, err error) { +func (m *msgServer) AddMessageReactionExtensions(ctx context.Context, req *msg.ModifyMessageReactionExtensionsReq) (resp *msg.ModifyMessageReactionExtensionsResp, err error) { return } -func (rpc *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) { - log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc args is:", req.String()) +func (m *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req *msg.DeleteMessageListReactionExtensionsReq) (resp *msg.DeleteMessageListReactionExtensionsResp, err error) { + log.Debug(req.OperationID, utils.GetSelfFuncName(), "m args is:", req.String()) var rResp msg.DeleteMessageListReactionExtensionsResp callbackResp := notification.callbackDeleteMessageReactionExtensions(req) if callbackResp.ActionCode != constant.ActionAllow || callbackResp.ErrCode != 0 { @@ -328,7 +328,7 @@ func (rpc *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req * if isExists { log.Debug(req.OperationID, "redis handle this delete", req.String()) for _, v := range req.ReactionExtensionList { - err := rpc.dMessageLocker.LockMessageTypeKey(req.ClientMsgID, v.TypeKey) + err := m.dMessageLocker.LockMessageTypeKey(req.ClientMsgID, v.TypeKey) if err != nil { setDeleteKeyResultInfo(&rResp, 100, err.Error(), req.ClientMsgID, v.TypeKey, v) continue @@ -354,7 +354,7 @@ func (rpc *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req * } } } else { - err := rpc.dMessageLocker.LockGlobalMessage(req.ClientMsgID) + err := m.dMessageLocker.LockGlobalMessage(req.ClientMsgID) if err != nil { rResp.ErrCode = 100 rResp.ErrMsg = err.Error() @@ -413,13 +413,13 @@ func (rpc *msgServer) DeleteMessageReactionExtensions(ctx context.Context, req * rResp.Result = append(rResp.Result, temp) } } - lockErr := rpc.dMessageLocker.UnLockGlobalMessage(req.ClientMsgID) + lockErr := m.dMessageLocker.UnLockGlobalMessage(req.ClientMsgID) if lockErr != nil { log.Error(req.OperationID, "UnLockGlobalMessage err:", lockErr.Error()) } } notification.ExtendMessageDeleteNotification(req.OperationID, req.OpUserID, req.SourceID, req.SessionType, req, &rResp, false, isExists) - log.Debug(req.OperationID, utils.GetSelfFuncName(), "rpc return is:", rResp.String()) + log.Debug(req.OperationID, utils.GetSelfFuncName(), "m return is:", rResp.String()) return &rResp, nil } diff --git a/internal/rpc/msg/msg_status.go b/internal/rpc/msg/msg_status.go index fb0ed2edf..b3a469f37 100644 --- a/internal/rpc/msg/msg_status.go +++ b/internal/rpc/msg/msg_status.go @@ -7,17 +7,17 @@ import ( "context" ) -func (s *msgServer) SetSendMsgStatus(ctx context.Context, req *pbMsg.SetSendMsgStatusReq) (*pbMsg.SetSendMsgStatusResp, error) { +func (m *msgServer) SetSendMsgStatus(ctx context.Context, req *pbMsg.SetSendMsgStatusReq) (*pbMsg.SetSendMsgStatusResp, error) { resp := &pbMsg.SetSendMsgStatusResp{} - if err := s.MsgInterface.SetSendMsgStatus(ctx, tracelog.GetOperationID(ctx), req.Status); err != nil { + if err := m.MsgInterface.SetSendMsgStatus(ctx, tracelog.GetOperationID(ctx), req.Status); err != nil { return nil, err } return resp, nil } -func (s *msgServer) GetSendMsgStatus(ctx context.Context, req *pbMsg.GetSendMsgStatusReq) (*pbMsg.GetSendMsgStatusResp, error) { +func (m *msgServer) GetSendMsgStatus(ctx context.Context, req *pbMsg.GetSendMsgStatusReq) (*pbMsg.GetSendMsgStatusResp, error) { resp := &pbMsg.GetSendMsgStatusResp{} - status, err := s.MsgInterface.GetSendMsgStatus(ctx, tracelog.GetOperationID(ctx)) + status, err := m.MsgInterface.GetSendMsgStatus(ctx, tracelog.GetOperationID(ctx)) if IsNotFound(err) { resp.Status = constant.MsgStatusNotExist return resp, nil diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index f2c0ee3a4..c9ec6bd8c 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -1,11 +1,13 @@ package msg import ( + "Open_IM/internal/common/check" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/db/localcache" "Open_IM/pkg/common/tracelog" "Open_IM/pkg/proto/msg" - sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" "math/rand" @@ -57,7 +59,7 @@ type MsgCallBackResp struct { } func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (isMute bool, err error) { - groupMemberInfo, err := GetGroupMemberInfo(ctx, groupID, userID) + groupMemberInfo, err := check.NewGroupChecker().GetGroupMemberInfo(ctx, groupID, userID) if err != nil { return false, err } @@ -69,13 +71,13 @@ func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (i // 如果禁言了,再看下是否群管理员 func groupIsMuted(ctx context.Context, groupID string, userID string) (bool, bool, error) { - groupInfo, err := GetGroupInfo(ctx, groupID) + groupInfo, err := check.NewGroupChecker().GetGroupInfo(ctx, groupID) if err != nil { return false, false, err } if groupInfo.Status == constant.GroupStatusMuted { - groupMemberInfo, err := GetGroupMemberInfo(ctx, groupID, userID) + groupMemberInfo, err := check.NewGroupChecker().GetGroupMemberInfo(ctx, groupID, userID) if err != nil { return false, false, err } @@ -85,20 +87,24 @@ func groupIsMuted(ctx context.Context, groupID string, userID string) (bool, boo } func GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) { - + return localcache.NewGroupMemberIDsLocalCache().GetGroupMemberIDs(ctx, groupID) } -func GetGroupInfo(ctx context.Context, groupID string) (sdkws.GroupInfo, error) { +//func GetGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) { +// return check.NewGroupChecker().GetGroupInfo(ctx, groupID) +// +// +//} -} +//func GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { +// check.NewGroupChecker().GetGroupMemberInfo +//} -func GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { +//func (m *msgServer)GetSuperGroupMsg(ctx context.Context, groupID string, seq uint32) (*sdkws.MsgData, error) { +// return m.MsgInterface.GetSuperGroupMsg(ctx, groupID, seq) +//} -} -func GetSuperGroupMsg(ctx context.Context, groupID string, seq uint32) (*sdkws.MsgData, error) { - -} -func (rpc *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgReq) ([]string, error) { +func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgReq) ([]string, error) { switch data.MsgData.SessionType { case constant.SingleChatType: if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { @@ -163,7 +169,7 @@ func (rpc *msgServer) messageVerification(ctx context.Context, data *msg.SendMsg } return userIDList, nil case constant.SuperGroupChatType: - groupInfo, err := GetGroupInfo(ctx, data.MsgData.GroupID) + groupInfo, err := check.NewGroupChecker().GetGroupInfo(ctx, data.MsgData.GroupID) if err != nil { return nil, err } @@ -175,7 +181,7 @@ func (rpc *msgServer) messageVerification(ctx context.Context, data *msg.SendMsg } if revokeMessage.RevokerID != revokeMessage.SourceMessageSendID { - resp, err := GetSuperGroupMsg(ctx, data.MsgData.GroupID, revokeMessage.Seq) + resp, err := m.MsgInterface.GetSuperGroupMsg(ctx, data.MsgData.GroupID, revokeMessage.Seq) if err != nil { return nil, err } @@ -231,7 +237,7 @@ func (rpc *msgServer) messageVerification(ctx context.Context, data *msg.SendMsg return nil, nil } } -func (rpc *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { +func (m *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { msg.ServerMsgID = GetMsgID(msg.SendID) msg.SendTime = utils.GetCurrentTimestampByMill() switch msg.ContentType { diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index b62822cf0..eb72c0ddf 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -75,7 +75,7 @@ func (rpc *rpcChat) initPrometheus() { promePkg.NewWorkSuperGroupChatMsgProcessFailedCounter() } -func (rpc *msgServer) Run() { +func (m *msgServer) Run() { log.Info("", "rpcChat init...") listenIP := "" if config.Config.ListenIP == "" { @@ -83,10 +83,10 @@ func (rpc *msgServer) Run() { } else { listenIP = config.Config.ListenIP } - address := listenIP + ":" + strconv.Itoa(rpc.rpcPort) + address := listenIP + ":" + strconv.Itoa(m.rpcPort) listener, err := net.Listen("tcp", address) if err != nil { - panic("listening err:" + err.Error() + rpc.rpcRegisterName) + panic("listening err:" + err.Error() + m.rpcRegisterName) } log.Info("", "listen network success, address ", address) recvSize := 1024 * 1024 * 30 @@ -109,26 +109,26 @@ func (rpc *msgServer) Run() { defer srv.GracefulStop() rpcRegisterIP := config.Config.RpcRegisterIP - msg.RegisterMsgServer(srv, rpc) + msg.RegisterMsgServer(srv, m) if config.Config.RpcRegisterIP == "" { rpcRegisterIP, err = utils.GetLocalIP() if err != nil { log.Error("", "GetLocalIP failed ", err.Error()) } } - err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10, "") + err = getcdv3.RegisterEtcd(m.etcdSchema, strings.Join(m.etcdAddr, ","), rpcRegisterIP, m.rpcPort, m.rpcRegisterName, 10, "") if err != nil { log.Error("", "register rpcChat to etcd failed ", err.Error()) - panic(utils.Wrap(err, "register chat module rpc to etcd err")) + panic(utils.Wrap(err, "register chat module m to etcd err")) } - go rpc.runCh() - rpc.initPrometheus() + go m.runCh() + m.initPrometheus() err = srv.Serve(listener) if err != nil { - log.Error("", "rpc rpcChat failed ", err.Error()) + log.Error("", "m rpcChat failed ", err.Error()) return } - log.Info("", "rpc rpcChat init success") + log.Info("", "m rpcChat init success") } func (rpc *rpcChat) runCh() { diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index cf10162cc..16cf25665 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -33,6 +33,7 @@ type MsgInterface interface { GetUserMinSeq(ctx context.Context, userID string) (uint32, error) GetMessageListBySeq(ctx context.Context, userID string, seqs []uint32) ([]*sdkws.MsgData, error) + GetSuperGroupMsg(ctx context.Context, groupID string, seq uint32) (*sdkws.MsgData, error) } type MsgDatabaseInterface interface { diff --git a/pkg/common/db/localcache/group.go b/pkg/common/db/localcache/group.go index e41c10456..fda1e2d48 100644 --- a/pkg/common/db/localcache/group.go +++ b/pkg/common/db/localcache/group.go @@ -24,8 +24,8 @@ type GroupMemberIDsHash struct { userIDs []string } -func NewGroupMemberIDsLocalCache(client discoveryRegistry.SvcDiscoveryRegistry) GroupLocalCache { - return GroupLocalCache{ +func NewGroupMemberIDsLocalCache(client discoveryRegistry.SvcDiscoveryRegistry) *GroupLocalCache { + return &GroupLocalCache{ cache: make(map[string]GroupMemberIDsHash, 0), client: client, } From d87cc24f9e43d88004d4fa9576aeedf5a3295a44 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 18:44:53 +0800 Subject: [PATCH 20/48] Error code standardization --- internal/common/notification/c.go | 28 +++++------- internal/common/notification/conversation.go | 18 ++++---- internal/common/notification/friend.go | 19 +++----- internal/common/notification/group.go | 34 +-------------- internal/common/notification/msg.go | 5 +-- internal/common/notification/super_group.go | 5 +-- internal/rpc/friend/friend.go | 2 +- internal/rpc/group/group.go | 46 ++++++++++---------- internal/rpc/msg/send_msg.go | 1 + 9 files changed, 58 insertions(+), 100 deletions(-) diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go index 32f1bef7a..237ee425d 100644 --- a/internal/common/notification/c.go +++ b/internal/common/notification/c.go @@ -1,9 +1,12 @@ package notification import ( + "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - pbChat "Open_IM/pkg/proto/msg" - "strings" + "Open_IM/pkg/proto/msg" + "Open_IM/pkg/proto/sdkws" + "context" + utils "github.com/OpenIMSDK/open_utils" ) type NotificationMsg struct { @@ -19,13 +22,12 @@ type NotificationMsg struct { } func Notification(n *NotificationMsg) { - var req pbChat.SendMsgReq + var req msg.SendMsgReq var msg sdkws.MsgData var offlineInfo sdkws.OfflinePushInfo var title, desc, ex string var pushSwitch, unReadCount bool var reliabilityLevel int - req.OperationID = n.OperationID msg.SendID = n.SendID msg.RecvID = n.RecvID msg.Content = n.Content @@ -272,18 +274,10 @@ func Notification(n *NotificationMsg) { offlineInfo.Ex = ex msg.OfflinePushInfo = &offlineInfo req.MsgData = &msg - etcdConn := rpc.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID) - if etcdConn == nil { - errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil" - log.NewError(req.OperationID, errMsg) - return - } - client := pbChat.NewMsgClient(etcdConn) - reply, err := client.SendMsg(context.Background(), &req) - if err != nil { - log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), err.Error()) - } else if reply.ErrCode != 0 { - log.NewError(req.OperationID, "SendMsg rpc failed, ", req.String(), reply.ErrCode, reply.ErrMsg) - } + _, err := sendMsg(context.Background(), &req) +} + +func sendMsg(ctx context.Context, req *msg.SendMsgReq) (msg.SendMsgResp, error) { + } diff --git a/internal/common/notification/conversation.go b/internal/common/notification/conversation.go index 88d56f10a..1f87b3263 100644 --- a/internal/common/notification/conversation.go +++ b/internal/common/notification/conversation.go @@ -1,9 +1,10 @@ -package msg +package notification import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" sdkws "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" @@ -42,7 +43,6 @@ func SetConversationNotification(operationID, sendID, recvID string, contentType // SetPrivate调用 func ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) { - log.NewInfo(operationID, utils.GetSelfFuncName()) conversationSetPrivateTips := &sdkws.ConversationSetPrivateTips{ RecvID: recvID, SendID: sendID, @@ -56,23 +56,23 @@ func ConversationSetPrivateNotification(ctx context.Context, sendID, recvID stri tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips } tips.DefaultTips = tipsMsg - SetConversationNotification(operationID, sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips) + SetConversationNotification(tracelog.GetOperationID(ctx), sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips) } // 会话改变 func ConversationChangeNotification(ctx context.Context, userID string) { - log.NewInfo(operationID, utils.GetSelfFuncName()) + ConversationChangedTips := &sdkws.ConversationUpdateTips{ UserID: userID, } var tips sdkws.TipsComm tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips - SetConversationNotification(operationID, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) + SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) } -//会话未读数同步 -func ConversationUnreadChangeNotification(context context.Context, userID, conversationID string, updateUnreadCountTime int64) { - log.NewInfo(operationID, utils.GetSelfFuncName()) +// 会话未读数同步 +func ConversationUnreadChangeNotification(ctx context.Context, userID, conversationID string, updateUnreadCountTime int64) { + ConversationChangedTips := &sdkws.ConversationUpdateTips{ UserID: userID, ConversationIDList: []string{conversationID}, @@ -80,5 +80,5 @@ func ConversationUnreadChangeNotification(context context.Context, userID, conve } var tips sdkws.TipsComm tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips - SetConversationNotification(operationID, userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips) + SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips) } diff --git a/internal/common/notification/friend.go b/internal/common/notification/friend.go index 2ade47709..9af20a095 100644 --- a/internal/common/notification/friend.go +++ b/internal/common/notification/friend.go @@ -2,13 +2,12 @@ package notification import ( "Open_IM/internal/common/check" - "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" "Open_IM/pkg/common/tracelog" pbFriend "Open_IM/pkg/proto/friend" - sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" "github.com/golang/protobuf/jsonpb" @@ -16,15 +15,11 @@ import ( ) func getFromToUserNickname(fromUserID, toUserID string) (string, string, error) { - users, err := check.GetUsersInfo(context.Background(), fromUserID, toUserID) + users, err := check.NewUserCheck().GetUsersInfoMap(context.Background(), []string{fromUserID, toUserID}, true) if err != nil { return "", "", nil } - if users[0].UserID == fromUserID { - return users[0].Nickname, users[1].Nickname, nil - } - return users[1].Nickname, users[0].Nickname, nil - + return users[fromUserID].Nickname, users[toUserID].Nickname, nil } func friendNotification(operationID, fromUserID, toUserID string, contentType int32, m proto.Message) { @@ -77,7 +72,7 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in return } - var n msg.NotificationMsg + var n NotificationMsg n.SendID = fromUserID n.RecvID = toUserID n.ContentType = contentType @@ -89,10 +84,10 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - msg.Notification(&n) + Notification(&n) } -func FriendApplicationAddNotification(ctx context.Context, req *pbFriend.AddFriendReq) { +func FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) { FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}} FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID @@ -117,7 +112,7 @@ func FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.Res func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) { friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}} - user, err := check.GetUsersInfo(context.Background(), opUserID) + user, err := check.NewUserCheck().GetUsersInfos(context.Background(), []string{opUserID}, true) if err != nil { return } diff --git a/internal/common/notification/group.go b/internal/common/notification/group.go index c3982ed6d..e51b08732 100644 --- a/internal/common/notification/group.go +++ b/internal/common/notification/group.go @@ -1,13 +1,10 @@ package notification import ( - "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/log" "Open_IM/pkg/common/tokenverify" - utils2 "Open_IM/pkg/common/utils" pbGroup "Open_IM/pkg/proto/group" "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" @@ -17,13 +14,6 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" ) -//message GroupCreatedTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo Creator = 2; -// repeated GroupMemberFullInfo MemberList = 3; -// uint64 OperationTime = 4; -//} creator->group - func setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { if tokenverify.IsManagerUserID(opUserID) { u, err := imdb.GetUserByUserID(opUserID) @@ -182,7 +172,7 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv return } - var n msg.NotificationMsg + var n NotificationMsg n.SendID = sendID if groupID != "" { n.RecvID = groupID @@ -207,7 +197,7 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - msg.Notification(&n) + Notification(&n) } // 创建群后调用 @@ -574,26 +564,6 @@ func MemberInvitedNotification(operationID, groupID, opUserID, reason string, in groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID) } -//message GroupInfoChangedTips{ -// int32 ChangedType = 1; //bitwise operators: 1:groupName; 10:Notification 100:Introduction; 1000:FaceUrl -// GroupInfo Group = 2; -// GroupMemberFullInfo OpUser = 3; -//} - -//message MemberLeaveTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo LeaverUser = 2; -// uint64 OperationTime = 3; -//} - -//群成员退群后调用 - -// message MemberEnterTips{ -// GroupInfo Group = 1; -// GroupMemberFullInfo EntrantUser = 2; -// uint64 OperationTime = 3; -// } -// // 群成员主动申请进群,管理员同意后调用, func MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} diff --git a/internal/common/notification/msg.go b/internal/common/notification/msg.go index a846ce738..23a78c135 100644 --- a/internal/common/notification/msg.go +++ b/internal/common/notification/msg.go @@ -1,7 +1,6 @@ package notification import ( - "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" sdkws "Open_IM/pkg/proto/sdkws" @@ -32,7 +31,7 @@ func MessageNotification(operationID, sendID, recvID string, contentType int32, } tips.JsonDetail, _ = marshaler.MarshalToString(m) - var n msg.NotificationMsg + var n NotificationMsg n.SendID = sendID n.RecvID = recvID n.ContentType = contentType @@ -44,5 +43,5 @@ func MessageNotification(operationID, sendID, recvID string, contentType int32, log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - msg.Notification(&n) + Notification(&n) } diff --git a/internal/common/notification/super_group.go b/internal/common/notification/super_group.go index 19d08dd98..61130a290 100644 --- a/internal/common/notification/super_group.go +++ b/internal/common/notification/super_group.go @@ -1,7 +1,6 @@ package notification import ( - "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" //sdk "Open_IM/pkg/proto/sdkws" @@ -11,7 +10,7 @@ import ( ) func SuperGroupNotification(operationID, sendID, recvID string) { - n := &msg.NotificationMsg{ + n := &NotificationMsg{ SendID: sendID, RecvID: recvID, MsgFrom: constant.SysMsgType, @@ -20,5 +19,5 @@ func SuperGroupNotification(operationID, sendID, recvID string) { OperationID: operationID, } log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content)) - msg.Notification(n) + Notification(n) } diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 28b146281..3b99ede9d 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -128,7 +128,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFr if err := tokenverify.CheckAdmin(ctx); err != nil { return nil, err } - if _, err := check.GetUsersInfo(ctx, req.OwnerUserID, req.FriendUserIDs); err != nil { + if _, err := check.NewUserCheck().GetUsersInfos(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...), true); err != nil { return nil, err } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 85119fd82..4adb96647 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -2,7 +2,7 @@ package group import ( "Open_IM/internal/common/check" - chat "Open_IM/internal/rpc/msg" + "Open_IM/internal/common/notification" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/controller" @@ -281,11 +281,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if req.GroupInfo.GroupType == constant.SuperGroup { go func() { for _, userID := range userIDs { - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } }() } else { - chat.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs) + notification.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs) } return resp, nil } @@ -379,7 +379,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, request := range requests { - chat.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ + notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ GroupID: request.GroupID, ReqMessage: request.ReqMsg, JoinSource: request.JoinSource, @@ -395,7 +395,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, userID := range req.InvitedUserIDs { - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } } else { opUserID := tracelog.GetOpUserID(ctx) @@ -416,7 +416,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil { return nil, err } - chat.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) + notification.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) } return resp, nil } @@ -493,7 +493,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou } go func() { for _, userID := range req.KickedUserIDs { - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } }() } else { @@ -533,7 +533,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou if err := s.GroupInterface.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil { return nil, err } - chat.MemberKickedNotification(req, req.KickedUserIDs) + notification.MemberKickedNotification(req, req.KickedUserIDs) } return resp, nil } @@ -700,10 +700,10 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup } if !join { if req.HandleResult == constant.GroupResponseAgree { - chat.GroupApplicationAcceptedNotification(req) - chat.MemberEnterNotification(ctx, req) + notification.GroupApplicationAcceptedNotification(req) + notification.MemberEnterNotification(ctx, req) } else if req.HandleResult == constant.GroupResponseRefuse { - chat.GroupApplicationRejectedNotification(req) + notification.GroupApplicationRejectedNotification(req) } } return resp, nil @@ -741,7 +741,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil { return nil, err } - chat.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) + notification.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) return resp, nil } groupRequest := relationTb.GroupRequestModel{ @@ -754,7 +754,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil { return nil, err } - chat.JoinGroupApplicationNotification(ctx, req) + notification.JoinGroupApplicationNotification(ctx, req) return resp, nil } @@ -768,13 +768,13 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil { return nil, err } - chat.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) + notification.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) } else { _, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx)) if err != nil { return nil, err } - chat.MemberQuitNotification(req) + notification.MemberQuitNotification(req) } return resp, nil } @@ -808,7 +808,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf if err != nil { return nil, err } - chat.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) + notification.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) if req.GroupInfoForSet.Notification != "" { s.GroupNotification(ctx, group.GroupID) } @@ -858,7 +858,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans if err := s.GroupInterface.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID, newOwner.RoleLevel); err != nil { return nil, err } - chat.GroupOwnerTransferredNotification(req) + notification.GroupOwnerTransferredNotification(req) return resp, nil } @@ -990,7 +990,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou return nil, err } } else { - chat.GroupDismissedNotification(req) + notification.GroupDismissedNotification(req) } return resp, nil } @@ -1014,7 +1014,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - chat.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds) + notification.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds) return resp, nil } @@ -1037,7 +1037,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - chat.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID) + notification.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID) return resp, nil } @@ -1049,7 +1049,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil { return nil, err } - chat.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + notification.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) return resp, nil } @@ -1061,7 +1061,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil { return nil, err } - chat.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + notification.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) return resp, nil } @@ -1138,7 +1138,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr return nil, err } for _, member := range req.Members { - chat.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID) + notification.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID) } return resp, nil } diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index f2c0ee3a4..e94b1b9dd 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -95,6 +95,7 @@ func GetGroupInfo(ctx context.Context, groupID string) (sdkws.GroupInfo, error) func GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { } + func GetSuperGroupMsg(ctx context.Context, groupID string, seq uint32) (*sdkws.MsgData, error) { } From b4f967ea97e27b9d962549e7130e17750196e1a6 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Mon, 13 Feb 2023 19:31:17 +0800 Subject: [PATCH 21/48] check.go --- internal/common/check/group.go | 101 ++++++++++++++++++++++++++++++--- internal/common/check/user.go | 95 ++++++++++++++++++++++++++----- internal/rpc/group/group.go | 2 +- internal/rpc/msg/server.go | 2 + internal/rpc/msg/utils.go | 12 ++++ pkg/common/constant/errors.go | 1 + 6 files changed, 190 insertions(+), 23 deletions(-) diff --git a/internal/common/check/group.go b/internal/common/check/group.go index c2465a848..c735f99e4 100644 --- a/internal/common/check/group.go +++ b/internal/common/check/group.go @@ -1,21 +1,106 @@ package check import ( + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + discoveryRegistry "Open_IM/pkg/discoveryregistry" + "Open_IM/pkg/proto/group" sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" "context" - "errors" + "google.golang.org/grpc" + "strings" ) -type GroupChecker struct{} +type GroupChecker struct { + zk discoveryRegistry.SvcDiscoveryRegistry +} + +func NewGroupChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *GroupChecker { + return &GroupChecker{ + zk: zk, + } +} + +func (g *GroupChecker) getConn() (*grpc.ClientConn, error) { + return g.zk.GetConn(config.Config.RpcRegisterName.OpenImGroupName) +} + +func (g *GroupChecker) GetGroupInfos(ctx context.Context, groupIDs []string, complete bool) ([]*sdkws.GroupInfo, error) { + cc, err := g.getConn() + if err != nil { + return nil, err + } + resp, err := group.NewGroupClient(cc).GetGroupsInfo(ctx, &group.GetGroupsInfoReq{ + GroupIDs: groupIDs, + }) + if err != nil { + return nil, err + } + if complete { + if ids := utils.Single(groupIDs, utils.Slice(resp.GroupInfos, func(e *sdkws.GroupInfo) string { + return e.GroupID + })); len(ids) > 0 { + return nil, constant.ErrGroupIDNotFound.Wrap(strings.Join(ids, ",")) + } + } + return resp.GroupInfos, nil +} + +func (g *GroupChecker) GetGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) { + groups, err := g.GetGroupInfos(ctx, []string{groupID}, true) + if err != nil { + return nil, err + } + return groups[0], nil +} + +func (g *GroupChecker) GetGroupInfoMap(ctx context.Context, groupIDs []string, complete bool) (map[string]*sdkws.GroupInfo, error) { + groups, err := g.GetGroupInfos(ctx, groupIDs, complete) + if err != nil { + return nil, err + } + return utils.SliceToMap(groups, func(e *sdkws.GroupInfo) string { + return e.GroupID + }), nil +} -func NewGroupChecker() GroupChecker { - return GroupChecker{} +func (g *GroupChecker) GetGroupMemberInfos(ctx context.Context, groupID string, userIDs []string, complete bool) ([]*sdkws.GroupMemberFullInfo, error) { + cc, err := g.getConn() + if err != nil { + return nil, err + } + resp, err := group.NewGroupClient(cc).GetGroupMembersInfo(ctx, &group.GetGroupMembersInfoReq{ + GroupID: groupID, + Members: userIDs, + }) + if err != nil { + return nil, err + } + if complete { + if ids := utils.Single(userIDs, utils.Slice(resp.Members, func(e *sdkws.GroupMemberFullInfo) string { + return e.UserID + })); len(ids) > 0 { + return nil, constant.ErrNotInGroupYet.Wrap(strings.Join(ids, ",")) + } + } + return resp.Members, nil } -func (GroupChecker) GetGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) { - return nil, errors.New("TODO:GetUserInfo") +func (g *GroupChecker) GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { + members, err := g.GetGroupMemberInfos(ctx, groupID, []string{userID}, true) + if err != nil { + return nil, err + } + return members[0], nil } -func (GroupChecker) GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { - return nil, errors.New("TODO:GetUserInfo") +func (g *GroupChecker) GetGroupMemberInfoMap(ctx context.Context, groupID string, userIDs []string, complete bool) (map[string]*sdkws.GroupMemberFullInfo, error) { + members, err := g.GetGroupMemberInfos(ctx, groupID, userIDs, true) + if err != nil { + return nil, err + } + return utils.SliceToMap(members, func(e *sdkws.GroupMemberFullInfo) string { + return e.UserID + }), nil } diff --git a/internal/common/check/user.go b/internal/common/check/user.go index 77c3d493d..8178cbf1a 100644 --- a/internal/common/check/user.go +++ b/internal/common/check/user.go @@ -1,37 +1,104 @@ package check import ( + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/constant" + discoveryRegistry "Open_IM/pkg/discoveryregistry" sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/proto/user" + "Open_IM/pkg/utils" "context" - "errors" + "google.golang.org/grpc" + "strings" ) //func GetUsersInfo(ctx context.Context, args ...interface{}) ([]*sdkws.UserInfo, error) { // return nil, errors.New("TODO:GetUserInfo") //} -func NewUserCheck() UserCheck { - return UserCheck{} +func NewUserCheck(zk discoveryRegistry.SvcDiscoveryRegistry) *UserCheck { + return &UserCheck{ + zk: zk, + } } -type UserCheck struct{} +type UserCheck struct { + zk discoveryRegistry.SvcDiscoveryRegistry +} + +func (u *UserCheck) getConn() (*grpc.ClientConn, error) { + return u.zk.GetConn(config.Config.RpcRegisterName.OpenImUserName) +} + +func (u *UserCheck) GetUsersInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.UserInfo, error) { + cc, err := u.getConn() + if err != nil { + return nil, err + } + resp, err := user.NewUserClient(cc).GetDesignateUsers(ctx, &user.GetDesignateUsersReq{ + UserIDs: userIDs, + }) + if err != nil { + return nil, err + } + if complete { + if ids := utils.Single(userIDs, utils.Slice(resp.UsersInfo, func(e *sdkws.UserInfo) string { + return e.UserID + })); len(ids) > 0 { + return nil, constant.ErrUserIDNotFound.Wrap(strings.Join(ids, ",")) + } + } + return resp.UsersInfo, nil +} -func (UserCheck) GetUsersInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.UserInfo, error) { - return nil, errors.New("todo") +func (u *UserCheck) GetUsersInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) { + users, err := u.GetUsersInfos(ctx, []string{userID}, true) + if err != nil { + return nil, err + } + return users[0], nil } -func (UserCheck) GetUsersInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.UserInfo, error) { - return nil, errors.New("todo") +func (u *UserCheck) GetUsersInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.UserInfo, error) { + users, err := u.GetUsersInfos(ctx, userIDs, complete) + if err != nil { + return nil, err + } + return utils.SliceToMap(users, func(e *sdkws.UserInfo) string { + return e.UserID + }), nil } -func (UserCheck) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) { - return nil, errors.New("todo") +func (u *UserCheck) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) { + users, err := u.GetUsersInfos(ctx, userIDs, complete) + if err != nil { + return nil, err + } + return utils.Slice(users, func(e *sdkws.UserInfo) *sdkws.PublicUserInfo { + return &sdkws.PublicUserInfo{ + UserID: e.UserID, + Nickname: e.Nickname, + FaceURL: e.FaceURL, + Gender: e.Gender, + Ex: e.Ex, + } + }), nil } -func (UserCheck) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) { - return nil, errors.New("todo") +func (u *UserCheck) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) { + users, err := u.GetPublicUserInfos(ctx, []string{userID}, true) + if err != nil { + return nil, err + } + return users[0], nil } -func (UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) { - return nil, errors.New("todo") +func (u *UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) { + users, err := u.GetPublicUserInfos(ctx, userIDs, complete) + if err != nil { + return nil, err + } + return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string { + return e.UserID + }), nil } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 85119fd82..7088d4223 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -36,7 +36,7 @@ func Start(server *grpc.Server) { pbGroup.RegisterGroupServer(server, &groupServer{ GroupInterface: controller.NewGroupInterface(nil, cache.NewRedis().GetClient(), unrelation.NewMongo().GetClient()), registerCenter: nil, - user: check.NewUserCheck(), + user: check.NewUserCheck(nil), }) } diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index eb72c0ddf..7d2fdaf31 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -1,6 +1,7 @@ package msg import ( + "Open_IM/internal/common/check" "Open_IM/internal/common/notification" "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" @@ -25,6 +26,7 @@ import ( type msgServer struct { *rpcserver.RpcServer MsgInterface controller.MsgInterface + Group *check.GroupChecker } type deleteMsg struct { diff --git a/internal/rpc/msg/utils.go b/internal/rpc/msg/utils.go index 1bc863994..3582bd8f5 100644 --- a/internal/rpc/msg/utils.go +++ b/internal/rpc/msg/utils.go @@ -4,6 +4,9 @@ import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/utils" + "github.com/go-redis/redis/v8" + "gorm.io/gorm" ) func isMessageHasReadEnabled(msgData *sdkws.MsgData) bool { @@ -23,3 +26,12 @@ func isMessageHasReadEnabled(msgData *sdkws.MsgData) bool { } return true } + +func IsNotFound(err error) bool { + switch utils.Unwrap(err) { + case redis.Nil, gorm.ErrRecordNotFound: + return true + default: + return false + } +} diff --git a/pkg/common/constant/errors.go b/pkg/common/constant/errors.go index c1a8af9a4..b998fc71d 100644 --- a/pkg/common/constant/errors.go +++ b/pkg/common/constant/errors.go @@ -14,6 +14,7 @@ var ( ErrUserIDNotFound = &ErrInfo{UserIDNotFoundError, "UserIDNotFoundError", ""} ErrGroupIDNotFound = &ErrInfo{GroupIDNotFoundError, "GroupIDNotFoundError", ""} ErrGroupIDExisted = &ErrInfo{GroupIDNotFoundError, "GroupIDExisted", ""} // todo group id 已存在 + ErrGroupIDExisted = &ErrInfo{GroupIDNotFoundError, "GroupIDExisted", ""} // todo group id 已存在 ErrRecordNotFound = &ErrInfo{RecordNotFoundError, "RecordNotFoundError", ""} From b27aa040f7b8412a60fe10bc69077b380f8eff98 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 21:36:08 +0800 Subject: [PATCH 22/48] Error code standardization --- internal/common/notification/c.go | 8 +- internal/common/notification/conversation.go | 23 +- internal/common/notification/friend.go | 24 +- internal/common/notification/group.go | 259 ++++++++++--------- internal/common/notification/msg.go | 10 +- internal/common/notification/super_group.go | 4 +- internal/rpc/msg/server.go | 1 + internal/rpc/user/user.go | 2 - pkg/common/tokenverify/jwt_token.go | 3 + 9 files changed, 172 insertions(+), 162 deletions(-) diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go index 237ee425d..17f5a801c 100644 --- a/internal/common/notification/c.go +++ b/internal/common/notification/c.go @@ -1,6 +1,7 @@ package notification import ( + "Open_IM/internal/common/check" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/proto/msg" @@ -9,6 +10,11 @@ import ( utils "github.com/OpenIMSDK/open_utils" ) +type Check struct { + user *check.UserCheck + group *check.GroupChecker +} + type NotificationMsg struct { SendID string RecvID string @@ -21,7 +27,7 @@ type NotificationMsg struct { SenderFaceURL string } -func Notification(n *NotificationMsg) { +func (c *Check) Notification(n *NotificationMsg) { var req msg.SendMsgReq var msg sdkws.MsgData var offlineInfo sdkws.OfflinePushInfo diff --git a/internal/common/notification/conversation.go b/internal/common/notification/conversation.go index 167203783..745a1e6bd 100644 --- a/internal/common/notification/conversation.go +++ b/internal/common/notification/conversation.go @@ -4,6 +4,7 @@ import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" sdkws "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" @@ -11,7 +12,7 @@ import ( "github.com/golang/protobuf/proto" ) -func SetConversationNotification(operationID, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) { +func (c *Check) SetConversationNotification(operationID, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) { log.NewInfo(operationID, "args: ", sendID, recvID, contentType, m.String(), tips.String()) var err error tips.Detail, err = proto.Marshal(m) @@ -37,12 +38,12 @@ func SetConversationNotification(operationID, sendID, recvID string, contentType log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + c.Notification(&n) } // SetPrivate调用 -func ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) { - log.NewInfo(operationID, utils.GetSelfFuncName()) +func (c *Check) ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) { + conversationSetPrivateTips := &sdkws.ConversationSetPrivateTips{ RecvID: recvID, SendID: sendID, @@ -56,23 +57,23 @@ func ConversationSetPrivateNotification(ctx context.Context, sendID, recvID stri tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips } tips.DefaultTips = tipsMsg - SetConversationNotification(operationID, sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips) + c.SetConversationNotification(tracelog.GetOperationID(ctx), sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips) } // 会话改变 -func ConversationChangeNotification(ctx context.Context, userID string) { - log.NewInfo(operationID, utils.GetSelfFuncName()) +func (c *Check) ConversationChangeNotification(ctx context.Context, userID string) { + ConversationChangedTips := &sdkws.ConversationUpdateTips{ UserID: userID, } var tips sdkws.TipsComm tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips - SetConversationNotification(operationID, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) + c.SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) } // 会话未读数同步 -func ConversationUnreadChangeNotification(context context.Context, userID, conversationID string, updateUnreadCountTime int64) { - log.NewInfo(operationID, utils.GetSelfFuncName()) +func (c *Check) ConversationUnreadChangeNotification(context context.Context, userID, conversationID string, updateUnreadCountTime int64) { + ConversationChangedTips := &sdkws.ConversationUpdateTips{ UserID: userID, ConversationIDList: []string{conversationID}, @@ -80,5 +81,5 @@ func ConversationUnreadChangeNotification(context context.Context, userID, conve } var tips sdkws.TipsComm tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips - SetConversationNotification(operationID, userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips) + c.SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips) } diff --git a/internal/common/notification/friend.go b/internal/common/notification/friend.go index 9af20a095..10c08f30a 100644 --- a/internal/common/notification/friend.go +++ b/internal/common/notification/friend.go @@ -14,8 +14,8 @@ import ( "github.com/golang/protobuf/proto" ) -func getFromToUserNickname(fromUserID, toUserID string) (string, string, error) { - users, err := check.NewUserCheck().GetUsersInfoMap(context.Background(), []string{fromUserID, toUserID}, true) +func getFromToUserNickname(userCheck *check.UserCheck, fromUserID, toUserID string) (string, string, error) { + users, err := userCheck.GetUsersInfoMap(context.Background(), []string{fromUserID, toUserID}, true) if err != nil { return "", "", nil } @@ -87,14 +87,14 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in Notification(&n) } -func FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) { +func (c *Check) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) { FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}} FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID friendNotification(tracelog.GetOperationID(ctx), req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips) } -func FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { +func (c *Check) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}} FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID @@ -102,7 +102,7 @@ func FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.Resp friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips) } -func FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { +func (c *Check) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}} FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID @@ -110,7 +110,7 @@ func FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.Res friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips) } -func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) { +func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) { friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}} user, err := check.NewUserCheck().GetUsersInfos(context.Background(), []string{opUserID}, true) if err != nil { @@ -129,28 +129,28 @@ func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUse friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips) } -func FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) { +func (c *Check) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) { friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}} friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips) } -func FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) { +func (c *Check) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) { friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}} friendInfoChangedTips.FromToUserID.FromUserID = fromUserID friendInfoChangedTips.FromToUserID.ToUserID = toUserID friendNotification(tracelog.GetOperationID(ctx), fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips) } -func BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) { +func (c *Check) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) { blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}} blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID blackAddedTips.FromToUserID.ToUserID = req.BlackUserID friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips) } -func BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) { +func (c *Check) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) { blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}} blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID @@ -158,12 +158,12 @@ func BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) } // send to myself -func UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) { +func (c *Check) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) { selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} friendNotification(tracelog.GetOperationID(ctx), opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) } -func FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { +func (c *Check) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} friendNotification(tracelog.GetOperationID(ctx), opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips) } diff --git a/internal/common/notification/group.go b/internal/common/notification/group.go index e51b08732..89e8c8d05 100644 --- a/internal/common/notification/group.go +++ b/internal/common/notification/group.go @@ -14,77 +14,78 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" ) -func setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { +func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { if tokenverify.IsManagerUserID(opUserID) { - u, err := imdb.GetUserByUserID(opUserID) + user, err := c.user.GetUsersInfos(context.Background(), []string{opUserID}, true) if err != nil { - return utils.Wrap(err, "GetUserByUserID failed") + return err } - utils.CopyStructFields(groupMemberInfo, u) groupMemberInfo.GroupID = groupID - } else { - u, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, opUserID) - if err == nil { - if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, u); err != nil { - return utils.Wrap(err, "") - } - } - user, err := imdb.GetUserByUserID(opUserID) - if err != nil { - return utils.Wrap(err, "") - } - groupMemberInfo.GroupID = groupID - groupMemberInfo.UserID = user.UserID - groupMemberInfo.Nickname = user.Nickname - groupMemberInfo.AppMangerLevel = user.AppMangerLevel - groupMemberInfo.FaceURL = user.FaceURL + groupMemberInfo.UserID = user[0].UserID + groupMemberInfo.Nickname = user[0].Nickname + groupMemberInfo.AppMangerLevel = user[0].AppMangerLevel + groupMemberInfo.FaceURL = user[0].FaceURL + return nil } + u, err := c.group.GetGroupMemberInfo(context.Background(), groupID, opUserID) + if err == nil { + *groupMemberInfo = *u + return nil + } + user, err := c.user.GetUsersInfos(context.Background(), []string{opUserID}, true) + if err != nil { + return err + } + groupMemberInfo.GroupID = groupID + groupMemberInfo.UserID = user[0].UserID + groupMemberInfo.Nickname = user[0].Nickname + groupMemberInfo.AppMangerLevel = user[0].AppMangerLevel + groupMemberInfo.FaceURL = user[0].FaceURL + return nil } -func setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error { - group, err := imdb.GetGroupInfoByGroupID(groupID) - if err != nil { - return utils.Wrap(err, "GetGroupInfoByGroupID failed") - } - err = utils2.GroupDBCopyOpenIM(groupInfo, group) +func (c *Check) setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error { + group, err := c.group.GetGroupInfos(context.Background(), []string{groupID}, true) if err != nil { - log.NewWarn("", "GroupDBCopyOpenIM failed ", groupID, err.Error()) - return nil + return err } + *groupInfo = *group[0] return nil } -func setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { - groupMember, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID) +func (c *Check) setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, userID) if err == nil { - return utils.Wrap(utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember), "") + *groupMemberInfo = *groupMember + return nil } - - user, err := imdb.GetUserByUserID(userID) + user, err := c.user.GetUsersInfos(context.Background(), []string{userID}, true) if err != nil { - return utils.Wrap(err, "") + return err } groupMemberInfo.GroupID = groupID - groupMemberInfo.UserID = user.UserID - groupMemberInfo.Nickname = user.Nickname - groupMemberInfo.AppMangerLevel = user.AppMangerLevel - groupMemberInfo.FaceURL = user.FaceURL + groupMemberInfo.UserID = user[0].UserID + groupMemberInfo.Nickname = user[0].Nickname + groupMemberInfo.AppMangerLevel = user[0].AppMangerLevel + groupMemberInfo.FaceURL = user[0].FaceURL return nil } -func setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { - groupMember, err := imdb.GetGroupOwnerInfoByGroupID(groupID) +func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + group, err := c.group.GetGroupInfo(context.Background(), groupID) if err != nil { - return utils.Wrap(err, "") + return err } - if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember); err != nil { - return utils.Wrap(err, "") + groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, group.OwnerUserID) + if err != nil { + return err } + *groupMemberInfo = *groupMember return nil } -func setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error { +func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error { user, err := imdb.GetUserByUserID(userID) if err != nil { return utils.Wrap(err, "") @@ -93,7 +94,7 @@ func setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) erro return nil } -func groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) { +func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) { log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID) var err error @@ -197,30 +198,30 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + c.Notification(&n) } // 创建群后调用 -func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) { +func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) { GroupCreatedTips := sdkws.GroupCreatedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, GroupOwnerUser: &sdkws.GroupMemberFullInfo{}} - if err := setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil { log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser) return } - err := setGroupInfo(groupID, GroupCreatedTips.Group) + err := c.setGroupInfo(groupID, GroupCreatedTips.Group) if err != nil { log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group) return } imdb.GetGroupOwnerInfoByGroupID(groupID) - if err := setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil { + if err := c.setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil { log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID) return } for _, v := range initMemberList { var groupMemberInfo sdkws.GroupMemberFullInfo - if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { + if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v) continue } @@ -229,7 +230,7 @@ func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberL break } } - groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID) + c.groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID) } // 群信息改变后掉用 @@ -238,9 +239,9 @@ func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberL // notification := "" // introduction := "" // faceURL := "" -func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) { +func (c *Check) GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) { GroupInfoChangedTips := sdkws.GroupInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil { + if err := c.setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } @@ -252,116 +253,116 @@ func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, GroupInfoChangedTips.Group.NeedVerification = needVerification.Value } - if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID) + c.groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID) } -func GroupMutedNotification(operationID, opUserID, groupID string) { +func (c *Check) GroupMutedNotification(operationID, opUserID, groupID string) { tips := sdkws.GroupMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { + if err := c.setGroupInfo(groupID, tips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID) } -func GroupCancelMutedNotification(operationID, opUserID, groupID string) { +func (c *Check) GroupCancelMutedNotification(operationID, opUserID, groupID string) { tips := sdkws.GroupCancelMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { + if err := c.setGroupInfo(groupID, tips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID) } -func GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) { +func (c *Check) GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) { tips := sdkws.GroupMemberMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} tips.MutedSeconds = mutedSeconds - if err := setGroupInfo(groupID, tips.Group); err != nil { + if err := c.setGroupInfo(groupID, tips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { + if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) return } - groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID) } -func GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberUserID string) { +func (c *Check) GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberUserID string) { tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { + if err := c.setGroupInfo(groupID, tips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { + if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) return } - groupNotification(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID) } -func GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) { +func (c *Check) GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) { if notificationType != constant.GroupMemberSetToAdminNotification && notificationType != constant.GroupMemberSetToOrdinaryUserNotification { log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType) return } tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { + if err := c.setGroupInfo(groupID, tips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { + if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) return } - groupNotification(notificationType, &tips, opUserID, groupID, "", operationID) + c.groupNotification(notificationType, &tips, opUserID, groupID, "", operationID) } -func GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) { +func (c *Check) GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) { tips := sdkws.GroupMemberCancelMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, tips.Group); err != nil { + if err := c.setGroupInfo(groupID, tips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { + if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) return } - groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID) } // message ReceiveJoinApplicationTips{ @@ -375,14 +376,14 @@ func GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMem // OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"` // // 申请进群后调用 -func JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) { +func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) { JoinGroupApplicationTips := sdkws.JoinGroupApplicationTips{Group: &sdkws.GroupInfo{}, Applicant: &sdkws.PublicUserInfo{}} - err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group) + err := c.setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group) if err != nil { log.Error(utils.OperationID(ctx), "setGroupInfo failed ", err.Error(), req.GroupID) return } - if err = setPublicUserInfo(utils.OpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { + if err = c.setPublicUserInfo(utils.OpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { log.Error(utils.OperationID(ctx), "setPublicUserInfo failed ", err.Error(), utils.OpUserID(ctx)) return } @@ -394,23 +395,23 @@ func JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGrou return } for _, v := range managerList { - groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, utils.OpUserID(ctx), "", v.UserID, utils.OperationID(ctx)) + c.groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, utils.OpUserID(ctx), "", v.UserID, utils.OperationID(ctx)) log.NewInfo(utils.OperationID(ctx), "Notification ", v) } } -func MemberQuitNotification(req *pbGroup.QuitGroupReq) { +func (c *Check) MemberQuitNotification(req *pbGroup.QuitGroupReq) { MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil { + if err := c.setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil { log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) return } - if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberQuitTips.QuitUser); err != nil { + if err := c.setOpUserInfo(req.OpUserID, req.GroupID, MemberQuitTips.QuitUser); err != nil { log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID) return } - groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID) } // message ApplicationProcessedTips{ @@ -421,18 +422,18 @@ func MemberQuitNotification(req *pbGroup.QuitGroupReq) { // } // // 处理进群请求后调用 -func GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseReq) { +func (c *Check) GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseReq) { GroupApplicationAcceptedTips := sdkws.GroupApplicationAcceptedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} - if err := setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil { + if err := c.setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil { log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationAcceptedTips.Group) return } - if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { + if err := c.setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser) return } - groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", req.FromUserID, req.OperationID) + c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", req.FromUserID, req.OperationID) adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) if err != nil { log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) @@ -443,21 +444,21 @@ func GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseR continue } GroupApplicationAcceptedTips.ReceiverAs = 1 - groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", v.UserID, req.OperationID) + c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", v.UserID, req.OperationID) } } -func GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseReq) { +func (c *Check) GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseReq) { GroupApplicationRejectedTips := sdkws.GroupApplicationRejectedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} - if err := setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil { + if err := c.setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil { log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationRejectedTips.Group) return } - if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { + if err := c.setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser) return } - groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", req.FromUserID, req.OperationID) + c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", req.FromUserID, req.OperationID) adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) if err != nil { log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) @@ -468,38 +469,38 @@ func GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseR continue } GroupApplicationRejectedTips.ReceiverAs = 1 - groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", v.UserID, req.OperationID) + c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", v.UserID, req.OperationID) } } -func GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) { +func (c *Check) GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) { GroupOwnerTransferredTips := sdkws.GroupOwnerTransferredTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, NewGroupOwner: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil { + if err := c.setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil { log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) return } - if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { + if err := c.setOpUserInfo(req.OpUserID, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) return } - if err := setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil { + if err := c.setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil { log.Error(req.OperationID, "setGroupMemberInfo failed", req.GroupID, req.NewOwnerUserID) return } - groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID) } -func GroupDismissedNotification(req *pbGroup.DismissGroupReq) { +func (c *Check) GroupDismissedNotification(req *pbGroup.DismissGroupReq) { tips := sdkws.GroupDismissedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, tips.Group); err != nil { + if err := c.setGroupInfo(req.GroupID, tips.Group); err != nil { log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) return } - if err := setOpUserInfo(req.OpUserID, req.GroupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(req.OpUserID, req.GroupID, tips.OpUser); err != nil { log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) return } - groupNotification(constant.GroupDismissedNotification, &tips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.GroupDismissedNotification, &tips, req.OpUserID, req.GroupID, "", req.OperationID) } // message MemberKickedTips{ @@ -510,25 +511,25 @@ func GroupDismissedNotification(req *pbGroup.DismissGroupReq) { // } // // 被踢后调用 -func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) { +func (c *Check) MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) { MemberKickedTips := sdkws.MemberKickedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil { + if err := c.setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil { log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) return } - if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil { + if err := c.setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil { log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID) return } for _, v := range kickedUserIDList { var groupMemberInfo sdkws.GroupMemberFullInfo - if err := setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil { + if err := c.setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil { log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.GroupID, v) continue } MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo) } - groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, req.GroupID, "", req.OperationID) // //for _, v := range kickedUserIDList { // groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID) @@ -543,50 +544,50 @@ func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList // } // // 被邀请进群后调用 -func MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) { +func (c *Check) MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) { MemberInvitedTips := sdkws.MemberInvitedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, MemberInvitedTips.Group); err != nil { + if err := c.setGroupInfo(groupID, MemberInvitedTips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil { + if err := c.setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } for _, v := range invitedUserIDList { var groupMemberInfo sdkws.GroupMemberFullInfo - if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { + if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID) continue } MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo) } - groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID) + c.groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID) } // 群成员主动申请进群,管理员同意后调用, -func MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { +func (c *Check) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil { + if err := c.setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil { log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberEnterTips.Group) return } - if err := setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil { + if err := c.setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil { log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser) return } - groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID) } -func MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) { +func (c *Check) MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) { MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} - if err := setGroupInfo(groupID, MemberEnterTips.Group); err != nil { + if err := c.setGroupInfo(groupID, MemberEnterTips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group) return } - if err := setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil { + if err := c.setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser) return } - groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID) + c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID) } diff --git a/internal/common/notification/msg.go b/internal/common/notification/msg.go index 23a78c135..ec74ed60e 100644 --- a/internal/common/notification/msg.go +++ b/internal/common/notification/msg.go @@ -3,18 +3,18 @@ package notification import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" - sdkws "Open_IM/pkg/proto/sdkws" + "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" ) -func DeleteMessageNotification(opUserID, userID string, seqList []uint32, operationID string) { +func (c *Check) DeleteMessageNotification(opUserID, userID string, seqList []uint32, operationID string) { DeleteMessageTips := sdkws.DeleteMessageTips{OpUserID: opUserID, UserID: userID, SeqList: seqList} - MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips) + c.MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips) } -func MessageNotification(operationID, sendID, recvID string, contentType int32, m proto.Message) { +func (c *Check) MessageNotification(operationID, sendID, recvID string, contentType int32, m proto.Message) { log.Debug(operationID, utils.GetSelfFuncName(), "args: ", m.String(), contentType) var err error var tips sdkws.TipsComm @@ -43,5 +43,5 @@ func MessageNotification(operationID, sendID, recvID string, contentType int32, log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + c.Notification(&n) } diff --git a/internal/common/notification/super_group.go b/internal/common/notification/super_group.go index 61130a290..2f073cf87 100644 --- a/internal/common/notification/super_group.go +++ b/internal/common/notification/super_group.go @@ -9,7 +9,7 @@ import ( //"github.com/golang/protobuf/proto" ) -func SuperGroupNotification(operationID, sendID, recvID string) { +func (c *Check) SuperGroupNotification(operationID, sendID, recvID string) { n := &NotificationMsg{ SendID: sendID, RecvID: recvID, @@ -19,5 +19,5 @@ func SuperGroupNotification(operationID, sendID, recvID string) { OperationID: operationID, } log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content)) - Notification(n) + c.Notification(n) } diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 7d2fdaf31..7b1dd3785 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -27,6 +27,7 @@ type msgServer struct { *rpcserver.RpcServer MsgInterface controller.MsgInterface Group *check.GroupChecker + User *check.UserCheck } type deleteMsg struct { diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 5fd12da67..d25d331d5 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -23,8 +23,6 @@ import ( ) type userServer struct { - rpcPort int - rpcRegisterName string *rpcserver.RpcServer controller.UserInterface } diff --git a/pkg/common/tokenverify/jwt_token.go b/pkg/common/tokenverify/jwt_token.go index ca428229d..9722830a7 100644 --- a/pkg/common/tokenverify/jwt_token.go +++ b/pkg/common/tokenverify/jwt_token.go @@ -87,3 +87,6 @@ func CheckAdmin(ctx context.Context) error { func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) { return GetClaimFromToken(string(redisToken.([]uint8))) } +func IsManagerUserID(opUserID string) bool { + return utils.IsContain(opUserID, config.Config.Manager.AppManagerUid) +} From b7645ffda69203a634a190e37a32975280dc2c1f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 13 Feb 2023 21:45:45 +0800 Subject: [PATCH 23/48] Error code standardization --- internal/common/notification/group.go | 63 +++++++++++++-------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/internal/common/notification/group.go b/internal/common/notification/group.go index 89e8c8d05..8ade090f9 100644 --- a/internal/common/notification/group.go +++ b/internal/common/notification/group.go @@ -5,6 +5,7 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" "Open_IM/pkg/common/tokenverify" + "Open_IM/pkg/common/tracelog" pbGroup "Open_IM/pkg/proto/group" "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" @@ -86,17 +87,16 @@ func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMe } func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error { - user, err := imdb.GetUserByUserID(userID) + user, err := c.user.GetPublicUserInfos(context.Background(), []string{userID}, true) if err != nil { - return utils.Wrap(err, "") + return err } - utils2.UserDBCopyOpenIMPublicUser(publicUserInfo, user) + *publicUserInfo = *user[0] return nil } func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) { log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID) - var err error var tips sdkws.TipsComm tips.Detail, err = proto.Marshal(m) @@ -109,25 +109,22 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr EnumsAsInts: false, EmitDefaults: false, } - tips.JsonDetail, _ = marshaler.MarshalToString(m) - var nickname string - - from, err := imdb.GetUserByUserID(sendID) - if err != nil { - log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID) - } - if from != nil { - nickname = from.Nickname - } + var nickname, toNickname string + if sendID != "" { - to, err := imdb.GetUserByUserID(recvUserID) - if err != nil { - log.NewWarn(operationID, "GetUserByUserID failed ", err.Error(), recvUserID) + from, err := c.user.GetUsersInfos(context.Background(), []string{sendID}, true) + if err != nil { + return + } + nickname = from[0].Nickname } - toNickname := "" - if to != nil { - toNickname = to.Nickname + if recvUserID != "" { + to, err := c.user.GetUsersInfos(context.Background(), []string{recvUserID}, true) + if err != nil { + return + } + toNickname = to[0].Nickname } cn := config.Config.Notification @@ -177,9 +174,10 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr n.SendID = sendID if groupID != "" { n.RecvID = groupID - group, err := imdb.GetGroupInfoByGroupID(groupID) + + group, err := c.group.GetGroupInfo(context.Background(), groupID) if err != nil { - log.NewError(operationID, "GetGroupInfoByGroupID failed ", err.Error(), groupID) + return } switch group.GroupType { case constant.NormalGroup: @@ -214,7 +212,7 @@ func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string, log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group) return } - imdb.GetGroupOwnerInfoByGroupID(groupID) + if err := c.setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil { log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID) return @@ -380,38 +378,37 @@ func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGro JoinGroupApplicationTips := sdkws.JoinGroupApplicationTips{Group: &sdkws.GroupInfo{}, Applicant: &sdkws.PublicUserInfo{}} err := c.setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group) if err != nil { - log.Error(utils.OperationID(ctx), "setGroupInfo failed ", err.Error(), req.GroupID) + return } - if err = c.setPublicUserInfo(utils.OpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { - log.Error(utils.OperationID(ctx), "setPublicUserInfo failed ", err.Error(), utils.OpUserID(ctx)) + if err = c.setPublicUserInfo(tracelog.GetOpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { + return } JoinGroupApplicationTips.ReqMsg = req.ReqMessage managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) if err != nil { - log.NewError(utils.OperationID(ctx), "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID) + return } for _, v := range managerList { - c.groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, utils.OpUserID(ctx), "", v.UserID, utils.OperationID(ctx)) - log.NewInfo(utils.OperationID(ctx), "Notification ", v) + c.groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, tracelog.GetOpUserID(ctx), "", v.UserID, utils.OperationID(ctx)) + } } func (c *Check) MemberQuitNotification(req *pbGroup.QuitGroupReq) { MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}} if err := c.setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil { - log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) + return } - if err := c.setOpUserInfo(req.OpUserID, req.GroupID, MemberQuitTips.QuitUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID) + if err := c.setOpUserInfo(tracelog.GetOpUserID(), req.GroupID, MemberQuitTips.QuitUser); err != nil { return } - c.groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.MemberQuitNotification, &MemberQuitTips, tracelog.GetOpUserID(), req.GroupID, "", req.OperationID) } // message ApplicationProcessedTips{ From c5f1c940d86d4bc3b9408be537cc1b38218b6820 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 09:05:38 +0800 Subject: [PATCH 24/48] Error code standardization --- internal/common/notification/group.go | 58 ++++++++++----------------- internal/rpc/group/group.go | 45 +++++++++++---------- 2 files changed, 45 insertions(+), 58 deletions(-) diff --git a/internal/common/notification/group.go b/internal/common/notification/group.go index 8ade090f9..05b286600 100644 --- a/internal/common/notification/group.go +++ b/internal/common/notification/group.go @@ -389,7 +389,6 @@ func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGro managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) if err != nil { - return } for _, v := range managerList { @@ -398,17 +397,17 @@ func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGro } } -func (c *Check) MemberQuitNotification(req *pbGroup.QuitGroupReq) { +func (c *Check) MemberQuitNotification(ctx context.Context, req *pbGroup.QuitGroupReq) { MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}} if err := c.setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil { return } - if err := c.setOpUserInfo(tracelog.GetOpUserID(), req.GroupID, MemberQuitTips.QuitUser); err != nil { + if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, MemberQuitTips.QuitUser); err != nil { return } - c.groupNotification(constant.MemberQuitNotification, &MemberQuitTips, tracelog.GetOpUserID(), req.GroupID, "", req.OperationID) + c.groupNotification(constant.MemberQuitNotification, &MemberQuitTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) } // message ApplicationProcessedTips{ @@ -419,18 +418,16 @@ func (c *Check) MemberQuitNotification(req *pbGroup.QuitGroupReq) { // } // // 处理进群请求后调用 -func (c *Check) GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseReq) { +func (c *Check) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { GroupApplicationAcceptedTips := sdkws.GroupApplicationAcceptedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} if err := c.setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationAcceptedTips.Group) return } - if err := c.setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser) + if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { return } - c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", req.FromUserID, req.OperationID) + c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx)) adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) if err != nil { log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) @@ -445,20 +442,17 @@ func (c *Check) GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicati } } -func (c *Check) GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseReq) { +func (c *Check) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { GroupApplicationRejectedTips := sdkws.GroupApplicationRejectedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} if err := c.setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationRejectedTips.Group) return } - if err := c.setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser) + if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { return } - c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", req.FromUserID, req.OperationID) + c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx)) adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) if err != nil { - log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) return } for _, v := range adminList { @@ -466,38 +460,35 @@ func (c *Check) GroupApplicationRejectedNotification(req *pbGroup.GroupApplicati continue } GroupApplicationRejectedTips.ReceiverAs = 1 - c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", v.UserID, req.OperationID) + c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", v.UserID, tracelog.GetOperationID(ctx)) } } -func (c *Check) GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) { +func (c *Check) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) { GroupOwnerTransferredTips := sdkws.GroupOwnerTransferredTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, NewGroupOwner: &sdkws.GroupMemberFullInfo{}} if err := c.setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) return } - if err := c.setOpUserInfo(req.OpUserID, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) + if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { return } if err := c.setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil { - log.Error(req.OperationID, "setGroupMemberInfo failed", req.GroupID, req.NewOwnerUserID) return } - c.groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) } -func (c *Check) GroupDismissedNotification(req *pbGroup.DismissGroupReq) { +func (c *Check) GroupDismissedNotification(ctx context.Context, req *pbGroup.DismissGroupReq) { tips := sdkws.GroupDismissedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} if err := c.setGroupInfo(req.GroupID, tips.Group); err != nil { - log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) + return } - if err := c.setOpUserInfo(req.OpUserID, req.GroupID, tips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID) + if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, tips.OpUser); err != nil { + return } - c.groupNotification(constant.GroupDismissedNotification, &tips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.GroupDismissedNotification, &tips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) } // message MemberKickedTips{ @@ -508,25 +499,22 @@ func (c *Check) GroupDismissedNotification(req *pbGroup.DismissGroupReq) { // } // // 被踢后调用 -func (c *Check) MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) { +func (c *Check) MemberKickedNotification(ctx context.Context, req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) { MemberKickedTips := sdkws.MemberKickedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} if err := c.setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil { - log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID) return } - if err := c.setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil { - log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID) + if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, MemberKickedTips.OpUser); err != nil { return } for _, v := range kickedUserIDList { var groupMemberInfo sdkws.GroupMemberFullInfo if err := c.setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil { - log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.GroupID, v) continue } MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo) } - c.groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.MemberKickedNotification, &MemberKickedTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) // //for _, v := range kickedUserIDList { // groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID) @@ -566,14 +554,12 @@ func (c *Check) MemberInvitedNotification(operationID, groupID, opUserID, reason func (c *Check) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} if err := c.setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil { - log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberEnterTips.Group) return } if err := c.setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil { - log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser) return } - c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID) + c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) } func (c *Check) MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) { diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 8735f8a14..db382bb20 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -48,6 +48,7 @@ type groupServer struct { GroupInterface controller.GroupInterface registerCenter discoveryRegistry.SvcDiscoveryRegistry user *check.UserCheck + notification *notification.Check } // @@ -281,11 +282,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if req.GroupInfo.GroupType == constant.SuperGroup { go func() { for _, userID := range userIDs { - notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } }() } else { - notification.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs) + s.notification.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs) } return resp, nil } @@ -379,7 +380,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, request := range requests { - notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ + s.notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ GroupID: request.GroupID, ReqMessage: request.ReqMsg, JoinSource: request.JoinSource, @@ -395,7 +396,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, userID := range req.InvitedUserIDs { - notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } } else { opUserID := tracelog.GetOpUserID(ctx) @@ -416,7 +417,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil { return nil, err } - notification.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) + s.notification.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) } return resp, nil } @@ -493,7 +494,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou } go func() { for _, userID := range req.KickedUserIDs { - notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) } }() } else { @@ -533,7 +534,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou if err := s.GroupInterface.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil { return nil, err } - notification.MemberKickedNotification(req, req.KickedUserIDs) + s.notification.MemberKickedNotification(ctx, req, req.KickedUserIDs) } return resp, nil } @@ -700,10 +701,10 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup } if !join { if req.HandleResult == constant.GroupResponseAgree { - notification.GroupApplicationAcceptedNotification(req) - notification.MemberEnterNotification(ctx, req) + s.notification.GroupApplicationAcceptedNotification(ctx, req) + s.notification.MemberEnterNotification(ctx, req) } else if req.HandleResult == constant.GroupResponseRefuse { - notification.GroupApplicationRejectedNotification(req) + s.notification.GroupApplicationRejectedNotification(ctx, req) } } return resp, nil @@ -741,7 +742,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil { return nil, err } - notification.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) + s.notification.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) return resp, nil } groupRequest := relationTb.GroupRequestModel{ @@ -754,7 +755,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil { return nil, err } - notification.JoinGroupApplicationNotification(ctx, req) + s.notification.JoinGroupApplicationNotification(ctx, req) return resp, nil } @@ -768,13 +769,13 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil { return nil, err } - notification.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) + s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) } else { _, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx)) if err != nil { return nil, err } - notification.MemberQuitNotification(req) + s.notification.MemberQuitNotification(ctx, req) } return resp, nil } @@ -808,7 +809,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf if err != nil { return nil, err } - notification.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) + s.notification.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) if req.GroupInfoForSet.Notification != "" { s.GroupNotification(ctx, group.GroupID) } @@ -858,7 +859,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans if err := s.GroupInterface.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID, newOwner.RoleLevel); err != nil { return nil, err } - notification.GroupOwnerTransferredNotification(req) + s.notification.GroupOwnerTransferredNotification(ctx, req) return resp, nil } @@ -990,7 +991,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou return nil, err } } else { - notification.GroupDismissedNotification(req) + s.notification.GroupDismissedNotification(ctx, req) } return resp, nil } @@ -1014,7 +1015,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - notification.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds) + s.notification.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds) return resp, nil } @@ -1037,7 +1038,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - notification.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID) + s.notification.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID) return resp, nil } @@ -1049,7 +1050,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil { return nil, err } - notification.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + s.notification.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) return resp, nil } @@ -1061,7 +1062,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil { return nil, err } - notification.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + s.notification.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) return resp, nil } @@ -1138,7 +1139,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr return nil, err } for _, member := range req.Members { - notification.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID) + s.notification.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID) } return resp, nil } From a61a3253a592d2c6801aa0b2eab86fbf237d2ca1 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 14 Feb 2023 10:33:15 +0800 Subject: [PATCH 25/48] group rpc GetGroupMemberRoleLevel --- internal/rpc/group/group.go | 24 ++ pkg/proto/group/group.pb.go | 477 +++++++++++++++++++++++------------- pkg/proto/group/group.proto | 11 +- 3 files changed, 334 insertions(+), 178 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index db382bb20..bd964b5b0 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -1208,3 +1208,27 @@ func (s *groupServer) GetGroupMemberUserID(ctx context.Context, req *pbGroup.Get } return resp, nil } + +func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.GetGroupMemberRoleLevelReq) (*pbGroup.GetGroupMemberRoleLevelResp, error) { + resp := &pbGroup.GetGroupMemberRoleLevelResp{} + if len(req.RoleLevels) == 0 { + return nil, constant.ErrArgs.Wrap("RoleLevels empty") + } + members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, nil, req.RoleLevels) + if err != nil { + return nil, err + } + nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) { + return e.UserID, e.Nickname == "" + }), true) + if err != nil { + return nil, err + } + resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *sdkws.GroupMemberFullInfo { + if e.Nickname == "" { + e.Nickname = nameMap[e.UserID] + } + return DbToPbGroupMembersCMSResp(e) + }) + return resp, nil +} diff --git a/pkg/proto/group/group.pb.go b/pkg/proto/group/group.pb.go index 0597a871a..86bb1a00d 100644 --- a/pkg/proto/group/group.pb.go +++ b/pkg/proto/group/group.pb.go @@ -39,7 +39,7 @@ func (m *CreateGroupReq) Reset() { *m = CreateGroupReq{} } func (m *CreateGroupReq) String() string { return proto.CompactTextString(m) } func (*CreateGroupReq) ProtoMessage() {} func (*CreateGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{0} + return fileDescriptor_group_4a94cf46004e5ca3, []int{0} } func (m *CreateGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateGroupReq.Unmarshal(m, b) @@ -98,7 +98,7 @@ func (m *CreateGroupResp) Reset() { *m = CreateGroupResp{} } func (m *CreateGroupResp) String() string { return proto.CompactTextString(m) } func (*CreateGroupResp) ProtoMessage() {} func (*CreateGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{1} + return fileDescriptor_group_4a94cf46004e5ca3, []int{1} } func (m *CreateGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateGroupResp.Unmarshal(m, b) @@ -136,7 +136,7 @@ func (m *GetGroupsInfoReq) Reset() { *m = GetGroupsInfoReq{} } func (m *GetGroupsInfoReq) String() string { return proto.CompactTextString(m) } func (*GetGroupsInfoReq) ProtoMessage() {} func (*GetGroupsInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{2} + return fileDescriptor_group_4a94cf46004e5ca3, []int{2} } func (m *GetGroupsInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsInfoReq.Unmarshal(m, b) @@ -174,7 +174,7 @@ func (m *GetGroupsInfoResp) Reset() { *m = GetGroupsInfoResp{} } func (m *GetGroupsInfoResp) String() string { return proto.CompactTextString(m) } func (*GetGroupsInfoResp) ProtoMessage() {} func (*GetGroupsInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{3} + return fileDescriptor_group_4a94cf46004e5ca3, []int{3} } func (m *GetGroupsInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsInfoResp.Unmarshal(m, b) @@ -212,7 +212,7 @@ func (m *SetGroupInfoReq) Reset() { *m = SetGroupInfoReq{} } func (m *SetGroupInfoReq) String() string { return proto.CompactTextString(m) } func (*SetGroupInfoReq) ProtoMessage() {} func (*SetGroupInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{4} + return fileDescriptor_group_4a94cf46004e5ca3, []int{4} } func (m *SetGroupInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupInfoReq.Unmarshal(m, b) @@ -249,7 +249,7 @@ func (m *SetGroupInfoResp) Reset() { *m = SetGroupInfoResp{} } func (m *SetGroupInfoResp) String() string { return proto.CompactTextString(m) } func (*SetGroupInfoResp) ProtoMessage() {} func (*SetGroupInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{5} + return fileDescriptor_group_4a94cf46004e5ca3, []int{5} } func (m *SetGroupInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupInfoResp.Unmarshal(m, b) @@ -281,7 +281,7 @@ func (m *GetGroupApplicationListReq) Reset() { *m = GetGroupApplicationL func (m *GetGroupApplicationListReq) String() string { return proto.CompactTextString(m) } func (*GetGroupApplicationListReq) ProtoMessage() {} func (*GetGroupApplicationListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{6} + return fileDescriptor_group_4a94cf46004e5ca3, []int{6} } func (m *GetGroupApplicationListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupApplicationListReq.Unmarshal(m, b) @@ -327,7 +327,7 @@ func (m *GetGroupApplicationListResp) Reset() { *m = GetGroupApplication func (m *GetGroupApplicationListResp) String() string { return proto.CompactTextString(m) } func (*GetGroupApplicationListResp) ProtoMessage() {} func (*GetGroupApplicationListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{7} + return fileDescriptor_group_4a94cf46004e5ca3, []int{7} } func (m *GetGroupApplicationListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupApplicationListResp.Unmarshal(m, b) @@ -373,7 +373,7 @@ func (m *GetUserReqApplicationListReq) Reset() { *m = GetUserReqApplicat func (m *GetUserReqApplicationListReq) String() string { return proto.CompactTextString(m) } func (*GetUserReqApplicationListReq) ProtoMessage() {} func (*GetUserReqApplicationListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{8} + return fileDescriptor_group_4a94cf46004e5ca3, []int{8} } func (m *GetUserReqApplicationListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserReqApplicationListReq.Unmarshal(m, b) @@ -419,7 +419,7 @@ func (m *GetUserReqApplicationListResp) Reset() { *m = GetUserReqApplica func (m *GetUserReqApplicationListResp) String() string { return proto.CompactTextString(m) } func (*GetUserReqApplicationListResp) ProtoMessage() {} func (*GetUserReqApplicationListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{9} + return fileDescriptor_group_4a94cf46004e5ca3, []int{9} } func (m *GetUserReqApplicationListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserReqApplicationListResp.Unmarshal(m, b) @@ -466,7 +466,7 @@ func (m *TransferGroupOwnerReq) Reset() { *m = TransferGroupOwnerReq{} } func (m *TransferGroupOwnerReq) String() string { return proto.CompactTextString(m) } func (*TransferGroupOwnerReq) ProtoMessage() {} func (*TransferGroupOwnerReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{10} + return fileDescriptor_group_4a94cf46004e5ca3, []int{10} } func (m *TransferGroupOwnerReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_TransferGroupOwnerReq.Unmarshal(m, b) @@ -517,7 +517,7 @@ func (m *TransferGroupOwnerResp) Reset() { *m = TransferGroupOwnerResp{} func (m *TransferGroupOwnerResp) String() string { return proto.CompactTextString(m) } func (*TransferGroupOwnerResp) ProtoMessage() {} func (*TransferGroupOwnerResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{11} + return fileDescriptor_group_4a94cf46004e5ca3, []int{11} } func (m *TransferGroupOwnerResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_TransferGroupOwnerResp.Unmarshal(m, b) @@ -551,7 +551,7 @@ func (m *JoinGroupReq) Reset() { *m = JoinGroupReq{} } func (m *JoinGroupReq) String() string { return proto.CompactTextString(m) } func (*JoinGroupReq) ProtoMessage() {} func (*JoinGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{12} + return fileDescriptor_group_4a94cf46004e5ca3, []int{12} } func (m *JoinGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_JoinGroupReq.Unmarshal(m, b) @@ -609,7 +609,7 @@ func (m *JoinGroupResp) Reset() { *m = JoinGroupResp{} } func (m *JoinGroupResp) String() string { return proto.CompactTextString(m) } func (*JoinGroupResp) ProtoMessage() {} func (*JoinGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{13} + return fileDescriptor_group_4a94cf46004e5ca3, []int{13} } func (m *JoinGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_JoinGroupResp.Unmarshal(m, b) @@ -643,7 +643,7 @@ func (m *GroupApplicationResponseReq) Reset() { *m = GroupApplicationRes func (m *GroupApplicationResponseReq) String() string { return proto.CompactTextString(m) } func (*GroupApplicationResponseReq) ProtoMessage() {} func (*GroupApplicationResponseReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{14} + return fileDescriptor_group_4a94cf46004e5ca3, []int{14} } func (m *GroupApplicationResponseReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupApplicationResponseReq.Unmarshal(m, b) @@ -701,7 +701,7 @@ func (m *GroupApplicationResponseResp) Reset() { *m = GroupApplicationRe func (m *GroupApplicationResponseResp) String() string { return proto.CompactTextString(m) } func (*GroupApplicationResponseResp) ProtoMessage() {} func (*GroupApplicationResponseResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{15} + return fileDescriptor_group_4a94cf46004e5ca3, []int{15} } func (m *GroupApplicationResponseResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupApplicationResponseResp.Unmarshal(m, b) @@ -732,7 +732,7 @@ func (m *QuitGroupReq) Reset() { *m = QuitGroupReq{} } func (m *QuitGroupReq) String() string { return proto.CompactTextString(m) } func (*QuitGroupReq) ProtoMessage() {} func (*QuitGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{16} + return fileDescriptor_group_4a94cf46004e5ca3, []int{16} } func (m *QuitGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_QuitGroupReq.Unmarshal(m, b) @@ -769,7 +769,7 @@ func (m *QuitGroupResp) Reset() { *m = QuitGroupResp{} } func (m *QuitGroupResp) String() string { return proto.CompactTextString(m) } func (*QuitGroupResp) ProtoMessage() {} func (*QuitGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{17} + return fileDescriptor_group_4a94cf46004e5ca3, []int{17} } func (m *QuitGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_QuitGroupResp.Unmarshal(m, b) @@ -802,7 +802,7 @@ func (m *GetGroupMemberListReq) Reset() { *m = GetGroupMemberListReq{} } func (m *GetGroupMemberListReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberListReq) ProtoMessage() {} func (*GetGroupMemberListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{18} + return fileDescriptor_group_4a94cf46004e5ca3, []int{18} } func (m *GetGroupMemberListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberListReq.Unmarshal(m, b) @@ -855,7 +855,7 @@ func (m *GetGroupMemberListResp) Reset() { *m = GetGroupMemberListResp{} func (m *GetGroupMemberListResp) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberListResp) ProtoMessage() {} func (*GetGroupMemberListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{19} + return fileDescriptor_group_4a94cf46004e5ca3, []int{19} } func (m *GetGroupMemberListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberListResp.Unmarshal(m, b) @@ -901,7 +901,7 @@ func (m *GetGroupMembersInfoReq) Reset() { *m = GetGroupMembersInfoReq{} func (m *GetGroupMembersInfoReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersInfoReq) ProtoMessage() {} func (*GetGroupMembersInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{20} + return fileDescriptor_group_4a94cf46004e5ca3, []int{20} } func (m *GetGroupMembersInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersInfoReq.Unmarshal(m, b) @@ -946,7 +946,7 @@ func (m *GetGroupMembersInfoResp) Reset() { *m = GetGroupMembersInfoResp func (m *GetGroupMembersInfoResp) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersInfoResp) ProtoMessage() {} func (*GetGroupMembersInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{21} + return fileDescriptor_group_4a94cf46004e5ca3, []int{21} } func (m *GetGroupMembersInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersInfoResp.Unmarshal(m, b) @@ -986,7 +986,7 @@ func (m *KickGroupMemberReq) Reset() { *m = KickGroupMemberReq{} } func (m *KickGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*KickGroupMemberReq) ProtoMessage() {} func (*KickGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{22} + return fileDescriptor_group_4a94cf46004e5ca3, []int{22} } func (m *KickGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KickGroupMemberReq.Unmarshal(m, b) @@ -1037,7 +1037,7 @@ func (m *KickGroupMemberResp) Reset() { *m = KickGroupMemberResp{} } func (m *KickGroupMemberResp) String() string { return proto.CompactTextString(m) } func (*KickGroupMemberResp) ProtoMessage() {} func (*KickGroupMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{23} + return fileDescriptor_group_4a94cf46004e5ca3, []int{23} } func (m *KickGroupMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KickGroupMemberResp.Unmarshal(m, b) @@ -1069,7 +1069,7 @@ func (m *GetJoinedGroupListReq) Reset() { *m = GetJoinedGroupListReq{} } func (m *GetJoinedGroupListReq) String() string { return proto.CompactTextString(m) } func (*GetJoinedGroupListReq) ProtoMessage() {} func (*GetJoinedGroupListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{24} + return fileDescriptor_group_4a94cf46004e5ca3, []int{24} } func (m *GetJoinedGroupListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedGroupListReq.Unmarshal(m, b) @@ -1115,7 +1115,7 @@ func (m *GetJoinedGroupListResp) Reset() { *m = GetJoinedGroupListResp{} func (m *GetJoinedGroupListResp) String() string { return proto.CompactTextString(m) } func (*GetJoinedGroupListResp) ProtoMessage() {} func (*GetJoinedGroupListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{25} + return fileDescriptor_group_4a94cf46004e5ca3, []int{25} } func (m *GetJoinedGroupListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedGroupListResp.Unmarshal(m, b) @@ -1162,7 +1162,7 @@ func (m *InviteUserToGroupReq) Reset() { *m = InviteUserToGroupReq{} } func (m *InviteUserToGroupReq) String() string { return proto.CompactTextString(m) } func (*InviteUserToGroupReq) ProtoMessage() {} func (*InviteUserToGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{26} + return fileDescriptor_group_4a94cf46004e5ca3, []int{26} } func (m *InviteUserToGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_InviteUserToGroupReq.Unmarshal(m, b) @@ -1213,7 +1213,7 @@ func (m *InviteUserToGroupResp) Reset() { *m = InviteUserToGroupResp{} } func (m *InviteUserToGroupResp) String() string { return proto.CompactTextString(m) } func (*InviteUserToGroupResp) ProtoMessage() {} func (*InviteUserToGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{27} + return fileDescriptor_group_4a94cf46004e5ca3, []int{27} } func (m *InviteUserToGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_InviteUserToGroupResp.Unmarshal(m, b) @@ -1245,7 +1245,7 @@ func (m *GetGroupAllMemberReq) Reset() { *m = GetGroupAllMemberReq{} } func (m *GetGroupAllMemberReq) String() string { return proto.CompactTextString(m) } func (*GetGroupAllMemberReq) ProtoMessage() {} func (*GetGroupAllMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{28} + return fileDescriptor_group_4a94cf46004e5ca3, []int{28} } func (m *GetGroupAllMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAllMemberReq.Unmarshal(m, b) @@ -1290,7 +1290,7 @@ func (m *GetGroupAllMemberResp) Reset() { *m = GetGroupAllMemberResp{} } func (m *GetGroupAllMemberResp) String() string { return proto.CompactTextString(m) } func (*GetGroupAllMemberResp) ProtoMessage() {} func (*GetGroupAllMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{29} + return fileDescriptor_group_4a94cf46004e5ca3, []int{29} } func (m *GetGroupAllMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAllMemberResp.Unmarshal(m, b) @@ -1330,7 +1330,7 @@ func (m *CMSGroup) Reset() { *m = CMSGroup{} } func (m *CMSGroup) String() string { return proto.CompactTextString(m) } func (*CMSGroup) ProtoMessage() {} func (*CMSGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{30} + return fileDescriptor_group_4a94cf46004e5ca3, []int{30} } func (m *CMSGroup) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CMSGroup.Unmarshal(m, b) @@ -1384,7 +1384,7 @@ func (m *GetGroupsReq) Reset() { *m = GetGroupsReq{} } func (m *GetGroupsReq) String() string { return proto.CompactTextString(m) } func (*GetGroupsReq) ProtoMessage() {} func (*GetGroupsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{31} + return fileDescriptor_group_4a94cf46004e5ca3, []int{31} } func (m *GetGroupsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsReq.Unmarshal(m, b) @@ -1437,7 +1437,7 @@ func (m *GetGroupsResp) Reset() { *m = GetGroupsResp{} } func (m *GetGroupsResp) String() string { return proto.CompactTextString(m) } func (*GetGroupsResp) ProtoMessage() {} func (*GetGroupsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{32} + return fileDescriptor_group_4a94cf46004e5ca3, []int{32} } func (m *GetGroupsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsResp.Unmarshal(m, b) @@ -1482,7 +1482,7 @@ func (m *GetGroupMemberReq) Reset() { *m = GetGroupMemberReq{} } func (m *GetGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberReq) ProtoMessage() {} func (*GetGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{33} + return fileDescriptor_group_4a94cf46004e5ca3, []int{33} } func (m *GetGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberReq.Unmarshal(m, b) @@ -1522,7 +1522,7 @@ func (m *GetGroupMembersCMSReq) Reset() { *m = GetGroupMembersCMSReq{} } func (m *GetGroupMembersCMSReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersCMSReq) ProtoMessage() {} func (*GetGroupMembersCMSReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{34} + return fileDescriptor_group_4a94cf46004e5ca3, []int{34} } func (m *GetGroupMembersCMSReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersCMSReq.Unmarshal(m, b) @@ -1575,7 +1575,7 @@ func (m *GetGroupMembersCMSResp) Reset() { *m = GetGroupMembersCMSResp{} func (m *GetGroupMembersCMSResp) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersCMSResp) ProtoMessage() {} func (*GetGroupMembersCMSResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{35} + return fileDescriptor_group_4a94cf46004e5ca3, []int{35} } func (m *GetGroupMembersCMSResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersCMSResp.Unmarshal(m, b) @@ -1620,7 +1620,7 @@ func (m *DismissGroupReq) Reset() { *m = DismissGroupReq{} } func (m *DismissGroupReq) String() string { return proto.CompactTextString(m) } func (*DismissGroupReq) ProtoMessage() {} func (*DismissGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{36} + return fileDescriptor_group_4a94cf46004e5ca3, []int{36} } func (m *DismissGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DismissGroupReq.Unmarshal(m, b) @@ -1657,7 +1657,7 @@ func (m *DismissGroupResp) Reset() { *m = DismissGroupResp{} } func (m *DismissGroupResp) String() string { return proto.CompactTextString(m) } func (*DismissGroupResp) ProtoMessage() {} func (*DismissGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{37} + return fileDescriptor_group_4a94cf46004e5ca3, []int{37} } func (m *DismissGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DismissGroupResp.Unmarshal(m, b) @@ -1690,7 +1690,7 @@ func (m *MuteGroupMemberReq) Reset() { *m = MuteGroupMemberReq{} } func (m *MuteGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*MuteGroupMemberReq) ProtoMessage() {} func (*MuteGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{38} + return fileDescriptor_group_4a94cf46004e5ca3, []int{38} } func (m *MuteGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupMemberReq.Unmarshal(m, b) @@ -1741,7 +1741,7 @@ func (m *MuteGroupMemberResp) Reset() { *m = MuteGroupMemberResp{} } func (m *MuteGroupMemberResp) String() string { return proto.CompactTextString(m) } func (*MuteGroupMemberResp) ProtoMessage() {} func (*MuteGroupMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{39} + return fileDescriptor_group_4a94cf46004e5ca3, []int{39} } func (m *MuteGroupMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupMemberResp.Unmarshal(m, b) @@ -1773,7 +1773,7 @@ func (m *CancelMuteGroupMemberReq) Reset() { *m = CancelMuteGroupMemberR func (m *CancelMuteGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupMemberReq) ProtoMessage() {} func (*CancelMuteGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{40} + return fileDescriptor_group_4a94cf46004e5ca3, []int{40} } func (m *CancelMuteGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupMemberReq.Unmarshal(m, b) @@ -1817,7 +1817,7 @@ func (m *CancelMuteGroupMemberResp) Reset() { *m = CancelMuteGroupMember func (m *CancelMuteGroupMemberResp) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupMemberResp) ProtoMessage() {} func (*CancelMuteGroupMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{41} + return fileDescriptor_group_4a94cf46004e5ca3, []int{41} } func (m *CancelMuteGroupMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupMemberResp.Unmarshal(m, b) @@ -1848,7 +1848,7 @@ func (m *MuteGroupReq) Reset() { *m = MuteGroupReq{} } func (m *MuteGroupReq) String() string { return proto.CompactTextString(m) } func (*MuteGroupReq) ProtoMessage() {} func (*MuteGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{42} + return fileDescriptor_group_4a94cf46004e5ca3, []int{42} } func (m *MuteGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupReq.Unmarshal(m, b) @@ -1885,7 +1885,7 @@ func (m *MuteGroupResp) Reset() { *m = MuteGroupResp{} } func (m *MuteGroupResp) String() string { return proto.CompactTextString(m) } func (*MuteGroupResp) ProtoMessage() {} func (*MuteGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{43} + return fileDescriptor_group_4a94cf46004e5ca3, []int{43} } func (m *MuteGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupResp.Unmarshal(m, b) @@ -1916,7 +1916,7 @@ func (m *CancelMuteGroupReq) Reset() { *m = CancelMuteGroupReq{} } func (m *CancelMuteGroupReq) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupReq) ProtoMessage() {} func (*CancelMuteGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{44} + return fileDescriptor_group_4a94cf46004e5ca3, []int{44} } func (m *CancelMuteGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupReq.Unmarshal(m, b) @@ -1953,7 +1953,7 @@ func (m *CancelMuteGroupResp) Reset() { *m = CancelMuteGroupResp{} } func (m *CancelMuteGroupResp) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupResp) ProtoMessage() {} func (*CancelMuteGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{45} + return fileDescriptor_group_4a94cf46004e5ca3, []int{45} } func (m *CancelMuteGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupResp.Unmarshal(m, b) @@ -1984,7 +1984,7 @@ func (m *GetJoinedSuperGroupListReq) Reset() { *m = GetJoinedSuperGroupL func (m *GetJoinedSuperGroupListReq) String() string { return proto.CompactTextString(m) } func (*GetJoinedSuperGroupListReq) ProtoMessage() {} func (*GetJoinedSuperGroupListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{46} + return fileDescriptor_group_4a94cf46004e5ca3, []int{46} } func (m *GetJoinedSuperGroupListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedSuperGroupListReq.Unmarshal(m, b) @@ -2022,7 +2022,7 @@ func (m *GetJoinedSuperGroupListResp) Reset() { *m = GetJoinedSuperGroup func (m *GetJoinedSuperGroupListResp) String() string { return proto.CompactTextString(m) } func (*GetJoinedSuperGroupListResp) ProtoMessage() {} func (*GetJoinedSuperGroupListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{47} + return fileDescriptor_group_4a94cf46004e5ca3, []int{47} } func (m *GetJoinedSuperGroupListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedSuperGroupListResp.Unmarshal(m, b) @@ -2060,7 +2060,7 @@ func (m *GetSuperGroupsInfoReq) Reset() { *m = GetSuperGroupsInfoReq{} } func (m *GetSuperGroupsInfoReq) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupsInfoReq) ProtoMessage() {} func (*GetSuperGroupsInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{48} + return fileDescriptor_group_4a94cf46004e5ca3, []int{48} } func (m *GetSuperGroupsInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupsInfoReq.Unmarshal(m, b) @@ -2098,7 +2098,7 @@ func (m *GetSuperGroupsInfoResp) Reset() { *m = GetSuperGroupsInfoResp{} func (m *GetSuperGroupsInfoResp) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupsInfoResp) ProtoMessage() {} func (*GetSuperGroupsInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{49} + return fileDescriptor_group_4a94cf46004e5ca3, []int{49} } func (m *GetSuperGroupsInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupsInfoResp.Unmarshal(m, b) @@ -2141,7 +2141,7 @@ func (m *SetGroupMemberInfo) Reset() { *m = SetGroupMemberInfo{} } func (m *SetGroupMemberInfo) String() string { return proto.CompactTextString(m) } func (*SetGroupMemberInfo) ProtoMessage() {} func (*SetGroupMemberInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{50} + return fileDescriptor_group_4a94cf46004e5ca3, []int{50} } func (m *SetGroupMemberInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupMemberInfo.Unmarshal(m, b) @@ -2214,7 +2214,7 @@ func (m *SetGroupMemberInfoReq) Reset() { *m = SetGroupMemberInfoReq{} } func (m *SetGroupMemberInfoReq) String() string { return proto.CompactTextString(m) } func (*SetGroupMemberInfoReq) ProtoMessage() {} func (*SetGroupMemberInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{51} + return fileDescriptor_group_4a94cf46004e5ca3, []int{51} } func (m *SetGroupMemberInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupMemberInfoReq.Unmarshal(m, b) @@ -2251,7 +2251,7 @@ func (m *SetGroupMemberInfoResp) Reset() { *m = SetGroupMemberInfoResp{} func (m *SetGroupMemberInfoResp) String() string { return proto.CompactTextString(m) } func (*SetGroupMemberInfoResp) ProtoMessage() {} func (*SetGroupMemberInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{52} + return fileDescriptor_group_4a94cf46004e5ca3, []int{52} } func (m *SetGroupMemberInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupMemberInfoResp.Unmarshal(m, b) @@ -2282,7 +2282,7 @@ func (m *GetGroupAbstractInfoReq) Reset() { *m = GetGroupAbstractInfoReq func (m *GetGroupAbstractInfoReq) String() string { return proto.CompactTextString(m) } func (*GetGroupAbstractInfoReq) ProtoMessage() {} func (*GetGroupAbstractInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{53} + return fileDescriptor_group_4a94cf46004e5ca3, []int{53} } func (m *GetGroupAbstractInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAbstractInfoReq.Unmarshal(m, b) @@ -2322,7 +2322,7 @@ func (m *GroupAbstractInfo) Reset() { *m = GroupAbstractInfo{} } func (m *GroupAbstractInfo) String() string { return proto.CompactTextString(m) } func (*GroupAbstractInfo) ProtoMessage() {} func (*GroupAbstractInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{54} + return fileDescriptor_group_4a94cf46004e5ca3, []int{54} } func (m *GroupAbstractInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupAbstractInfo.Unmarshal(m, b) @@ -2374,7 +2374,7 @@ func (m *GetGroupAbstractInfoResp) Reset() { *m = GetGroupAbstractInfoRe func (m *GetGroupAbstractInfoResp) String() string { return proto.CompactTextString(m) } func (*GetGroupAbstractInfoResp) ProtoMessage() {} func (*GetGroupAbstractInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{55} + return fileDescriptor_group_4a94cf46004e5ca3, []int{55} } func (m *GetGroupAbstractInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAbstractInfoResp.Unmarshal(m, b) @@ -2413,7 +2413,7 @@ func (m *GetUserInGroupMembersReq) Reset() { *m = GetUserInGroupMembersR func (m *GetUserInGroupMembersReq) String() string { return proto.CompactTextString(m) } func (*GetUserInGroupMembersReq) ProtoMessage() {} func (*GetUserInGroupMembersReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{56} + return fileDescriptor_group_4a94cf46004e5ca3, []int{56} } func (m *GetUserInGroupMembersReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserInGroupMembersReq.Unmarshal(m, b) @@ -2458,7 +2458,7 @@ func (m *GetUserInGroupMembersResp) Reset() { *m = GetUserInGroupMembers func (m *GetUserInGroupMembersResp) String() string { return proto.CompactTextString(m) } func (*GetUserInGroupMembersResp) ProtoMessage() {} func (*GetUserInGroupMembersResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{57} + return fileDescriptor_group_4a94cf46004e5ca3, []int{57} } func (m *GetUserInGroupMembersResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserInGroupMembersResp.Unmarshal(m, b) @@ -2496,7 +2496,7 @@ func (m *GetGroupMemberUserIDReq) Reset() { *m = GetGroupMemberUserIDReq func (m *GetGroupMemberUserIDReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberUserIDReq) ProtoMessage() {} func (*GetGroupMemberUserIDReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{58} + return fileDescriptor_group_4a94cf46004e5ca3, []int{58} } func (m *GetGroupMemberUserIDReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberUserIDReq.Unmarshal(m, b) @@ -2534,7 +2534,7 @@ func (m *GetGroupMemberUserIDResp) Reset() { *m = GetGroupMemberUserIDRe func (m *GetGroupMemberUserIDResp) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberUserIDResp) ProtoMessage() {} func (*GetGroupMemberUserIDResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_b971ad66a8171801, []int{59} + return fileDescriptor_group_4a94cf46004e5ca3, []int{59} } func (m *GetGroupMemberUserIDResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberUserIDResp.Unmarshal(m, b) @@ -2561,6 +2561,90 @@ func (m *GetGroupMemberUserIDResp) GetUserIDs() []string { return nil } +type GetGroupMemberRoleLevelReq struct { + GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,omitempty"` + RoleLevels []int32 `protobuf:"varint,2,rep,packed,name=roleLevels" json:"roleLevels,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetGroupMemberRoleLevelReq) Reset() { *m = GetGroupMemberRoleLevelReq{} } +func (m *GetGroupMemberRoleLevelReq) String() string { return proto.CompactTextString(m) } +func (*GetGroupMemberRoleLevelReq) ProtoMessage() {} +func (*GetGroupMemberRoleLevelReq) Descriptor() ([]byte, []int) { + return fileDescriptor_group_4a94cf46004e5ca3, []int{60} +} +func (m *GetGroupMemberRoleLevelReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetGroupMemberRoleLevelReq.Unmarshal(m, b) +} +func (m *GetGroupMemberRoleLevelReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetGroupMemberRoleLevelReq.Marshal(b, m, deterministic) +} +func (dst *GetGroupMemberRoleLevelReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetGroupMemberRoleLevelReq.Merge(dst, src) +} +func (m *GetGroupMemberRoleLevelReq) XXX_Size() int { + return xxx_messageInfo_GetGroupMemberRoleLevelReq.Size(m) +} +func (m *GetGroupMemberRoleLevelReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetGroupMemberRoleLevelReq.DiscardUnknown(m) +} + +var xxx_messageInfo_GetGroupMemberRoleLevelReq proto.InternalMessageInfo + +func (m *GetGroupMemberRoleLevelReq) GetGroupID() string { + if m != nil { + return m.GroupID + } + return "" +} + +func (m *GetGroupMemberRoleLevelReq) GetRoleLevels() []int32 { + if m != nil { + return m.RoleLevels + } + return nil +} + +type GetGroupMemberRoleLevelResp struct { + Members []*sdkws.GroupMemberFullInfo `protobuf:"bytes,1,rep,name=members" json:"members,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetGroupMemberRoleLevelResp) Reset() { *m = GetGroupMemberRoleLevelResp{} } +func (m *GetGroupMemberRoleLevelResp) String() string { return proto.CompactTextString(m) } +func (*GetGroupMemberRoleLevelResp) ProtoMessage() {} +func (*GetGroupMemberRoleLevelResp) Descriptor() ([]byte, []int) { + return fileDescriptor_group_4a94cf46004e5ca3, []int{61} +} +func (m *GetGroupMemberRoleLevelResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetGroupMemberRoleLevelResp.Unmarshal(m, b) +} +func (m *GetGroupMemberRoleLevelResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetGroupMemberRoleLevelResp.Marshal(b, m, deterministic) +} +func (dst *GetGroupMemberRoleLevelResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetGroupMemberRoleLevelResp.Merge(dst, src) +} +func (m *GetGroupMemberRoleLevelResp) XXX_Size() int { + return xxx_messageInfo_GetGroupMemberRoleLevelResp.Size(m) +} +func (m *GetGroupMemberRoleLevelResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetGroupMemberRoleLevelResp.DiscardUnknown(m) +} + +var xxx_messageInfo_GetGroupMemberRoleLevelResp proto.InternalMessageInfo + +func (m *GetGroupMemberRoleLevelResp) GetMembers() []*sdkws.GroupMemberFullInfo { + if m != nil { + return m.Members + } + return nil +} + func init() { proto.RegisterType((*CreateGroupReq)(nil), "group.CreateGroupReq") proto.RegisterType((*CreateGroupResp)(nil), "group.CreateGroupResp") @@ -2622,6 +2706,8 @@ func init() { proto.RegisterType((*GetUserInGroupMembersResp)(nil), "group.GetUserInGroupMembersResp") proto.RegisterType((*GetGroupMemberUserIDReq)(nil), "group.GetGroupMemberUserIDReq") proto.RegisterType((*GetGroupMemberUserIDResp)(nil), "group.GetGroupMemberUserIDResp") + proto.RegisterType((*GetGroupMemberRoleLevelReq)(nil), "group.GetGroupMemberRoleLevelReq") + proto.RegisterType((*GetGroupMemberRoleLevelResp)(nil), "group.GetGroupMemberRoleLevelResp") } // Reference imports to suppress errors if they are not otherwise used. @@ -2688,6 +2774,8 @@ type GroupClient interface { GetUserInGroupMembers(ctx context.Context, in *GetUserInGroupMembersReq, opts ...grpc.CallOption) (*GetUserInGroupMembersResp, error) // 获取群成员用户ID GetGroupMemberUserID(ctx context.Context, in *GetGroupMemberUserIDReq, opts ...grpc.CallOption) (*GetGroupMemberUserIDResp, error) + // 查询群组中对应级别的成员 + GetGroupMemberRoleLevel(ctx context.Context, in *GetGroupMemberRoleLevelReq, opts ...grpc.CallOption) (*GetGroupMemberRoleLevelResp, error) } type groupClient struct { @@ -2941,6 +3029,15 @@ func (c *groupClient) GetGroupMemberUserID(ctx context.Context, in *GetGroupMemb return out, nil } +func (c *groupClient) GetGroupMemberRoleLevel(ctx context.Context, in *GetGroupMemberRoleLevelReq, opts ...grpc.CallOption) (*GetGroupMemberRoleLevelResp, error) { + out := new(GetGroupMemberRoleLevelResp) + err := grpc.Invoke(ctx, "/group.group/GetGroupMemberRoleLevel", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // Server API for Group service type GroupServer interface { @@ -2997,6 +3094,8 @@ type GroupServer interface { GetUserInGroupMembers(context.Context, *GetUserInGroupMembersReq) (*GetUserInGroupMembersResp, error) // 获取群成员用户ID GetGroupMemberUserID(context.Context, *GetGroupMemberUserIDReq) (*GetGroupMemberUserIDResp, error) + // 查询群组中对应级别的成员 + GetGroupMemberRoleLevel(context.Context, *GetGroupMemberRoleLevelReq) (*GetGroupMemberRoleLevelResp, error) } func RegisterGroupServer(s *grpc.Server, srv GroupServer) { @@ -3489,6 +3588,24 @@ func _Group_GetGroupMemberUserID_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _Group_GetGroupMemberRoleLevel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetGroupMemberRoleLevelReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GroupServer).GetGroupMemberRoleLevel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/group.group/GetGroupMemberRoleLevel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GroupServer).GetGroupMemberRoleLevel(ctx, req.(*GetGroupMemberRoleLevelReq)) + } + return interceptor(ctx, in, info, handler) +} + var _Group_serviceDesc = grpc.ServiceDesc{ ServiceName: "group.group", HandlerType: (*GroupServer)(nil), @@ -3601,126 +3718,132 @@ var _Group_serviceDesc = grpc.ServiceDesc{ MethodName: "getGroupMemberUserID", Handler: _Group_GetGroupMemberUserID_Handler, }, + { + MethodName: "GetGroupMemberRoleLevel", + Handler: _Group_GetGroupMemberRoleLevel_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "group/group.proto", } -func init() { proto.RegisterFile("group/group.proto", fileDescriptor_group_b971ad66a8171801) } - -var fileDescriptor_group_b971ad66a8171801 = []byte{ - // 1808 bytes of a gzipped FileDescriptorProto - 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a5, 0x02, 0xbd, 0x68, 0x39, 0xad, - 0xa9, 0x25, 0x00, 0xdb, 0x58, 0xe9, 0xcf, 0x10, 0x7b, 0x5c, 0x58, 0x29, 0x3c, 0x2e, 0x83, 0x60, - 0xe1, 0xf1, 0x0c, 0xd2, 0x8d, 0x4e, 0x97, 0xb3, 0x49, 0x9c, 0xae, 0x08, 0xa4, 0xc5, 0xe9, 0x14, - 0x98, 0x39, 0xa9, 0x85, 0x2a, 0xf4, 0x2b, 0xd7, 0xc2, 0x12, 0x4c, 0x2d, 0xd7, 0xc2, 0x52, 0x00, - 0x1d, 0x47, 0x47, 0x0e, 0xd5, 0xca, 0xd1, 0x51, 0x44, 0xc9, 0x72, 0x74, 0xa8, 0xe0, 0xf0, 0x01, - 0x20, 0x56, 0xc4, 0xb3, 0x8b, 0xe5, 0xc0, 0x4c, 0xda, 0x52, 0x8d, 0xcb, 0xd0, 0xbf, 0x61, 0xc6, - 0x56, 0x00, 0x1a, 0x94, 0x2f, 0x10, 0x39, 0xd0, 0x66, 0x2c, 0xf7, 0x5d, 0x8f, 0xc3, 0xc7, 0x56, - 0x61, 0x0e, 0xb4, 0x9c, 0xad, 0xf0, 0x05, 0x84, 0x23, 0xc2, 0xa7, 0x1c, 0xb2, 0x48, 0x46, 0xcb, - 0xd8, 0x01, 0xa9, 0xab, 0x9a, 0x40, 0x23, 0x05, 0xa3, 0xf3, 0xc0, 0xe3, 0xe9, 0xf2, 0xeb, 0x5b, - 0xfb, 0x94, 0x78, 0x87, 0x3b, 0x0d, 0xe9, 0xbf, 0x48, 0x2e, 0xf3, 0x57, 0xfe, 0x7b, 0x34, 0xc2, - 0x49, 0x1b, 0xbf, 0x04, 0x00, 0x00, 0xff, 0xff, 0x19, 0x28, 0x60, 0x4b, 0xfe, 0x1c, 0x00, 0x00, +func init() { proto.RegisterFile("group/group.proto", fileDescriptor_group_4a94cf46004e5ca3) } + +var fileDescriptor_group_4a94cf46004e5ca3 = []byte{ + // 1833 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0x51, 0x53, 0xe4, 0xc6, + 0x11, 0xae, 0xdd, 0x33, 0xdc, 0xd1, 0xc7, 0x1a, 0x18, 0xd8, 0x45, 0x27, 0xb8, 0x83, 0x8c, 0xaf, + 0x62, 0x2a, 0x31, 0x8b, 0x0b, 0x2e, 0x2e, 0xbb, 0x92, 0x2a, 0xe7, 0xcc, 0xc5, 0x18, 0x87, 0x85, + 0xa0, 0x3d, 0x3b, 0x29, 0xbf, 0xc4, 0x62, 0x77, 0x90, 0x75, 0x68, 0xa5, 0x41, 0xa3, 0x05, 0x3f, + 0x26, 0x95, 0x87, 0x3c, 0x25, 0x8f, 0x79, 0xc9, 0x53, 0xde, 0xf2, 0x2b, 0xf2, 0xdb, 0x52, 0x9a, + 0x91, 0x46, 0x23, 0xcd, 0x68, 0x77, 0xcd, 0x1d, 0x2f, 0x5b, 0xa5, 0xee, 0x9e, 0xe9, 0x9e, 0x9e, + 0xee, 0x9e, 0xaf, 0x7b, 0x61, 0xc5, 0x8b, 0xa3, 0x31, 0xdd, 0xe3, 0xbf, 0x5d, 0x1a, 0x47, 0x49, + 0x84, 0xe6, 0xf8, 0x87, 0xfd, 0xe1, 0x19, 0x25, 0xe1, 0xee, 0x71, 0x6f, 0xb7, 0x4f, 0xe2, 0x1b, + 0x12, 0xef, 0xd1, 0x2b, 0x6f, 0x8f, 0x0b, 0xec, 0xb1, 0xe1, 0xd5, 0x2d, 0xdb, 0xbb, 0x65, 0x42, + 0xde, 0xde, 0x9d, 0x26, 0x18, 0xbb, 0x94, 0x92, 0x38, 0x13, 0xc7, 0xff, 0x6d, 0xc0, 0xfb, 0x87, + 0x31, 0x71, 0x13, 0x72, 0x94, 0xea, 0x71, 0xc8, 0x35, 0xda, 0x86, 0xc7, 0x7e, 0xe8, 0x27, 0x3d, + 0x32, 0xba, 0x20, 0x31, 0xb3, 0x1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13, 0x53, 0x97, 0xc7, 0xc4, 0x65, + 0x51, 0x98, 0xc5, 0x5e, 0xf6, 0x85, 0xdb, 0xb0, 0xaa, 0x69, 0x63, 0x14, 0x5f, 0xf3, 0x70, 0x48, + 0x93, 0x83, 0x0c, 0x39, 0xef, 0xfe, 0xdf, 0x83, 0x3f, 0xf1, 0x6b, 0xd1, 0x54, 0xd6, 0x5e, 0xfe, + 0x0e, 0xcc, 0x73, 0x17, 0xe4, 0x77, 0xaf, 0x3f, 0xa7, 0x19, 0x1f, 0x53, 0x58, 0x3b, 0xe6, 0x79, + 0x9f, 0x6a, 0x7a, 0x1d, 0xcd, 0x50, 0x7e, 0x0a, 0x6f, 0x35, 0x55, 0x6f, 0xa5, 0x35, 0x50, 0x54, + 0x90, 0x61, 0x19, 0x96, 0x54, 0xa8, 0x78, 0x1d, 0xda, 0x06, 0x8d, 0x8c, 0xe2, 0x37, 0xb0, 0x26, + 0x1f, 0xbd, 0x20, 0x28, 0xae, 0xf7, 0x1e, 0xb2, 0x0c, 0xf7, 0x8a, 0x94, 0x56, 0x74, 0xdd, 0x39, + 0x2e, 0xff, 0xd5, 0x80, 0x47, 0x87, 0xbd, 0x3e, 0x97, 0xf9, 0xa9, 0x20, 0x0a, 0x75, 0x01, 0x79, + 0xf2, 0x31, 0x48, 0x9d, 0x72, 0xea, 0x8e, 0xf2, 0xba, 0x6e, 0xe0, 0xa0, 0x5f, 0xc0, 0x72, 0x99, + 0x2a, 0x9f, 0x1b, 0x8d, 0x8e, 0xff, 0xd2, 0x80, 0x45, 0x89, 0xb8, 0xde, 0xce, 0x99, 0x9b, 0xd9, + 0xb1, 0x14, 0xeb, 0x0a, 0x82, 0xea, 0xea, 0x07, 0x65, 0x57, 0x9f, 0x42, 0x4b, 0xb1, 0xa0, 0x36, + 0x64, 0x3f, 0xac, 0x84, 0xec, 0x52, 0x57, 0xa0, 0xf6, 0xdc, 0xad, 0x32, 0x62, 0x77, 0x0b, 0x0c, + 0x39, 0x43, 0x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xc0, 0xab, 0xba, 0x02, 0x1d, 0x00, 0x00, } diff --git a/pkg/proto/group/group.proto b/pkg/proto/group/group.proto index 39a84d00a..d5cb23324 100644 --- a/pkg/proto/group/group.proto +++ b/pkg/proto/group/group.proto @@ -279,7 +279,7 @@ message GetUserInGroupMembersReq { repeated string groupIDs = 2; } -message getUserInGroupMembersResp{ +message GetUserInGroupMembersResp{ repeated sdkws.GroupMemberFullInfo members = 1; } @@ -291,7 +291,14 @@ message GetGroupMemberUserIDResp{ repeated string userIDs = 1; } +message GetGroupMemberRoleLevelReq{ + string groupID = 1; + repeated int32 roleLevels = 2; +} +message GetGroupMemberRoleLevelResp { + repeated sdkws.GroupMemberFullInfo members = 1; +} service group{ //创建群 @@ -350,6 +357,8 @@ service group{ rpc getUserInGroupMembers(GetUserInGroupMembersReq) returns (GetUserInGroupMembersResp); //获取群成员用户ID rpc getGroupMemberUserID(GetGroupMemberUserIDReq) returns (GetGroupMemberUserIDResp); + //查询群组中对应级别的成员 + rpc GetGroupMemberRoleLevel(GetGroupMemberRoleLevelReq)returns (GetGroupMemberRoleLevelResp); } From e1b6e054f04ac5ce2b42bc9ddd10d79a9b8b6d2c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 10:34:34 +0800 Subject: [PATCH 26/48] Error code standardization --- internal/common/check/group.go | 4 + internal/common/notification/c.go | 5 +- internal/common/notification/conversation.go | 19 +- internal/common/notification/friend.go | 41 ++-- internal/common/notification/group.go | 232 ++++++++----------- internal/common/notification/msg.go | 4 +- internal/common/notification/super_group.go | 10 +- internal/rpc/group/group.go | 26 +-- 8 files changed, 148 insertions(+), 193 deletions(-) diff --git a/internal/common/check/group.go b/internal/common/check/group.go index c735f99e4..4d30609c0 100644 --- a/internal/common/check/group.go +++ b/internal/common/check/group.go @@ -104,3 +104,7 @@ func (g *GroupChecker) GetGroupMemberInfoMap(ctx context.Context, groupID string return e.UserID }), nil } + +func (g *GroupChecker) GetOwnerAndAdminInfos(ctx context.Context, groupID string) ([]*sdkws.GroupMemberFullInfo, error) { + +} diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go index 17f5a801c..5dac5fed4 100644 --- a/internal/common/notification/c.go +++ b/internal/common/notification/c.go @@ -22,12 +22,11 @@ type NotificationMsg struct { MsgFrom int32 ContentType int32 SessionType int32 - OperationID string SenderNickname string SenderFaceURL string } -func (c *Check) Notification(n *NotificationMsg) { +func (c *Check) Notification(ctx context.Context, n *NotificationMsg) { var req msg.SendMsgReq var msg sdkws.MsgData var offlineInfo sdkws.OfflinePushInfo @@ -284,6 +283,6 @@ func (c *Check) Notification(n *NotificationMsg) { _, err := sendMsg(context.Background(), &req) } -func sendMsg(ctx context.Context, req *msg.SendMsgReq) (msg.SendMsgResp, error) { +func sendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) { } diff --git a/internal/common/notification/conversation.go b/internal/common/notification/conversation.go index 745a1e6bd..a7506779a 100644 --- a/internal/common/notification/conversation.go +++ b/internal/common/notification/conversation.go @@ -3,21 +3,16 @@ package notification import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/tracelog" sdkws "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" "context" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" ) -func (c *Check) SetConversationNotification(operationID, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) { - log.NewInfo(operationID, "args: ", sendID, recvID, contentType, m.String(), tips.String()) +func (c *Check) SetConversationNotification(ctx context.Context, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) { var err error tips.Detail, err = proto.Marshal(m) if err != nil { - log.NewError(operationID, "Marshal failed ", err.Error(), m.String()) return } marshaler := jsonpb.Marshaler{ @@ -32,13 +27,11 @@ func (c *Check) SetConversationNotification(operationID, sendID, recvID string, n.ContentType = int32(contentType) n.SessionType = constant.SingleChatType n.MsgFrom = constant.SysMsgType - n.OperationID = operationID n.Content, err = proto.Marshal(&tips) if err != nil { - log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), tips.String()) return } - c.Notification(&n) + c.Notification(ctx, &n) } // SetPrivate调用 @@ -57,7 +50,7 @@ func (c *Check) ConversationSetPrivateNotification(ctx context.Context, sendID, tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips } tips.DefaultTips = tipsMsg - c.SetConversationNotification(tracelog.GetOperationID(ctx), sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips) + c.SetConversationNotification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips) } // 会话改变 @@ -68,11 +61,11 @@ func (c *Check) ConversationChangeNotification(ctx context.Context, userID strin } var tips sdkws.TipsComm tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips - c.SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) + c.SetConversationNotification(ctx, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips) } // 会话未读数同步 -func (c *Check) ConversationUnreadChangeNotification(context context.Context, userID, conversationID string, updateUnreadCountTime int64) { +func (c *Check) ConversationUnreadChangeNotification(ctx context.Context, userID, conversationID string, updateUnreadCountTime int64) { ConversationChangedTips := &sdkws.ConversationUpdateTips{ UserID: userID, @@ -81,5 +74,5 @@ func (c *Check) ConversationUnreadChangeNotification(context context.Context, us } var tips sdkws.TipsComm tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips - c.SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips) + c.SetConversationNotification(ctx, userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips) } diff --git a/internal/common/notification/friend.go b/internal/common/notification/friend.go index 10c08f30a..684700154 100644 --- a/internal/common/notification/friend.go +++ b/internal/common/notification/friend.go @@ -4,31 +4,26 @@ import ( "Open_IM/internal/common/check" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/tracelog" pbFriend "Open_IM/pkg/proto/friend" "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" "context" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" ) -func getFromToUserNickname(userCheck *check.UserCheck, fromUserID, toUserID string) (string, string, error) { - users, err := userCheck.GetUsersInfoMap(context.Background(), []string{fromUserID, toUserID}, true) +func (c *Check) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) { + users, err := c.user.GetUsersInfoMap(ctx, []string{fromUserID, toUserID}, true) if err != nil { return "", "", nil } return users[fromUserID].Nickname, users[toUserID].Nickname, nil } -func friendNotification(operationID, fromUserID, toUserID string, contentType int32, m proto.Message) { - log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType) +func (c *Check) friendNotification(ctx context.Context, fromUserID, toUserID string, contentType int32, m proto.Message) { var err error var tips sdkws.TipsComm tips.Detail, err = proto.Marshal(m) if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), m.String()) return } @@ -40,9 +35,8 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in tips.JsonDetail, _ = marshaler.MarshalToString(m) - fromUserNickname, toUserNickname, err := getFromToUserNickname(fromUserID, toUserID) + fromUserNickname, toUserNickname, err := c.getFromToUserNickname(ctx, fromUserID, toUserID) if err != nil { - log.Error(operationID, "getFromToUserNickname failed ", err.Error(), fromUserID, toUserID) return } cn := config.Config.Notification @@ -68,7 +62,6 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in case constant.FriendInfoUpdatedNotification: tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname default: - log.Error(operationID, "contentType failed ", contentType) return } @@ -78,20 +71,18 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in n.ContentType = contentType n.SessionType = constant.SingleChatType n.MsgFrom = constant.SysMsgType - n.OperationID = operationID n.Content, err = proto.Marshal(&tips) if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - Notification(&n) + c.Notification(ctx, &n) } func (c *Check) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) { FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}} FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID - friendNotification(tracelog.GetOperationID(ctx), req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips) + c.friendNotification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips) } func (c *Check) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { @@ -99,7 +90,7 @@ func (c *Check) FriendApplicationAgreedNotification(ctx context.Context, req *pb FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID FriendApplicationApprovedTips.HandleMsg = req.HandleMsg - friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips) + c.friendNotification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips) } func (c *Check) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { @@ -107,12 +98,12 @@ func (c *Check) FriendApplicationRefusedNotification(ctx context.Context, req *p FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID FriendApplicationApprovedTips.HandleMsg = req.HandleMsg - friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips) + c.friendNotification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips) } func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) { friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}} - user, err := check.NewUserCheck().GetUsersInfos(context.Background(), []string{opUserID}, true) + user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true) if err != nil { return } @@ -126,44 +117,44 @@ func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUser return } friendAddedTips.Friend = friend - friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips) + c.friendNotification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips) } func (c *Check) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) { friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}} friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID - friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips) + c.friendNotification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips) } func (c *Check) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) { friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}} friendInfoChangedTips.FromToUserID.FromUserID = fromUserID friendInfoChangedTips.FromToUserID.ToUserID = toUserID - friendNotification(tracelog.GetOperationID(ctx), fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips) + c.friendNotification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips) } func (c *Check) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) { blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}} blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID blackAddedTips.FromToUserID.ToUserID = req.BlackUserID - friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips) + c.friendNotification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips) } func (c *Check) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) { blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}} blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID - friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips) + c.friendNotification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips) } // send to myself func (c *Check) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) { selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} - friendNotification(tracelog.GetOperationID(ctx), opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) + c.friendNotification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) } func (c *Check) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} - friendNotification(tracelog.GetOperationID(ctx), opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips) + c.friendNotification(ctx, opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips) } diff --git a/internal/common/notification/group.go b/internal/common/notification/group.go index 05b286600..e340ed3b7 100644 --- a/internal/common/notification/group.go +++ b/internal/common/notification/group.go @@ -15,9 +15,10 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" ) -func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { +func (c *Check) setOpUserInfo(ctx context.Context, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + opUserID := tracelog.GetOpUserID(ctx) if tokenverify.IsManagerUserID(opUserID) { - user, err := c.user.GetUsersInfos(context.Background(), []string{opUserID}, true) + user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true) if err != nil { return err } @@ -28,12 +29,12 @@ func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.G groupMemberInfo.FaceURL = user[0].FaceURL return nil } - u, err := c.group.GetGroupMemberInfo(context.Background(), groupID, opUserID) + u, err := c.group.GetGroupMemberInfo(ctx, groupID, opUserID) if err == nil { *groupMemberInfo = *u return nil } - user, err := c.user.GetUsersInfos(context.Background(), []string{opUserID}, true) + user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true) if err != nil { return err } @@ -46,8 +47,8 @@ func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.G return nil } -func (c *Check) setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error { - group, err := c.group.GetGroupInfos(context.Background(), []string{groupID}, true) +func (c *Check) setGroupInfo(ctx context.Context, groupID string, groupInfo *sdkws.GroupInfo) error { + group, err := c.group.GetGroupInfos(ctx, []string{groupID}, true) if err != nil { return err } @@ -55,13 +56,13 @@ func (c *Check) setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error { return nil } -func (c *Check) setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { - groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, userID) +func (c *Check) setGroupMemberInfo(ctx context.Context, groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + groupMember, err := c.group.GetGroupMemberInfo(ctx, groupID, userID) if err == nil { *groupMemberInfo = *groupMember return nil } - user, err := c.user.GetUsersInfos(context.Background(), []string{userID}, true) + user, err := c.user.GetUsersInfos(ctx, []string{userID}, true) if err != nil { return err } @@ -73,12 +74,12 @@ func (c *Check) setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkw return nil } -func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { - group, err := c.group.GetGroupInfo(context.Background(), groupID) +func (c *Check) setGroupOwnerInfo(ctx context.Context, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error { + group, err := c.group.GetGroupInfo(ctx, groupID) if err != nil { return err } - groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, group.OwnerUserID) + groupMember, err := c.group.GetGroupMemberInfo(ctx, groupID, group.OwnerUserID) if err != nil { return err } @@ -86,8 +87,8 @@ func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMe return nil } -func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error { - user, err := c.user.GetPublicUserInfos(context.Background(), []string{userID}, true) +func (c *Check) setPublicUserInfo(ctx context.Context, userID string, publicUserInfo *sdkws.PublicUserInfo) error { + user, err := c.user.GetPublicUserInfos(ctx, []string{userID}, true) if err != nil { return err } @@ -95,13 +96,11 @@ func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUse return nil } -func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) { - log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID) +func (c *Check) groupNotification(ctx context.Context, contentType int32, m proto.Message, sendID, groupID, recvUserID string) { var err error var tips sdkws.TipsComm tips.Detail, err = proto.Marshal(m) if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), m.String()) return } marshaler := jsonpb.Marshaler{ @@ -113,14 +112,14 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr var nickname, toNickname string if sendID != "" { - from, err := c.user.GetUsersInfos(context.Background(), []string{sendID}, true) + from, err := c.user.GetUsersInfos(ctx, []string{sendID}, true) if err != nil { return } nickname = from[0].Nickname } if recvUserID != "" { - to, err := c.user.GetUsersInfos(context.Background(), []string{recvUserID}, true) + to, err := c.user.GetUsersInfos(ctx, []string{recvUserID}, true) if err != nil { return } @@ -166,7 +165,6 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr case constant.GroupMemberSetToOrdinaryUserNotification: tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips default: - log.Error(operationID, "contentType failed ", contentType) return } @@ -175,7 +173,7 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr if groupID != "" { n.RecvID = groupID - group, err := c.group.GetGroupInfo(context.Background(), groupID) + group, err := c.group.GetGroupInfo(ctx, groupID) if err != nil { return } @@ -190,37 +188,31 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr n.SessionType = constant.SingleChatType } n.ContentType = contentType - n.OperationID = operationID n.Content, err = proto.Marshal(&tips) if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - c.Notification(&n) + c.Notification(ctx, &n) } // 创建群后调用 -func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) { +func (c *Check) GroupCreatedNotification(ctx context.Context, groupID string, initMemberList []string) { GroupCreatedTips := sdkws.GroupCreatedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, GroupOwnerUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil { - log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser) + if err := c.setOpUserInfo(ctx, groupID, GroupCreatedTips.OpUser); err != nil { return } - err := c.setGroupInfo(groupID, GroupCreatedTips.Group) + err := c.setGroupInfo(ctx, groupID, GroupCreatedTips.Group) if err != nil { - log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group) return } - if err := c.setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil { - log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID) + if err := c.setGroupOwnerInfo(ctx, groupID, GroupCreatedTips.GroupOwnerUser); err != nil { return } for _, v := range initMemberList { var groupMemberInfo sdkws.GroupMemberFullInfo - if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v) + if err := c.setGroupMemberInfo(ctx, groupID, v, &groupMemberInfo); err != nil { continue } GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo) @@ -228,7 +220,8 @@ func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string, break } } - c.groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID) + + c.groupNotification(ctx, constant.GroupCreatedNotification, &GroupCreatedTips, tracelog.GetOpUserID(ctx), groupID, "") } // 群信息改变后掉用 @@ -237,10 +230,9 @@ func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string, // notification := "" // introduction := "" // faceURL := "" -func (c *Check) GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) { +func (c *Check) GroupInfoSetNotification(ctx context.Context, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) { GroupInfoChangedTips := sdkws.GroupInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + if err := c.setGroupInfo(ctx, groupID, GroupInfoChangedTips.Group); err != nil { return } GroupInfoChangedTips.Group.GroupName = groupName @@ -251,116 +243,102 @@ func (c *Check) GroupInfoSetNotification(operationID, opUserID, groupID string, GroupInfoChangedTips.Group.NeedVerification = needVerification.Value } - if err := c.setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + if err := c.setOpUserInfo(ctx, groupID, GroupInfoChangedTips.OpUser); err != nil { return } - c.groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.GroupInfoSetNotification, &GroupInfoChangedTips, tracelog.GetOpUserID(ctx), groupID, "") } -func (c *Check) GroupMutedNotification(operationID, opUserID, groupID string) { +func (c *Check) GroupMutedNotification(ctx context.Context, groupID string) { tips := sdkws.GroupMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil { return } - if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil { return } - c.groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.GroupMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "") } -func (c *Check) GroupCancelMutedNotification(operationID, opUserID, groupID string) { +func (c *Check) GroupCancelMutedNotification(ctx context.Context, groupID string) { tips := sdkws.GroupCancelMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil { return } - if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil { return } - c.groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.GroupCancelMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "") } -func (c *Check) GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) { +func (c *Check) GroupMemberMutedNotification(ctx context.Context, groupID, groupMemberUserID string, mutedSeconds uint32) { tips := sdkws.GroupMemberMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} tips.MutedSeconds = mutedSeconds - if err := c.setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil { return } - if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil { return } - if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.MutedUser); err != nil { return } - c.groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.GroupMemberMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "") } -func (c *Check) GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberUserID string) { +func (c *Check) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) { tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil { return } - if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil { return } - if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.ChangedUser); err != nil { return } - c.groupNotification(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.GroupMemberInfoSetNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "") } -func (c *Check) GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) { +func (c *Check) GroupMemberRoleLevelChangeNotification(ctx context.Context, operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) { if notificationType != constant.GroupMemberSetToAdminNotification && notificationType != constant.GroupMemberSetToOrdinaryUserNotification { log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType) return } tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, tips.Group); err != nil { + if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) return } - if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil { log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) return } - if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { + if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.ChangedUser); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) return } - c.groupNotification(notificationType, &tips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, notificationType, &tips, tracelog.GetOpUserID(ctx), groupID, "") } -func (c *Check) GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) { +func (c *Check) GroupMemberCancelMutedNotification(ctx context.Context, groupID, groupMemberUserID string) { tips := sdkws.GroupMemberCancelMutedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, tips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil { return } - if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil { return } - if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.MutedUser); err != nil { return } - c.groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.GroupMemberCancelMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "") } // message ReceiveJoinApplicationTips{ @@ -376,38 +354,35 @@ func (c *Check) GroupMemberCancelMutedNotification(operationID, opUserID, groupI // 申请进群后调用 func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) { JoinGroupApplicationTips := sdkws.JoinGroupApplicationTips{Group: &sdkws.GroupInfo{}, Applicant: &sdkws.PublicUserInfo{}} - err := c.setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group) + err := c.setGroupInfo(ctx, req.GroupID, JoinGroupApplicationTips.Group) if err != nil { return } - if err = c.setPublicUserInfo(tracelog.GetOpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { + if err = c.setPublicUserInfo(ctx, tracelog.GetOpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil { return } JoinGroupApplicationTips.ReqMsg = req.ReqMessage - - managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) + managerList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID) if err != nil { return } for _, v := range managerList { - c.groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, tracelog.GetOpUserID(ctx), "", v.UserID, utils.OperationID(ctx)) - + c.groupNotification(ctx, constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, tracelog.GetOpUserID(ctx), "", v.UserID) } } func (c *Check) MemberQuitNotification(ctx context.Context, req *pbGroup.QuitGroupReq) { MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil { - + if err := c.setGroupInfo(ctx, req.GroupID, MemberQuitTips.Group); err != nil { return } - if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, MemberQuitTips.QuitUser); err != nil { + if err := c.setOpUserInfo(ctx, req.GroupID, MemberQuitTips.QuitUser); err != nil { return } - c.groupNotification(constant.MemberQuitNotification, &MemberQuitTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) + c.groupNotification(ctx, constant.MemberQuitNotification, &MemberQuitTips, tracelog.GetOpUserID(ctx), req.GroupID, "") } // message ApplicationProcessedTips{ @@ -420,75 +395,74 @@ func (c *Check) MemberQuitNotification(ctx context.Context, req *pbGroup.QuitGro // 处理进群请求后调用 func (c *Check) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { GroupApplicationAcceptedTips := sdkws.GroupApplicationAcceptedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} - if err := c.setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil { + if err := c.setGroupInfo(ctx, req.GroupID, GroupApplicationAcceptedTips.Group); err != nil { return } - if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { + if err := c.setOpUserInfo(ctx, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil { return } - c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx)) - adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) + c.groupNotification(ctx, constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID) + adminList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID) if err != nil { - log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID) return } for _, v := range adminList { - if v.UserID == req.OpUserID { + if v.UserID == tracelog.GetOpUserID(ctx) { continue } GroupApplicationAcceptedTips.ReceiverAs = 1 - c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", v.UserID, req.OperationID) + c.groupNotification(ctx, constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", v.UserID) } } func (c *Check) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { GroupApplicationRejectedTips := sdkws.GroupApplicationRejectedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg} - if err := c.setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil { + if err := c.setGroupInfo(ctx, req.GroupID, GroupApplicationRejectedTips.Group); err != nil { return } - if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { + if err := c.setOpUserInfo(ctx, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil { return } - c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx)) - adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID) + c.groupNotification(ctx, constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID) + adminList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID) if err != nil { return } for _, v := range adminList { - if v.UserID == req.OpUserID { + if v.UserID == tracelog.GetOpUserID(ctx) { continue } GroupApplicationRejectedTips.ReceiverAs = 1 - c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", v.UserID, tracelog.GetOperationID(ctx)) + c.groupNotification(ctx, constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", v.UserID) } } func (c *Check) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) { GroupOwnerTransferredTips := sdkws.GroupOwnerTransferredTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, NewGroupOwner: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil { + if err := c.setGroupInfo(ctx, req.GroupID, GroupOwnerTransferredTips.Group); err != nil { return } - if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { + if err := c.setOpUserInfo(ctx, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil { return } - if err := c.setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil { + if err := c.setGroupMemberInfo(ctx, req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil { return } - c.groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) + c.groupNotification(ctx, constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, tracelog.GetOpUserID(ctx), req.GroupID, "") } func (c *Check) GroupDismissedNotification(ctx context.Context, req *pbGroup.DismissGroupReq) { tips := sdkws.GroupDismissedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(req.GroupID, tips.Group); err != nil { + if err := c.setGroupInfo(ctx, req.GroupID, tips.Group); err != nil { return } - if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, tips.OpUser); err != nil { + if err := c.setOpUserInfo(ctx, req.GroupID, tips.OpUser); err != nil { return } - c.groupNotification(constant.GroupDismissedNotification, &tips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) + c.groupNotification(ctx, constant.GroupDismissedNotification, &tips, tracelog.GetOpUserID(ctx), req.GroupID, "") } // message MemberKickedTips{ @@ -501,20 +475,20 @@ func (c *Check) GroupDismissedNotification(ctx context.Context, req *pbGroup.Dis // 被踢后调用 func (c *Check) MemberKickedNotification(ctx context.Context, req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) { MemberKickedTips := sdkws.MemberKickedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil { + if err := c.setGroupInfo(ctx, req.GroupID, MemberKickedTips.Group); err != nil { return } - if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, MemberKickedTips.OpUser); err != nil { + if err := c.setOpUserInfo(ctx, req.GroupID, MemberKickedTips.OpUser); err != nil { return } for _, v := range kickedUserIDList { var groupMemberInfo sdkws.GroupMemberFullInfo - if err := c.setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil { + if err := c.setGroupMemberInfo(ctx, req.GroupID, v, &groupMemberInfo); err != nil { continue } MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo) } - c.groupNotification(constant.MemberKickedNotification, &MemberKickedTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) + c.groupNotification(ctx, constant.MemberKickedNotification, &MemberKickedTips, tracelog.GetOpUserID(ctx), req.GroupID, "") // //for _, v := range kickedUserIDList { // groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID) @@ -529,48 +503,46 @@ func (c *Check) MemberKickedNotification(ctx context.Context, req *pbGroup.KickG // } // // 被邀请进群后调用 -func (c *Check) MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) { +func (c *Check) MemberInvitedNotification(ctx context.Context, groupID, reason string, invitedUserIDList []string) { MemberInvitedTips := sdkws.MemberInvitedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, MemberInvitedTips.Group); err != nil { - log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + if err := c.setGroupInfo(ctx, groupID, MemberInvitedTips.Group); err != nil { return } - if err := c.setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil { - log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + if err := c.setOpUserInfo(ctx, groupID, MemberInvitedTips.OpUser); err != nil { + return } for _, v := range invitedUserIDList { var groupMemberInfo sdkws.GroupMemberFullInfo - if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil { - log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID) + if err := c.setGroupMemberInfo(ctx, groupID, v, &groupMemberInfo); err != nil { continue } MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo) } - c.groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.MemberInvitedNotification, &MemberInvitedTips, tracelog.GetOpUserID(ctx), groupID, "") } // 群成员主动申请进群,管理员同意后调用, func (c *Check) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) { MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil { + if err := c.setGroupInfo(ctx, req.GroupID, MemberEnterTips.Group); err != nil { return } - if err := c.setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil { + if err := c.setGroupMemberInfo(ctx, req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil { return } - c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx)) + c.groupNotification(ctx, constant.MemberEnterNotification, &MemberEnterTips, tracelog.GetOpUserID(ctx), req.GroupID, "") } -func (c *Check) MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) { +func (c *Check) MemberEnterDirectlyNotification(ctx context.Context, groupID string, entrantUserID string, operationID string) { MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}} - if err := c.setGroupInfo(groupID, MemberEnterTips.Group); err != nil { + if err := c.setGroupInfo(ctx, groupID, MemberEnterTips.Group); err != nil { log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group) return } - if err := c.setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil { + if err := c.setGroupMemberInfo(ctx, groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil { log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser) return } - c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID) + c.groupNotification(ctx, constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "") } diff --git a/internal/common/notification/msg.go b/internal/common/notification/msg.go index ec74ed60e..771288713 100644 --- a/internal/common/notification/msg.go +++ b/internal/common/notification/msg.go @@ -5,11 +5,12 @@ import ( "Open_IM/pkg/common/log" "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" + "context" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" ) -func (c *Check) DeleteMessageNotification(opUserID, userID string, seqList []uint32, operationID string) { +func (c *Check) DeleteMessageNotification(ctx context.Context, userID string, seqList []uint32, operationID string) { DeleteMessageTips := sdkws.DeleteMessageTips{OpUserID: opUserID, UserID: userID, SeqList: seqList} c.MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips) } @@ -37,7 +38,6 @@ func (c *Check) MessageNotification(operationID, sendID, recvID string, contentT n.ContentType = contentType n.SessionType = constant.SingleChatType n.MsgFrom = constant.SysMsgType - n.OperationID = operationID n.Content, err = proto.Marshal(&tips) if err != nil { log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) diff --git a/internal/common/notification/super_group.go b/internal/common/notification/super_group.go index 2f073cf87..1e9f18a90 100644 --- a/internal/common/notification/super_group.go +++ b/internal/common/notification/super_group.go @@ -2,22 +2,18 @@ package notification import ( "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" - //sdk "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" + "context" //"github.com/golang/protobuf/jsonpb" //"github.com/golang/protobuf/proto" ) -func (c *Check) SuperGroupNotification(operationID, sendID, recvID string) { +func (c *Check) SuperGroupNotification(ctx context.Context, sendID, recvID string) { n := &NotificationMsg{ SendID: sendID, RecvID: recvID, MsgFrom: constant.SysMsgType, ContentType: constant.SuperGroupUpdateNotification, SessionType: constant.SingleChatType, - OperationID: operationID, } - log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content)) - c.Notification(n) + c.Notification(ctx, n) } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index db382bb20..94dbf113b 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -282,11 +282,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if req.GroupInfo.GroupType == constant.SuperGroup { go func() { for _, userID := range userIDs { - s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + s.notification.SuperGroupNotification(ctx, userID, userID) } }() } else { - s.notification.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs) + s.notification.GroupCreatedNotification(ctx, group.GroupID, userIDs) } return resp, nil } @@ -396,7 +396,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, userID := range req.InvitedUserIDs { - s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + s.notification.SuperGroupNotification(ctx, userID, userID) } } else { opUserID := tracelog.GetOpUserID(ctx) @@ -417,7 +417,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil { return nil, err } - s.notification.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) + s.notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs) } return resp, nil } @@ -494,7 +494,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou } go func() { for _, userID := range req.KickedUserIDs { - s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID) + s.notification.SuperGroupNotification(ctx, userID, userID) } }() } else { @@ -742,7 +742,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil { return nil, err } - s.notification.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) + s.notification.MemberEnterDirectlyNotification(ctx, req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) return resp, nil } groupRequest := relationTb.GroupRequestModel{ @@ -769,7 +769,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil { return nil, err } - s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) + s.notification.SuperGroupNotification(ctx, tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) } else { _, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx)) if err != nil { @@ -809,7 +809,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf if err != nil { return nil, err } - s.notification.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) + s.notification.GroupInfoSetNotification(ctx, req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) if req.GroupInfoForSet.Notification != "" { s.GroupNotification(ctx, group.GroupID) } @@ -1015,7 +1015,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - s.notification.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds) + s.notification.GroupMemberMutedNotification(ctx, req.GroupID, req.UserID, req.MutedSeconds) return resp, nil } @@ -1038,7 +1038,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - s.notification.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID) + s.notification.GroupMemberCancelMutedNotification(ctx, req.GroupID, req.UserID) return resp, nil } @@ -1050,7 +1050,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil { return nil, err } - s.notification.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + s.notification.GroupMutedNotification(ctx, req.GroupID) return resp, nil } @@ -1062,7 +1062,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil { return nil, err } - s.notification.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID) + s.notification.GroupCancelMutedNotification(ctx, req.GroupID) return resp, nil } @@ -1139,7 +1139,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr return nil, err } for _, member := range req.Members { - s.notification.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID) + s.notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID) } return resp, nil } From b7d724a5e45a83fb89000b0cf49103dff7be151f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 10:57:52 +0800 Subject: [PATCH 27/48] Error code standardization --- internal/common/check/conversation.go | 15 ++++++ internal/common/check/group.go | 10 +++- internal/common/notification/msg.go | 13 ++--- internal/rpc/msg/callback.go | 2 +- internal/rpc/msg/send_pull.go | 68 ++------------------------- internal/rpc/msg/server.go | 1 + 6 files changed, 34 insertions(+), 75 deletions(-) create mode 100644 internal/common/check/conversation.go diff --git a/internal/common/check/conversation.go b/internal/common/check/conversation.go new file mode 100644 index 000000000..b56c35741 --- /dev/null +++ b/internal/common/check/conversation.go @@ -0,0 +1,15 @@ +package check + +import ( + discoveryRegistry "Open_IM/pkg/discoveryregistry" + pbConversation "Open_IM/pkg/proto/conversation" + "context" +) + +type ConversationChecker struct { + zk discoveryRegistry.SvcDiscoveryRegistry +} + +func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (resp *pbConversation.ModifyConversationFieldResp, err error) { + return +} diff --git a/internal/common/check/group.go b/internal/common/check/group.go index 4d30609c0..6af51075e 100644 --- a/internal/common/check/group.go +++ b/internal/common/check/group.go @@ -106,5 +106,13 @@ func (g *GroupChecker) GetGroupMemberInfoMap(ctx context.Context, groupID string } func (g *GroupChecker) GetOwnerAndAdminInfos(ctx context.Context, groupID string) ([]*sdkws.GroupMemberFullInfo, error) { - + cc, err := g.getConn() + if err != nil { + return nil, err + } + resp, err := group.NewGroupClient(cc).GetGroupMemberRoleLevel(ctx, &group.GetGroupMemberRoleLevelReq{ + GroupID: groupID, + RoleLevels: []int32{constant.GroupOwner, constant.GroupAdmin}, + }) + return resp.Members, err } diff --git a/internal/common/notification/msg.go b/internal/common/notification/msg.go index 771288713..137faf02f 100644 --- a/internal/common/notification/msg.go +++ b/internal/common/notification/msg.go @@ -2,26 +2,22 @@ package notification import ( "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" "Open_IM/pkg/proto/sdkws" - "Open_IM/pkg/utils" "context" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" ) func (c *Check) DeleteMessageNotification(ctx context.Context, userID string, seqList []uint32, operationID string) { - DeleteMessageTips := sdkws.DeleteMessageTips{OpUserID: opUserID, UserID: userID, SeqList: seqList} - c.MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips) + DeleteMessageTips := sdkws.DeleteMessageTips{UserID: userID, SeqList: seqList} + c.MessageNotification(ctx, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips) } -func (c *Check) MessageNotification(operationID, sendID, recvID string, contentType int32, m proto.Message) { - log.Debug(operationID, utils.GetSelfFuncName(), "args: ", m.String(), contentType) +func (c *Check) MessageNotification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message) { var err error var tips sdkws.TipsComm tips.Detail, err = proto.Marshal(m) if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), m.String()) return } @@ -40,8 +36,7 @@ func (c *Check) MessageNotification(operationID, sendID, recvID string, contentT n.MsgFrom = constant.SysMsgType n.Content, err = proto.Marshal(&tips) if err != nil { - log.Error(operationID, "Marshal failed ", err.Error(), tips.String()) return } - c.Notification(&n) + c.Notification(ctx, &n) } diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index c6848a82f..d82c776da 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -33,7 +33,7 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbapi.CommonCallbackReq return req } -func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) error { +func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (err error) { callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable { return callbackResp diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index 51298fe99..ebfde0851 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -116,13 +116,12 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( var memberKickedTips sdkws.MemberKickedTips err := proto.Unmarshal(req.MsgData.Content, &tips) if err != nil { - + return nil, err } err = proto.Unmarshal(tips.Detail, &memberKickedTips) if err != nil { - + return nil, err } - for _, v := range memberKickedTips.KickedUserList { addUidList = append(addUidList, v.UserID) } @@ -204,7 +203,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( conversation.GroupAtType = constant.AtMe } - _, err := m.ModifyConversationField(context.Background(), &conversationReq) + _, err := m.Conversation.ModifyConversationField(ctx, &conversationReq) if err != nil { return } @@ -212,7 +211,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( if tag { conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList) conversation.GroupAtType = constant.AtAll - _, err := m.ModifyConversationField(context.Background(), &conversationReq) + _, err := m.Conversation.ModifyConversationField(ctx, &conversationReq) if err != nil { return } @@ -228,10 +227,6 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( return resp, nil } -func (m *msgServer) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) { - -} - func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, error error) { resp = &msg.SendMsgResp{} flag := isMessageHasReadEnabled(req.MsgData) @@ -305,60 +300,5 @@ func (m *msgServer) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMes MsgDataList: msgs, } } - - //redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(req.UserID, req.SeqList, req.OperationID) - //if err != nil { - // if err != go_redis.Nil { - // promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - // log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList) - // } else { - // log.Debug(req.OperationID, "get message from redis is nil", failedSeqList) - // } - // msgList, err1 := commonDB.DB.GetMsgBySeqListMongo2(req.UserID, failedSeqList, req.OperationID) - // if err1 != nil { - // promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - // log.Error(req.OperationID, "PullMessageBySeqList data error", req.String(), err1.Error()) - // resp.ErrCode = 201 - // resp.ErrMsg = err1.Error() - // return resp, nil - // } else { - // promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - // redisMsgList = append(redisMsgList, msgList...) - // resp.List = redisMsgList - // } - //} else { - // promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - // resp.List = redisMsgList - //} - // - //for k, v := range req.GroupSeqList { - // x := new(sdkws.MsgDataList) - // redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(k, v.SeqList, req.OperationID) - // if err != nil { - // if err != go_redis.Nil { - // promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList)) - // log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList) - // } else { - // log.Debug(req.OperationID, "get message from redis is nil", failedSeqList) - // } - // msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, req.OperationID) - // if err1 != nil { - // promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList)) - // log.Error(req.OperationID, "PullMessageBySeqList data error", req.String(), err1.Error()) - // resp.ErrCode = 201 - // resp.ErrMsg = err1.Error() - // return resp, nil - // } else { - // promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList)) - // redisMsgList = append(redisMsgList, msgList...) - // x.MsgDataList = redisMsgList - // m[k] = x - // } - // } else { - // promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList)) - // x.MsgDataList = redisMsgList - // m[k] = x - // } - //} return resp, nil } diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 7b1dd3785..ae416ccf3 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -28,6 +28,7 @@ type msgServer struct { MsgInterface controller.MsgInterface Group *check.GroupChecker User *check.UserCheck + Conversation *check.ConversationChecker } type deleteMsg struct { From 05d00a8174bdbc3d7db11876007ca5330bdb435a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 11:33:10 +0800 Subject: [PATCH 28/48] Error code standardization --- internal/common/check/access.go | 1 + internal/common/check/msg.go | 26 ++++++++++++++++++ internal/common/notification/c.go | 38 ++++++++++++++------------ internal/common/notification/friend.go | 6 ---- internal/common/notification/user.go | 13 +++++++++ internal/rpc/friend/friend.go | 18 ++++++------ internal/rpc/user/user.go | 11 +++++--- 7 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 internal/common/check/msg.go create mode 100644 internal/common/notification/user.go diff --git a/internal/common/check/access.go b/internal/common/check/access.go index 4f0df2643..71254b903 100644 --- a/internal/common/check/access.go +++ b/internal/common/check/access.go @@ -11,4 +11,5 @@ func Access(ctx context.Context, ownerUserID string) (err error) { return err } return tokenverify.CheckAccessV3(ctx, ownerUserID) + } diff --git a/internal/common/check/msg.go b/internal/common/check/msg.go new file mode 100644 index 000000000..c4f1dfc03 --- /dev/null +++ b/internal/common/check/msg.go @@ -0,0 +1,26 @@ +package check + +import ( + "Open_IM/pkg/common/config" + discoveryRegistry "Open_IM/pkg/discoveryregistry" + "Open_IM/pkg/proto/msg" + "context" + "google.golang.org/grpc" +) + +type MsgCheck struct { + zk discoveryRegistry.SvcDiscoveryRegistry +} + +func (m *MsgCheck) getConn() (*grpc.ClientConn, error) { + return m.zk.GetConn(config.Config.RpcRegisterName.OpenImMsgName) +} + +func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) { + cc, err := m.getConn() + if err != nil { + return nil, err + } + resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req) + return resp, err +} diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go index 5dac5fed4..098bdcf56 100644 --- a/internal/common/notification/c.go +++ b/internal/common/notification/c.go @@ -4,8 +4,10 @@ import ( "Open_IM/internal/common/check" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/tracelog" "Open_IM/pkg/proto/msg" "Open_IM/pkg/proto/sdkws" + utils2 "Open_IM/pkg/utils" "context" utils "github.com/OpenIMSDK/open_utils" ) @@ -13,6 +15,7 @@ import ( type Check struct { user *check.UserCheck group *check.GroupChecker + msg *check.MsgCheck } type NotificationMsg struct { @@ -26,28 +29,33 @@ type NotificationMsg struct { SenderFaceURL string } -func (c *Check) Notification(ctx context.Context, n *NotificationMsg) { +func (c *Check) Notification(ctx context.Context, notificationMsg *NotificationMsg) { + var err error + defer func() { + tracelog.SetCtxDebug(ctx, utils2.GetFuncName(1), err, "notificationMsg", notificationMsg) + }() + var req msg.SendMsgReq var msg sdkws.MsgData var offlineInfo sdkws.OfflinePushInfo var title, desc, ex string var pushSwitch, unReadCount bool var reliabilityLevel int - msg.SendID = n.SendID - msg.RecvID = n.RecvID - msg.Content = n.Content - msg.MsgFrom = n.MsgFrom - msg.ContentType = n.ContentType - msg.SessionType = n.SessionType + msg.SendID = notificationMsg.SendID + msg.RecvID = notificationMsg.RecvID + msg.Content = notificationMsg.Content + msg.MsgFrom = notificationMsg.MsgFrom + msg.ContentType = notificationMsg.ContentType + msg.SessionType = notificationMsg.SessionType msg.CreateTime = utils.GetCurrentTimestampByMill() - msg.ClientMsgID = utils.GetMsgID(n.SendID) + msg.ClientMsgID = utils.GetMsgID(notificationMsg.SendID) msg.Options = make(map[string]bool, 7) - msg.SenderNickname = n.SenderNickname - msg.SenderFaceURL = n.SenderFaceURL - switch n.SessionType { + msg.SenderNickname = notificationMsg.SenderNickname + msg.SenderFaceURL = notificationMsg.SenderFaceURL + switch notificationMsg.SessionType { case constant.GroupChatType, constant.SuperGroupChatType: msg.RecvID = "" - msg.GroupID = n.RecvID + msg.GroupID = notificationMsg.RecvID } offlineInfo.IOSBadgeCount = config.Config.IOSPush.BadgeCount offlineInfo.IOSPushSound = config.Config.IOSPush.PushSound @@ -280,9 +288,5 @@ func (c *Check) Notification(ctx context.Context, n *NotificationMsg) { msg.OfflinePushInfo = &offlineInfo req.MsgData = &msg - _, err := sendMsg(context.Background(), &req) -} - -func sendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) { - + _, err = c.msg.SendMsg(ctx, &req) } diff --git a/internal/common/notification/friend.go b/internal/common/notification/friend.go index 684700154..7a521c329 100644 --- a/internal/common/notification/friend.go +++ b/internal/common/notification/friend.go @@ -148,12 +148,6 @@ func (c *Check) BlackDeletedNotification(ctx context.Context, req *pbFriend.Remo c.friendNotification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips) } -// send to myself -func (c *Check) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) { - selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} - c.friendNotification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) -} - func (c *Check) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} c.friendNotification(ctx, opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips) diff --git a/internal/common/notification/user.go b/internal/common/notification/user.go new file mode 100644 index 000000000..01d5fcee8 --- /dev/null +++ b/internal/common/notification/user.go @@ -0,0 +1,13 @@ +package notification + +import ( + "Open_IM/pkg/common/constant" + "Open_IM/pkg/proto/sdkws" + "context" +) + +// send to myself +func (c *Check) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) { + selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} + c.friendNotification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) +} diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 3b99ede9d..a73e82233 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -3,7 +3,7 @@ package friend import ( "Open_IM/internal/common/check" "Open_IM/internal/common/convert" - chat "Open_IM/internal/common/notification" + "Open_IM/internal/common/notification" "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" @@ -26,6 +26,8 @@ type friendServer struct { *rpcserver.RpcServer controller.FriendInterface controller.BlackInterface + notification *notification.Check + userCheck *check.UserCheck } func NewFriendServer(port int) *friendServer { @@ -105,7 +107,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.Apply if req.ToUserID == req.FromUserID { return nil, constant.ErrCanNotAddYourself.Wrap() } - if _, err := check.GetUsersInfo(ctx, req.ToUserID, req.FromUserID); err != nil { + if _, err := s.userCheck.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}, true); err != nil { return nil, err } in1, in2, err := s.FriendInterface.CheckIn(ctx, req.FromUserID, req.ToUserID) @@ -118,7 +120,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.Apply if err = s.FriendInterface.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil { return nil, err } - chat.FriendApplicationAddNotification(ctx, req) + s.notification.FriendApplicationAddNotification(ctx, req) return resp, nil } @@ -128,7 +130,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFr if err := tokenverify.CheckAdmin(ctx); err != nil { return nil, err } - if _, err := check.NewUserCheck().GetUsersInfos(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...), true); err != nil { + if _, err := s.userCheck.GetUsersInfos(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...), true); err != nil { return nil, err } @@ -157,7 +159,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res if err != nil { return nil, err } - chat.FriendApplicationAgreedNotification(ctx, req) + s.notification.FriendApplicationAgreedNotification(ctx, req) return resp, nil } if req.HandleResult == constant.FriendResponseRefuse { @@ -165,7 +167,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res if err != nil { return nil, err } - chat.FriendApplicationRefusedNotification(ctx, req) + s.notification.FriendApplicationRefusedNotification(ctx, req) return resp, nil } return nil, constant.ErrArgs.Wrap("req.HandleResult != -1/1") @@ -184,7 +186,7 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri if err := s.FriendInterface.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil { return nil, err } - chat.FriendDeletedNotification(ctx, req) + s.notification.FriendDeletedNotification(ctx, req) return resp, nil } @@ -201,7 +203,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFri if err := s.FriendInterface.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil { return nil, err } - chat.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID) + s.notification.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID) return resp, nil } diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index d25d331d5..658de155d 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -1,8 +1,9 @@ package user import ( + "Open_IM/internal/common/check" "Open_IM/internal/common/convert" - chat "Open_IM/internal/common/notification" + "Open_IM/internal/common/notification" "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" @@ -25,6 +26,8 @@ import ( type userServer struct { *rpcserver.RpcServer controller.UserInterface + notification *notification.Check + userCheck *check.UserCheck } func NewUserServer(port int) *userServer { @@ -226,11 +229,11 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI } go func() { for _, v := range friends { - chat.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx)) + s.notification.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx)) } }() - chat.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID) + s.notification.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID) return resp, nil } @@ -246,7 +249,7 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Se if err := s.UpdateByMap(ctx, req.UserID, m); err != nil { return nil, err } - chat.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID) + s.notification.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID) return resp, nil } From f5c4e755eb83928b2c97fd4b640c7046bf4c4809 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 14 Feb 2023 11:37:19 +0800 Subject: [PATCH 29/48] rpc start --- cmd/rpc/group/main.go | 17 +----- internal/rpc/group/group.go | 103 +----------------------------------- internal/startrpc/start.go | 23 ++++---- 3 files changed, 16 insertions(+), 127 deletions(-) diff --git a/cmd/rpc/group/main.go b/cmd/rpc/group/main.go index ad9ba151c..2ccae9e6b 100644 --- a/cmd/rpc/group/main.go +++ b/cmd/rpc/group/main.go @@ -7,20 +7,5 @@ import ( ) func main() { - //defaultPorts := config.Config.RpcPort.OpenImGroupPort - //rpcPort := flag.Int("port", defaultPorts[0], "get RpcGroupPort from cmd,default 16000 as port") - //prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.GroupPrometheusPort[0], "groupPrometheusPort default listen port") - //flag.Parse() - //fmt.Println("start group rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n") - //rpcServer := group.NewGroupServer(*rpcPort) - //go func() { - // err := promePkg.StartPromeSrv(*prometheusPort) - // if err != nil { - // panic(err) - // } - //}() - //rpcServer.Run() - - startrpc.StartRpc(config.Config.RpcPort.OpenImGroupPort[0], config.Config.RpcRegisterName.OpenImGroupName, config.Config.Prometheus.GroupPrometheusPort[0], group.Start) - + startrpc.Start(config.Config.RpcPort.OpenImGroupPort[0], config.Config.RpcRegisterName.OpenImGroupName, config.Config.Prometheus.GroupPrometheusPort[0], group.Start) } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index bd964b5b0..7ee2e93f1 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -26,121 +26,22 @@ import ( "time" ) -func Start(server *grpc.Server) { - //err := mysql.InitConn().AutoMigrateModel(&groupModel) - //if err != nil { - // panic("db init err:" + err.Error()) - //} - //mongo.InitMongo() - //redis.InitRedis() +func Start(server *grpc.Server) error { pbGroup.RegisterGroupServer(server, &groupServer{ GroupInterface: controller.NewGroupInterface(nil, cache.NewRedis().GetClient(), unrelation.NewMongo().GetClient()), registerCenter: nil, user: check.NewUserCheck(nil), }) + return nil } type groupServer struct { - //rpcPort int - //rpcRegisterName string - //schema string - //zkAddr []string GroupInterface controller.GroupInterface registerCenter discoveryRegistry.SvcDiscoveryRegistry user *check.UserCheck notification *notification.Check } -// -//type groupServer struct { -// rpcPort int -// rpcRegisterName string -// schema string -// zkAddr []string -// GroupInterface controller.GroupInterface -// registerCenter discoveryRegistry.SvcDiscoveryRegistry -// user *check.UserCheck -//} -// -//func NewGroupServer(port int) *groupServer { -// log.NewPrivateLog(constant.LogFileName) -// g := groupServer{ -// rpcPort: port, -// rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName, -// schema: config.Config.Zookeeper.Schema, -// zkAddr: config.Config.Zookeeper.ZkAddr, -// } -// //mysql init -// var mysql relation.Mysql -// var mongo unrelation.Mongo -// var groupModel relationTb.GroupModel -// var redis cache.RedisClient -// err := mysql.InitConn().AutoMigrateModel(&groupModel) -// if err != nil { -// panic("db init err:" + err.Error()) -// } -// mongo.InitMongo() -// redis.InitRedis() -// mongo.CreateSuperGroupIndex() -// zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, 10, "", "") -// if err != nil { -// panic(err.Error()) -// } -// registerIP, err := network.GetRpcRegisterIP(config.Config.RpcRegisterIP) -// g.registerCenter = zkClient -// err = g.registerCenter.Register(config.Config.RpcRegisterName.OpenImGroupName, registerIP, port) -// if err != nil { -// panic(err.Error()) -// } -// -// //conns, err := g.registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName) -// g.GroupInterface = controller.NewGroupInterface(mysql.GormConn(), redis.GetClient(), mongo.GetClient()) -// g.user = check.NewUserCheck() -// return &g -//} -// -//func (s *groupServer) Run() { -// operationID := utils.OperationIDGenerator() -// log.NewInfo(operationID, "group rpc start ") -// address := network.GetListenIP(config.Config.ListenIP) + ":" + strconv.Itoa(s.rpcPort) -// //listener network -// listener, err := net.Listen("tcp", address) -// if err != nil { -// panic("listening err:" + err.Error() + s.rpcRegisterName) -// } -// log.NewInfo(operationID, "listen network success, ", address, listener) -// -// defer listener.Close() -// //grpc server -// recvSize := 1024 * 1024 * constant.GroupRPCRecvSize -// sendSize := 1024 * 1024 * constant.GroupRPCSendSize -// var grpcOpts = []grpc.ServerOption{ -// grpc.MaxRecvMsgSize(recvSize), -// grpc.MaxSendMsgSize(sendSize), -// grpc.UnaryInterceptor(middleware.RpcServerInterceptor), -// } -// if config.Config.Prometheus.Enable { -// promePkg.NewGrpcRequestCounter() -// promePkg.NewGrpcRequestFailedCounter() -// promePkg.NewGrpcRequestSuccessCounter() -// grpcOpts = append(grpcOpts, []grpc.ServerOption{ -// // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), -// grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), -// grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), -// }...) -// } -// srv := grpc.NewServer(grpcOpts...) -// defer srv.GracefulStop() -// //Service registers with etcd -// pbGroup.RegisterGroupServer(srv, s) -// err = srv.Serve(listener) -// if err != nil { -// log.NewError(operationID, "Serve failed ", err.Error()) -// return -// } -// log.NewInfo(operationID, "group rpc success") -//} - func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error { if !tokenverify.IsAppManagerUid(ctx) { groupMember, err := s.GroupInterface.TakeGroupMember(ctx, groupID, tracelog.GetOpUserID(ctx)) diff --git a/internal/startrpc/start.go b/internal/startrpc/start.go index 841ee3cbc..ba4b6a5b6 100644 --- a/internal/startrpc/start.go +++ b/internal/startrpc/start.go @@ -15,7 +15,7 @@ import ( "net" ) -func StartRpc(rpcPort int, rpcRegisterName string, prometheusPort int, fn func(server *grpc.Server), options ...grpc.ServerOption) { +func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(server *grpc.Server) error, options []grpc.ServerOption) error { flagRpcPort := flag.Int("port", rpcPort, "get RpcGroupPort from cmd,default 16000 as port") flagPrometheusPort := flag.Int("prometheus_port", prometheusPort, "groupPrometheusPort default listen port") flag.Parse() @@ -25,16 +25,17 @@ func StartRpc(rpcPort int, rpcRegisterName string, prometheusPort int, fn func(s log.NewPrivateLog(constant.LogFileName) listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, rpcPort)) if err != nil { - panic(err) + return err } defer listener.Close() zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, 10, "", "") if err != nil { - panic(err.Error()) + return err } + defer zkClient.Close() registerIP, err := network.GetRpcRegisterIP(config.Config.RpcRegisterIP) if err != nil { - panic(err) + return err } options = append(options, grpc.UnaryInterceptor(middleware.RpcServerInterceptor)) // ctx 中间件 if config.Config.Prometheus.Enable { @@ -49,18 +50,20 @@ func StartRpc(rpcPort int, rpcRegisterName string, prometheusPort int, fn func(s } srv := grpc.NewServer(options...) defer srv.GracefulStop() - fn(srv) err = zkClient.Register(rpcRegisterName, registerIP, rpcPort) if err != nil { - panic(err.Error()) + return err } if config.Config.Prometheus.Enable { err := promePkg.StartPromeSrv(prometheusPort) if err != nil { - panic(err) + return err } } - if err := srv.Serve(listener); err != nil { - panic(err) - } + return rpcFn(srv) +} + +func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(server *grpc.Server) error, options ...grpc.ServerOption) { + err := start(rpcPort, rpcRegisterName, prometheusPort, rpcFn, options) + fmt.Println("end", err) } From 20829cdd28095cd8b714c6ea19ea5be1add511a5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 11:41:04 +0800 Subject: [PATCH 30/48] Error code standardization --- internal/common/notification/extend_msg.go | 39 +++++++++------------- internal/rpc/friend/black.go | 5 ++- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/internal/common/notification/extend_msg.go b/internal/common/notification/extend_msg.go index 5a3b78a07..18f0d7b91 100644 --- a/internal/common/notification/extend_msg.go +++ b/internal/common/notification/extend_msg.go @@ -1,16 +1,16 @@ package notification import ( - "Open_IM/pkg/common/config" + "Open_IM/pkg/apistruct" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" "Open_IM/pkg/proto/msg" sdkws "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" ) -func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID string, sessionType int32, +func (c *Check) ExtendMessageUpdatedNotification(ctx context.Context, sendID string, sourceID string, sessionType int32, req *msg.SetMessageReactionExtensionsReq, resp *msg.SetMessageReactionExtensionsResp, isHistory bool, isReactionFromCache bool) { var m apistruct.ReactionMessageModifierNotification m.SourceID = req.SourceID @@ -23,7 +23,6 @@ func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID strin } } if len(keyMap) == 0 { - log.NewWarn(operationID, "all key set failed can not send notification", *req) return } m.SuccessReactionExtensionList = keyMap @@ -31,9 +30,9 @@ func ExtendMessageUpdatedNotification(operationID, sendID string, sourceID strin m.IsReact = resp.IsReact m.IsExternalExtensions = req.IsExternalExtensions m.MsgFirstModifyTime = resp.MsgFirstModifyTime - messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache) + c.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageModifier, utils.StructToJsonString(m), isHistory, isReactionFromCache) } -func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string, sessionType int32, +func (c *Check) ExtendMessageDeleteNotification(ctx context.Context, sendID string, sourceID string, sessionType int32, req *msg.DeleteMessageListReactionExtensionsReq, resp *msg.DeleteMessageListReactionExtensionsResp, isHistory bool, isReactionFromCache bool) { var m apistruct.ReactionMessageDeleteNotification m.SourceID = req.SourceID @@ -46,16 +45,20 @@ func ExtendMessageDeleteNotification(operationID, sendID string, sourceID string } } if len(keyMap) == 0 { - log.NewWarn(operationID, "all key set failed can not send notification", *req) return } m.SuccessReactionExtensionList = keyMap m.ClientMsgID = req.ClientMsgID m.MsgFirstModifyTime = req.MsgFirstModifyTime - messageReactionSender(operationID, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache) + c.messageReactionSender(ctx, sendID, sourceID, sessionType, constant.ReactionMessageDeleter, utils.StructToJsonString(m), isHistory, isReactionFromCache) } -func messageReactionSender(operationID, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) { +func (c *Check) messageReactionSender(ctx context.Context, sendID string, sourceID string, sessionType, contentType int32, content string, isHistory bool, isReactionFromCache bool) { + var err error + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "sendID", sendID, "sourceID", sourceID, "sessionType", sessionType) + }() + options := make(map[string]bool, 5) utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false) utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false) @@ -67,7 +70,6 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT utils.SetSwitchFromOptions(options, constant.IsPersistent, false) } pbData := msg.SendMsgReq{ - OperationID: operationID, MsgData: &sdkws.MsgData{ SendID: sendID, ClientMsgID: utils.GetMsgID(sendID), @@ -75,9 +77,8 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT MsgFrom: constant.SysMsgType, ContentType: contentType, Content: []byte(content), - // ForceList: params.ForceList, - CreateTime: utils.GetCurrentTimestampByMill(), - Options: options, + CreateTime: utils.GetCurrentTimestampByMill(), + Options: options, }, } switch sessionType { @@ -86,15 +87,5 @@ func messageReactionSender(operationID, sendID string, sourceID string, sessionT case constant.GroupChatType, constant.SuperGroupChatType: pbData.MsgData.GroupID = sourceID } - etcdConn, err := rpc.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName) - if err != nil { - return - } - client := msg.NewMsgClient(etcdConn) - reply, err := client.SendMsg(context.Background(), &pbData) - if err != nil { - log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), err.Error()) - } else if reply.ErrCode != 0 { - log.NewError(operationID, "SendMsg rpc failed, ", pbData.String(), reply.ErrCode, reply.ErrMsg) - } + _, err = c.msg.SendMsg(ctx, &pbData) } diff --git a/internal/rpc/friend/black.go b/internal/rpc/friend/black.go index 37485e854..a77e3c267 100644 --- a/internal/rpc/friend/black.go +++ b/internal/rpc/friend/black.go @@ -3,7 +3,6 @@ package friend import ( "Open_IM/internal/common/check" "Open_IM/internal/common/convert" - chat "Open_IM/internal/common/notification" "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" @@ -47,7 +46,7 @@ func (s *friendServer) RemoveBlack(ctx context.Context, req *pbFriend.RemoveBlac if err := s.BlackInterface.Delete(ctx, []*relation.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil { return nil, err } - chat.BlackDeletedNotification(ctx, req) + s.notification.BlackDeletedNotification(ctx, req) return resp, nil } @@ -60,6 +59,6 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq) if err := s.BlackInterface.Create(ctx, []*relation.BlackModel{&black}); err != nil { return nil, err } - chat.BlackAddedNotification(ctx, req) + s.notification.BlackAddedNotification(ctx, req) return resp, nil } From 461fd5f1ff65fb343259504dcffe71329cd33c33 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 11:49:42 +0800 Subject: [PATCH 31/48] Error code standardization --- internal/common/check/access.go | 5 ++--- internal/common/check/friend.go | 12 +++++++++++- internal/common/notification/c.go | 7 ++++--- internal/common/notification/friend.go | 3 +-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/common/check/access.go b/internal/common/check/access.go index 71254b903..bdd42c8aa 100644 --- a/internal/common/check/access.go +++ b/internal/common/check/access.go @@ -5,11 +5,10 @@ import ( "context" ) -func Access(ctx context.Context, ownerUserID string) (err error) { - _, err = GetUsersInfo(ctx, ownerUserID) +func (u *UserCheck) Access(ctx context.Context, ownerUserID string) (err error) { + _, err = u.GetUsersInfo(ctx, ownerUserID) if err != nil { return err } return tokenverify.CheckAccessV3(ctx, ownerUserID) - } diff --git a/internal/common/check/friend.go b/internal/common/check/friend.go index c48a42931..1cc6f0389 100644 --- a/internal/common/check/friend.go +++ b/internal/common/check/friend.go @@ -1,11 +1,21 @@ package check import ( + "Open_IM/pkg/common/config" + discoveryRegistry "Open_IM/pkg/discoveryregistry" sdkws "Open_IM/pkg/proto/sdkws" "context" "errors" + "google.golang.org/grpc" ) -func GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*sdkws.FriendInfo, error) { +type FriendChecker struct { + zk discoveryRegistry.SvcDiscoveryRegistry +} + +func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*sdkws.FriendInfo, error) { return nil, errors.New("TODO:GetUserInfo") } +func (u *FriendChecker) getConn() (*grpc.ClientConn, error) { + return u.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName) +} diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go index 098bdcf56..29894f806 100644 --- a/internal/common/notification/c.go +++ b/internal/common/notification/c.go @@ -13,9 +13,10 @@ import ( ) type Check struct { - user *check.UserCheck - group *check.GroupChecker - msg *check.MsgCheck + user *check.UserCheck + group *check.GroupChecker + msg *check.MsgCheck + friend *check.FriendChecker } type NotificationMsg struct { diff --git a/internal/common/notification/friend.go b/internal/common/notification/friend.go index 7a521c329..e4d2568cf 100644 --- a/internal/common/notification/friend.go +++ b/internal/common/notification/friend.go @@ -1,7 +1,6 @@ package notification import ( - "Open_IM/internal/common/check" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" pbFriend "Open_IM/pkg/proto/friend" @@ -112,7 +111,7 @@ func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUser friendAddedTips.OpUser.Nickname = user[0].Nickname friendAddedTips.OpUser.FaceURL = user[0].FaceURL - friend, err := check.GetFriendsInfo(ctx, fromUserID, toUserID) + friend, err := c.friend.GetFriendsInfo(ctx, fromUserID, toUserID) if err != nil { return } From 731112e61b0257d31e7f73044e522f9924c72076 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 11:55:50 +0800 Subject: [PATCH 32/48] Error code standardization --- internal/rpc/auth/auth.go | 3 ++- internal/rpc/friend/friend.go | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index dc6dd128e..603f60c22 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -65,7 +65,7 @@ func (s *rpcAuth) Run() { func (s *rpcAuth) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) { resp := pbAuth.UserTokenResp{} - if _, err := check.GetUsersInfo(ctx, req.UserID); err != nil { + if _, err := s.userCheck.GetUsersInfo(ctx, req.UserID); err != nil { return nil, err } token, err := s.CreateToken(ctx, req.UserID, constant.PlatformIDToName(int(req.PlatformID))) @@ -143,4 +143,5 @@ func (s *rpcAuth) forceKickOff(ctx context.Context, userID string, platformID in type rpcAuth struct { *rpcserver.RpcServer controller.AuthInterface + userCheck *check.UserCheck } diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index a73e82233..db2f357b0 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -150,7 +150,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFr // ok func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.RespondFriendApplyReq) (resp *pbFriend.RespondFriendApplyResp, err error) { resp = &pbFriend.RespondFriendApplyResp{} - if err := check.Access(ctx, req.ToUserID); err != nil { + if err := s.userCheck.Access(ctx, req.ToUserID); err != nil { return nil, err } friendRequest := relationTb.FriendRequestModel{FromUserID: req.FromUserID, ToUserID: req.ToUserID, HandleMsg: req.HandleMsg, HandleResult: req.HandleResult} @@ -176,7 +176,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res // ok func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (resp *pbFriend.DeleteFriendResp, err error) { resp = &pbFriend.DeleteFriendResp{} - if err := check.Access(ctx, req.OwnerUserID); err != nil { + if err := s.userCheck.Access(ctx, req.OwnerUserID); err != nil { return nil, err } _, err = s.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID}) @@ -193,7 +193,7 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri // ok func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFriendRemarkReq) (resp *pbFriend.SetFriendRemarkResp, err error) { resp = &pbFriend.SetFriendRemarkResp{} - if err := check.Access(ctx, req.OwnerUserID); err != nil { + if err := s.userCheck.Access(ctx, req.OwnerUserID); err != nil { return nil, err } _, err = s.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID}) @@ -210,7 +210,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFri // ok func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbFriend.GetDesignatedFriendsReq) (resp *pbFriend.GetDesignatedFriendsResp, err error) { resp = &pbFriend.GetDesignatedFriendsResp{} - if err := check.Access(ctx, req.UserID); err != nil { + if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } friends, total, err := s.FriendInterface.PageOwnerFriends(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) @@ -228,7 +228,7 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbFriend.G // ok 获取接收到的好友申请(即别人主动申请的) func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbFriend.GetPaginationFriendsApplyToReq) (resp *pbFriend.GetPaginationFriendsApplyToResp, err error) { resp = &pbFriend.GetPaginationFriendsApplyToResp{} - if err := check.Access(ctx, req.UserID); err != nil { + if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } friendRequests, total, err := s.FriendInterface.PageFriendRequestToMe(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) @@ -246,7 +246,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbF // ok 获取主动发出去的好友申请列表 func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbFriend.GetPaginationFriendsApplyFromReq) (resp *pbFriend.GetPaginationFriendsApplyFromResp, err error) { resp = &pbFriend.GetPaginationFriendsApplyFromResp{} - if err := check.Access(ctx, req.UserID); err != nil { + if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } friendRequests, total, err := s.FriendInterface.PageFriendRequestFromMe(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) From 9eb0ee55f334d413059cdd6f6380b7c71a9943ce Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 12:06:58 +0800 Subject: [PATCH 33/48] Error code standardization --- internal/common/check/conversation.go | 16 ++++++++++++++++ internal/common/check/friend.go | 25 ++++++++++++++++++++----- internal/common/check/msg.go | 4 ++++ internal/rpc/friend/black.go | 5 ++--- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/internal/common/check/conversation.go b/internal/common/check/conversation.go index b56c35741..9ebb1b299 100644 --- a/internal/common/check/conversation.go +++ b/internal/common/check/conversation.go @@ -1,15 +1,31 @@ package check import ( + "Open_IM/pkg/common/config" discoveryRegistry "Open_IM/pkg/discoveryregistry" + "Open_IM/pkg/proto/conversation" pbConversation "Open_IM/pkg/proto/conversation" "context" + "google.golang.org/grpc" ) type ConversationChecker struct { zk discoveryRegistry.SvcDiscoveryRegistry } +func NewConversationChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *ConversationChecker { + return &ConversationChecker{zk: zk} +} + func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (resp *pbConversation.ModifyConversationFieldResp, err error) { + cc, err := c.getConn() + if err != nil { + return nil, err + } + resp, err = conversation.NewConversationClient(cc).ModifyConversationField(ctx, req) return } + +func (c *ConversationChecker) getConn() (*grpc.ClientConn, error) { + return c.zk.GetConn(config.Config.RpcRegisterName.OpenImConversationName) +} diff --git a/internal/common/check/friend.go b/internal/common/check/friend.go index 1cc6f0389..6c258a38c 100644 --- a/internal/common/check/friend.go +++ b/internal/common/check/friend.go @@ -3,9 +3,9 @@ package check import ( "Open_IM/pkg/common/config" discoveryRegistry "Open_IM/pkg/discoveryregistry" + "Open_IM/pkg/proto/friend" sdkws "Open_IM/pkg/proto/sdkws" "context" - "errors" "google.golang.org/grpc" ) @@ -13,9 +13,24 @@ type FriendChecker struct { zk discoveryRegistry.SvcDiscoveryRegistry } -func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*sdkws.FriendInfo, error) { - return nil, errors.New("TODO:GetUserInfo") +func NewFriendChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *FriendChecker { + return &FriendChecker{ + zk: zk, + } } -func (u *FriendChecker) getConn() (*grpc.ClientConn, error) { - return u.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName) + +func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (resp *sdkws.FriendInfo, err error) { + cc, err := f.getConn() + if err != nil { + return nil, err + } + r, err := friend.NewFriendClient(cc).GetPaginationFriends(ctx, &friend.GetPaginationFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}}) + if err != nil { + return nil, err + } + resp = r.FriendsInfo[0] + return +} +func (f *FriendChecker) getConn() (*grpc.ClientConn, error) { + return f.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName) } diff --git a/internal/common/check/msg.go b/internal/common/check/msg.go index c4f1dfc03..010ee1606 100644 --- a/internal/common/check/msg.go +++ b/internal/common/check/msg.go @@ -12,6 +12,10 @@ type MsgCheck struct { zk discoveryRegistry.SvcDiscoveryRegistry } +func NewMsgCheck(zk discoveryRegistry.SvcDiscoveryRegistry) *MsgCheck { + return &MsgCheck{zk: zk} +} + func (m *MsgCheck) getConn() (*grpc.ClientConn, error) { return m.zk.GetConn(config.Config.RpcRegisterName.OpenImMsgName) } diff --git a/internal/rpc/friend/black.go b/internal/rpc/friend/black.go index a77e3c267..9969fd478 100644 --- a/internal/rpc/friend/black.go +++ b/internal/rpc/friend/black.go @@ -1,7 +1,6 @@ package friend import ( - "Open_IM/internal/common/check" "Open_IM/internal/common/convert" "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/tokenverify" @@ -12,7 +11,7 @@ import ( func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbFriend.GetPaginationBlacksReq) (resp *pbFriend.GetPaginationBlacksResp, err error) { resp = &pbFriend.GetPaginationBlacksResp{} - if err := check.Access(ctx, req.UserID); err != nil { + if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } blacks, total, err := s.BlackInterface.FindOwnerBlacks(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) @@ -40,7 +39,7 @@ func (s *friendServer) IsBlack(ctx context.Context, req *pbFriend.IsBlackReq) (* func (s *friendServer) RemoveBlack(ctx context.Context, req *pbFriend.RemoveBlackReq) (*pbFriend.RemoveBlackResp, error) { resp := &pbFriend.RemoveBlackResp{} - if err := check.Access(ctx, req.OwnerUserID); err != nil { + if err := s.userCheck.Access(ctx, req.OwnerUserID); err != nil { return nil, err } if err := s.BlackInterface.Delete(ctx, []*relation.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil { From c2375100800483f6ad7548de72f1d2006d9de24c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 12:10:15 +0800 Subject: [PATCH 34/48] Error code standardization --- internal/common/notification/c.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/common/notification/c.go b/internal/common/notification/c.go index 29894f806..52f6853b2 100644 --- a/internal/common/notification/c.go +++ b/internal/common/notification/c.go @@ -5,6 +5,7 @@ import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/tracelog" + discoveryRegistry "Open_IM/pkg/discoveryregistry" "Open_IM/pkg/proto/msg" "Open_IM/pkg/proto/sdkws" utils2 "Open_IM/pkg/utils" @@ -13,10 +14,21 @@ import ( ) type Check struct { - user *check.UserCheck - group *check.GroupChecker - msg *check.MsgCheck - friend *check.FriendChecker + user *check.UserCheck + group *check.GroupChecker + msg *check.MsgCheck + friend *check.FriendChecker + conversation *check.ConversationChecker +} + +func NewCheck(zk discoveryRegistry.SvcDiscoveryRegistry) *Check { + return &Check{ + user: check.NewUserCheck(zk), + group: check.NewGroupChecker(zk), + msg: check.NewMsgCheck(zk), + friend: check.NewFriendChecker(zk), + conversation: check.NewConversationChecker(zk), + } } type NotificationMsg struct { From 1ae1f77a143e88b1feed57abbea244fec81c4b32 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 14 Feb 2023 15:02:45 +0800 Subject: [PATCH 35/48] msg cb --- internal/rpc/msg/callback.go | 239 +++++++++------------------------ pkg/callbackstruct/common.go | 26 ++-- pkg/common/http/http_client.go | 20 +++ pkg/utils/utils_v2.go | 8 ++ 4 files changed, 112 insertions(+), 181 deletions(-) diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index d82c776da..96f97137e 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -5,18 +5,23 @@ import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" - "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" pbChat "Open_IM/pkg/proto/msg" "Open_IM/pkg/utils" - http2 "net/http" + "context" ) -func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbapi.CommonCallbackReq { - req := cbapi.CommonCallbackReq{ +func cbURL() string { + return config.Config.Callback.CallbackUrl +} + +func toCommonCallback(ctx context.Context, msg *pbChat.SendMsgReq, command string) cbapi.CommonCallbackReq { + return cbapi.CommonCallbackReq{ SendID: msg.MsgData.SendID, ServerMsgID: msg.MsgData.ServerMsgID, + CallbackCommand: command, ClientMsgID: msg.MsgData.ClientMsgID, - OperationID: msg.OperationID, + OperationID: tracelog.GetOperationID(ctx), SenderPlatformID: msg.MsgData.SenderPlatformID, SenderNickname: msg.MsgData.SenderNickname, SessionType: msg.MsgData.SessionType, @@ -30,198 +35,86 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbapi.CommonCallbackReq Seq: msg.MsgData.Seq, Ex: msg.MsgData.Ex, } - return req } -func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (err error) { - callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} +func CallbackBeforeSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) error { if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable { - return callbackResp + return nil } - log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) - commonCallbackReq := copyCallbackCommonReqStruct(msg) - commonCallbackReq.CallbackCommand = constant.CallbackBeforeSendSingleMsgCommand - req := cbapi.CallbackBeforeSendSingleMsgReq{ - CommonCallbackReq: commonCallbackReq, + req := &cbapi.CallbackBeforeSendSingleMsgReq{ + CommonCallbackReq: toCommonCallback(ctx, msg, constant.CallbackBeforeSendSingleMsgCommand), RecvID: msg.MsgData.RecvID, } - resp := &cbapi.CallbackBeforeSendSingleMsgResp{ - CommonCallbackResp: &callbackResp, - } - //utils.CopyStructFields(req, msg.MsgData) - defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSendSingleMsgCommand, - req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - if !*config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackFailedContinue { - callbackResp.ActionCode = constant.ActionForbidden - return callbackResp - } else { - callbackResp.ActionCode = constant.ActionAllow - return callbackResp - } - } - return callbackResp + resp := &cbapi.CallbackBeforeSendSingleMsgResp{} + return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg) } -func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) error { - callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} +func CallbackAfterSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) error { if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable { - return callbackResp + return nil } - log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) - commonCallbackReq := copyCallbackCommonReqStruct(msg) - commonCallbackReq.CallbackCommand = constant.CallbackAfterSendSingleMsgCommand - req := cbapi.CallbackAfterSendSingleMsgReq{ - CommonCallbackReq: commonCallbackReq, + req := &cbapi.CallbackAfterSendSingleMsgReq{ + CommonCallbackReq: toCommonCallback(ctx, msg, constant.CallbackBeforeSendSingleMsgCommand), RecvID: msg.MsgData.RecvID, } - resp := &cbapi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendSingleMsgCommand, - req, resp, config.Config.Callback.CallbackAfterSendSingleMsg); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - return callbackResp - } - return callbackResp + resp := &cbapi.CallbackAfterSendSingleMsgResp{} + return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendSingleMsg) } -func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) error { - callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} - if !config.Config.Callback.CallbackBeforeSendGroupMsg.Enable { - return callbackResp +func CallbackBeforeSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) error { + if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable { + return nil } - log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) - commonCallbackReq := copyCallbackCommonReqStruct(msg) - commonCallbackReq.CallbackCommand = constant.CallbackBeforeSendGroupMsgCommand - req := cbapi.CallbackAfterSendGroupMsgReq{ - CommonCallbackReq: commonCallbackReq, + req := &cbapi.CallbackAfterSendGroupMsgReq{ + CommonCallbackReq: toCommonCallback(ctx, msg, constant.CallbackBeforeSendSingleMsgCommand), GroupID: msg.MsgData.GroupID, } - resp := &cbapi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSendGroupMsgCommand, - req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - if !*config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue { - callbackResp.ActionCode = constant.ActionForbidden - return callbackResp - } else { - callbackResp.ActionCode = constant.ActionAllow - return callbackResp - } - } - return callbackResp + resp := &cbapi.CallbackBeforeSendGroupMsgResp{} + return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendSingleMsg) } -func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) error { - callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} +func CallbackAfterSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) error { if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable { - return callbackResp + return nil } - log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) - commonCallbackReq := copyCallbackCommonReqStruct(msg) - commonCallbackReq.CallbackCommand = constant.CallbackAfterSendGroupMsgCommand - req := cbapi.CallbackAfterSendGroupMsgReq{ - CommonCallbackReq: commonCallbackReq, + req := &cbapi.CallbackAfterSendGroupMsgReq{ + CommonCallbackReq: toCommonCallback(ctx, msg, constant.CallbackAfterSendGroupMsgCommand), GroupID: msg.MsgData.GroupID, } - resp := &cbapi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendGroupMsgCommand, req, resp, - config.Config.Callback.CallbackAfterSendGroupMsg); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - return callbackResp - } - return callbackResp + resp := &cbapi.CallbackAfterSendGroupMsgResp{} + return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg) } -func callbackMsgModify(msg *pbChat.SendMsgReq) (err error) { - log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) - callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID} +func CallbackMsgModify(ctx context.Context, msg *pbChat.SendMsgReq) error { if !config.Config.Callback.CallbackMsgModify.Enable || msg.MsgData.ContentType != constant.Text { - return callbackResp - } - commonCallbackReq := copyCallbackCommonReqStruct(msg) - commonCallbackReq.CallbackCommand = constant.CallbackMsgModifyCommand - req := cbapi.CallbackMsgModifyCommandReq{ - CommonCallbackReq: commonCallbackReq, - } - resp := &cbapi.CallbackMsgModifyCommandResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackMsgModifyCommand, req, resp, - config.Config.Callback.CallbackMsgModify); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - if !*config.Config.Callback.CallbackMsgModify.CallbackFailedContinue { - callbackResp.ActionCode = constant.ActionForbidden - return callbackResp - } else { - callbackResp.ActionCode = constant.ActionAllow - return callbackResp - } - } - if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow { - if resp.Content != nil { - msg.MsgData.Content = []byte(*resp.Content) - } - if resp.RecvID != nil { - msg.MsgData.RecvID = *resp.RecvID - } - if resp.GroupID != nil { - msg.MsgData.GroupID = *resp.GroupID - } - if resp.ClientMsgID != nil { - msg.MsgData.ClientMsgID = *resp.ClientMsgID - } - if resp.ServerMsgID != nil { - msg.MsgData.ServerMsgID = *resp.ServerMsgID - } - if resp.SenderPlatformID != nil { - msg.MsgData.SenderPlatformID = *resp.SenderPlatformID - } - if resp.SenderNickname != nil { - msg.MsgData.SenderNickname = *resp.SenderNickname - } - if resp.SenderFaceURL != nil { - msg.MsgData.SenderFaceURL = *resp.SenderFaceURL - } - if resp.SessionType != nil { - msg.MsgData.SessionType = *resp.SessionType - } - if resp.MsgFrom != nil { - msg.MsgData.MsgFrom = *resp.MsgFrom - } - if resp.ContentType != nil { - msg.MsgData.ContentType = *resp.ContentType - } - if resp.Status != nil { - msg.MsgData.Status = *resp.Status - } - if resp.Options != nil { - msg.MsgData.Options = *resp.Options - } - if resp.OfflinePushInfo != nil { - msg.MsgData.OfflinePushInfo = resp.OfflinePushInfo - } - if resp.AtUserIDList != nil { - msg.MsgData.AtUserIDList = *resp.AtUserIDList - } - if resp.MsgDataList != nil { - msg.MsgData.MsgDataList = *resp.MsgDataList - } - if resp.AttachedInfo != nil { - msg.MsgData.AttachedInfo = *resp.AttachedInfo - } - if resp.Ex != nil { - msg.MsgData.Ex = *resp.Ex - } - - } - log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), string(msg.MsgData.Content)) - return callbackResp + return nil + } + req := &cbapi.CallbackMsgModifyCommandReq{ + CommonCallbackReq: toCommonCallback(ctx, msg, constant.CallbackMsgModifyCommand), + } + resp := &cbapi.CallbackMsgModifyCommandResp{} + if err := http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg); err != nil { + return err + } + if resp.Content != nil { + msg.MsgData.Content = []byte(*resp.Content) + } + utils.NotNilReplace(msg.MsgData.OfflinePushInfo, resp.OfflinePushInfo) + utils.NotNilReplace(&msg.MsgData.RecvID, resp.RecvID) + utils.NotNilReplace(&msg.MsgData.GroupID, resp.GroupID) + utils.NotNilReplace(&msg.MsgData.ClientMsgID, resp.ClientMsgID) + utils.NotNilReplace(&msg.MsgData.ServerMsgID, resp.ServerMsgID) + utils.NotNilReplace(&msg.MsgData.SenderPlatformID, resp.SenderPlatformID) + utils.NotNilReplace(&msg.MsgData.SenderNickname, resp.SenderNickname) + utils.NotNilReplace(&msg.MsgData.SenderFaceURL, resp.SenderFaceURL) + utils.NotNilReplace(&msg.MsgData.SessionType, resp.SessionType) + utils.NotNilReplace(&msg.MsgData.MsgFrom, resp.MsgFrom) + utils.NotNilReplace(&msg.MsgData.ContentType, resp.ContentType) + utils.NotNilReplace(&msg.MsgData.Status, resp.Status) + utils.NotNilReplace(&msg.MsgData.Options, resp.Options) + utils.NotNilReplace(&msg.MsgData.AtUserIDList, resp.AtUserIDList) + utils.NotNilReplace(&msg.MsgData.MsgDataList, resp.MsgDataList) + utils.NotNilReplace(&msg.MsgData.AttachedInfo, resp.AttachedInfo) + utils.NotNilReplace(&msg.MsgData.Ex, resp.Ex) + return nil } diff --git a/pkg/callbackstruct/common.go b/pkg/callbackstruct/common.go index 8c96a132d..2f589fc91 100644 --- a/pkg/callbackstruct/common.go +++ b/pkg/callbackstruct/common.go @@ -25,26 +25,36 @@ type CommonCallbackReq struct { Ex string `json:"ex"` } +func (c *CommonCallbackReq) GetCallbackCommand() string { + return c.CallbackCommand +} + +type CallbackReq interface { + GetCallbackCommand() string +} + type CallbackResp interface { Parse() (err error) } type CommonCallbackResp struct { - ActionCode int `json:"actionCode"` - ErrCode int32 `json:"errCode"` - ErrMsg string `json:"errMsg"` - OperationID string `json:"operationID"` + ActionCode int `json:"actionCode"` + ErrCode int32 `json:"errCode"` + ErrMsg string `json:"errMsg"` + //OperationID string `json:"operationID"` } -func (c *CommonCallbackResp) Parse() (err error) { +func (c *CommonCallbackResp) Parse() error { + if c == nil { + return constant.ErrData.Wrap("callback common is nil") + } if c.ActionCode != constant.NoError || c.ErrCode != constant.NoError { newErr := constant.ErrCallback newErr.ErrCode = c.ErrCode newErr.DetailErrMsg = fmt.Sprintf("callback response error actionCode is %d, errCode is %d, errMsg is %s", c.ActionCode, c.ErrCode, c.ErrMsg) - err = newErr - return + return newErr.Wrap() } - return + return nil } type UserStatusBaseCallback struct { diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index dcf3de0d5..2ef3c4be4 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -78,3 +78,23 @@ func CallBackPostReturn(url, callbackCommand string, input interface{}, output c } return output.Parse() } + +func CallBackPostReturnV2(url string, req cbapi.CallbackReq, resp cbapi.CallbackResp, callbackConfig config.CallBackConfig) error { + v := urlLib.Values{} + v.Set("callbackCommand", req.GetCallbackCommand()) + url = url + "?" + v.Encode() + b, err := Post(url, req, callbackConfig.CallbackTimeOut) + if err != nil { + if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue { + return constant.ErrCallbackContinue + } + return constant.NewErrNetwork(err) + } + if err = json.Unmarshal(b, resp); err != nil { + if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue { + return constant.ErrCallbackContinue + } + return constant.NewErrData(err) + } + return resp.Parse() +} diff --git a/pkg/utils/utils_v2.go b/pkg/utils/utils_v2.go index bd2959845..f32a7b73a 100644 --- a/pkg/utils/utils_v2.go +++ b/pkg/utils/utils_v2.go @@ -425,3 +425,11 @@ func Unwrap(err error) error { } return err } + +// NotNilReplace 当new_不为空时, 将old设置为new_ +func NotNilReplace[T any](old, new_ *T) { + if old == nil || new_ == nil { + return + } + *old = *new_ +} From 8f308183280a23421231e0ec254e7eedc4433c03 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 15:17:56 +0800 Subject: [PATCH 36/48] Error code standardization --- internal/common/check/group.go | 12 ++++ internal/common/convert/convert.go | 98 +++++++++++++++--------------- internal/rpc/friend/friend.go | 8 +-- 3 files changed, 64 insertions(+), 54 deletions(-) diff --git a/internal/common/check/group.go b/internal/common/check/group.go index 6af51075e..89a094e0f 100644 --- a/internal/common/check/group.go +++ b/internal/common/check/group.go @@ -116,3 +116,15 @@ func (g *GroupChecker) GetOwnerAndAdminInfos(ctx context.Context, groupID string }) return resp.Members, err } + +func (g *GroupChecker) GetOwnerInfo(ctx context.Context, groupID string) (*sdkws.GroupMemberFullInfo, error) { + cc, err := g.getConn() + if err != nil { + return nil, err + } + resp, err := group.NewGroupClient(cc).GetGroupMemberRoleLevel(ctx, &group.GetGroupMemberRoleLevelReq{ + GroupID: groupID, + RoleLevels: []int32{constant.GroupOwner}, + }) + return resp.Members[0], err +} diff --git a/internal/common/convert/convert.go b/internal/common/convert/convert.go index 9d4f31f46..8349d5ea7 100644 --- a/internal/common/convert/convert.go +++ b/internal/common/convert/convert.go @@ -1,29 +1,22 @@ package convert import ( + "Open_IM/internal/common/check" "Open_IM/pkg/common/db/table/relation" + discoveryRegistry "Open_IM/pkg/discoveryregistry" sdk "Open_IM/pkg/proto/sdkws" + "context" utils "github.com/OpenIMSDK/open_utils" "time" ) -func getUsersInfo(userIDs []string) ([]*sdk.UserInfo, error) { - return nil, nil -} - -func getGroupOwnerInfo(groupID string) (*sdk.GroupMemberFullInfo, error) { - return nil, nil -} -func getNumberOfGroupMember(groupID string) (int32, error) { - return 0, nil -} - type DBFriend struct { *relation.FriendModel + userCheck *check.UserCheck } -func NewDBFriend(friend *relation.FriendModel) *DBFriend { - return &DBFriend{FriendModel: friend} +func NewDBFriend(friend *relation.FriendModel, zk discoveryRegistry.SvcDiscoveryRegistry) *DBFriend { + return &DBFriend{FriendModel: friend, userCheck: check.NewUserCheck(zk)} } type PBFriend struct { @@ -45,9 +38,9 @@ func (*PBFriend) PB2DB(friends []*sdk.FriendInfo) (DBFriends []*relation.FriendM return } -func (*DBFriend) DB2PB(friends []*relation.FriendModel) (PBFriends []*sdk.FriendInfo, err error) { +func (*DBFriend) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, friends []*relation.FriendModel) (PBFriends []*sdk.FriendInfo, err error) { for _, v := range friends { - u, err := NewDBFriend(v).Convert() + u, err := NewDBFriend(v, zk).Convert(ctx) if err != nil { return nil, err } @@ -56,14 +49,14 @@ func (*DBFriend) DB2PB(friends []*relation.FriendModel) (PBFriends []*sdk.Friend return } -func (db *DBFriend) Convert() (*sdk.FriendInfo, error) { +func (db *DBFriend) Convert(ctx context.Context) (*sdk.FriendInfo, error) { pbFriend := &sdk.FriendInfo{FriendUser: &sdk.UserInfo{}} utils.CopyStructFields(pbFriend, db) - user, err := getUsersInfo([]string{db.FriendUserID}) + user, err := db.userCheck.GetUsersInfo(ctx, db.FriendUserID) if err != nil { return nil, err } - utils.CopyStructFields(pbFriend.FriendUser, user[0]) + utils.CopyStructFields(pbFriend.FriendUser, user) pbFriend.CreateTime = db.CreateTime.Unix() pbFriend.FriendUser.CreateTime = db.CreateTime.Unix() @@ -80,10 +73,11 @@ func (pb *PBFriend) Convert() (*relation.FriendModel, error) { type DBFriendRequest struct { *relation.FriendRequestModel + userCheck *check.UserCheck } -func NewDBFriendRequest(friendRequest *relation.FriendRequestModel) *DBFriendRequest { - return &DBFriendRequest{FriendRequestModel: friendRequest} +func NewDBFriendRequest(friendRequest *relation.FriendRequestModel, zk discoveryRegistry.SvcDiscoveryRegistry) *DBFriendRequest { + return &DBFriendRequest{FriendRequestModel: friendRequest, userCheck: check.NewUserCheck(zk)} } type PBFriendRequest struct { @@ -105,9 +99,9 @@ func (*PBFriendRequest) PB2DB(friendRequests []*sdk.FriendRequest) (DBFriendRequ return } -func (*DBFriendRequest) DB2PB(friendRequests []*relation.FriendRequestModel) (PBFriendRequests []*sdk.FriendRequest, err error) { +func (*DBFriendRequest) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, friendRequests []*relation.FriendRequestModel) (PBFriendRequests []*sdk.FriendRequest, err error) { for _, v := range friendRequests { - u, err := NewDBFriendRequest(v).Convert() + u, err := NewDBFriendRequest(v, zk).Convert(ctx) if err != nil { return nil, err } @@ -123,23 +117,23 @@ func (pb *PBFriendRequest) Convert() (*relation.FriendRequestModel, error) { dbFriendRequest.HandleTime = utils.UnixSecondToTime(int64(pb.HandleTime)) return dbFriendRequest, nil } -func (db *DBFriendRequest) Convert() (*sdk.FriendRequest, error) { +func (db *DBFriendRequest) Convert(ctx context.Context) (*sdk.FriendRequest, error) { pbFriendRequest := &sdk.FriendRequest{} utils.CopyStructFields(pbFriendRequest, db) - user, err := getUsersInfo([]string{db.FromUserID}) + user, err := db.userCheck.GetUsersInfo(ctx, db.FromUserID) if err != nil { return nil, err } - pbFriendRequest.FromNickname = user[0].Nickname - pbFriendRequest.FromFaceURL = user[0].FaceURL - pbFriendRequest.FromGender = user[0].Gender - user, err = getUsersInfo([]string{db.ToUserID}) + pbFriendRequest.FromNickname = user.Nickname + pbFriendRequest.FromFaceURL = user.FaceURL + pbFriendRequest.FromGender = user.Gender + user, err = db.userCheck.GetUsersInfo(ctx, db.ToUserID) if err != nil { return nil, err } - pbFriendRequest.ToNickname = user[0].Nickname - pbFriendRequest.ToFaceURL = user[0].FaceURL - pbFriendRequest.ToGender = user[0].Gender + pbFriendRequest.ToNickname = user.Nickname + pbFriendRequest.ToFaceURL = user.FaceURL + pbFriendRequest.ToGender = user.Gender pbFriendRequest.CreateTime = db.CreateTime.Unix() pbFriendRequest.HandleTime = db.HandleTime.Unix() return pbFriendRequest, nil @@ -147,6 +141,7 @@ func (db *DBFriendRequest) Convert() (*sdk.FriendRequest, error) { type DBBlack struct { *relation.BlackModel + userCheck *check.UserCheck } func (*PBBlack) PB2DB(blacks []*sdk.BlackInfo) (DBBlacks []*relation.BlackModel, err error) { @@ -160,9 +155,9 @@ func (*PBBlack) PB2DB(blacks []*sdk.BlackInfo) (DBBlacks []*relation.BlackModel, return } -func (*DBBlack) DB2PB(blacks []*relation.BlackModel) (PBBlacks []*sdk.BlackInfo, err error) { +func (*DBBlack) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, blacks []*relation.BlackModel) (PBBlacks []*sdk.BlackInfo, err error) { for _, v := range blacks { - u, err := NewDBBlack(v).Convert() + u, err := NewDBBlack(v, zk).Convert(ctx) if err != nil { return nil, err } @@ -171,8 +166,8 @@ func (*DBBlack) DB2PB(blacks []*relation.BlackModel) (PBBlacks []*sdk.BlackInfo, return } -func NewDBBlack(black *relation.BlackModel) *DBBlack { - return &DBBlack{BlackModel: black} +func NewDBBlack(black *relation.BlackModel, zk discoveryRegistry.SvcDiscoveryRegistry) *DBBlack { + return &DBBlack{BlackModel: black, userCheck: check.NewUserCheck(zk)} } type PBBlack struct { @@ -189,11 +184,11 @@ func (pb *PBBlack) Convert() (*relation.BlackModel, error) { dbBlack.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime)) return dbBlack, nil } -func (db *DBBlack) Convert() (*sdk.BlackInfo, error) { +func (db *DBBlack) Convert(ctx context.Context) (*sdk.BlackInfo, error) { pbBlack := &sdk.BlackInfo{} utils.CopyStructFields(pbBlack, db) pbBlack.CreateTime = db.CreateTime.Unix() - user, err := getUsersInfo([]string{db.BlockUserID}) + user, err := db.userCheck.GetUsersInfo(ctx, db.BlockUserID) if err != nil { return nil, err } @@ -203,6 +198,8 @@ func (db *DBBlack) Convert() (*sdk.BlackInfo, error) { type DBGroup struct { *relation.GroupModel + zk discoveryRegistry.SvcDiscoveryRegistry + groupCheck *check.GroupChecker } func (*PBGroup) PB2DB(groups []*sdk.GroupInfo) (DBGroups []*relation.GroupModel, err error) { @@ -216,9 +213,9 @@ func (*PBGroup) PB2DB(groups []*sdk.GroupInfo) (DBGroups []*relation.GroupModel, return } -func (*DBGroup) DB2PB(groups []*relation.GroupModel) (PBGroups []*sdk.GroupInfo, err error) { +func (db *DBGroup) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, groups []*relation.GroupModel) (PBGroups []*sdk.GroupInfo, err error) { for _, v := range groups { - u, err := NewDBGroup(v).Convert() + u, err := NewDBGroup(v, zk).Convert(ctx) if err != nil { return nil, err } @@ -227,8 +224,8 @@ func (*DBGroup) DB2PB(groups []*relation.GroupModel) (PBGroups []*sdk.GroupInfo, return } -func NewDBGroup(group *relation.GroupModel) *DBGroup { - return &DBGroup{GroupModel: group} +func NewDBGroup(groupModel *relation.GroupModel, zk discoveryRegistry.SvcDiscoveryRegistry) *DBGroup { + return &DBGroup{GroupModel: groupModel, groupCheck: check.NewGroupChecker(zk)} } type PBGroup struct { @@ -244,20 +241,20 @@ func (pb *PBGroup) Convert() (*relation.GroupModel, error) { err := utils.CopyStructFields(dst, pb) return dst, err } -func (db *DBGroup) Convert() (*sdk.GroupInfo, error) { +func (db *DBGroup) Convert(ctx context.Context) (*sdk.GroupInfo, error) { dst := &sdk.GroupInfo{} utils.CopyStructFields(dst, db) - user, err := getGroupOwnerInfo(db.GroupID) + user, err := db.groupCheck.GetOwnerInfo(ctx, db.GroupID) if err != nil { return nil, err } dst.OwnerUserID = user.UserID - memberCount, err := getNumberOfGroupMember(db.GroupID) + g, err := db.groupCheck.GetGroupInfo(ctx, db.GroupID) if err != nil { return nil, err } - dst.MemberCount = uint32(memberCount) + dst.MemberCount = g.MemberCount dst.CreateTime = db.CreateTime.Unix() dst.NotificationUpdateTime = db.NotificationUpdateTime.Unix() if db.NotificationUpdateTime.Unix() < 0 { @@ -268,6 +265,7 @@ func (db *DBGroup) Convert() (*sdk.GroupInfo, error) { type DBGroupMember struct { *relation.GroupMemberModel + userCheck *check.UserCheck } func (*PBGroupMember) PB2DB(groupMembers []*sdk.GroupMemberFullInfo) (DBGroupMembers []*relation.GroupMemberModel, err error) { @@ -281,9 +279,9 @@ func (*PBGroupMember) PB2DB(groupMembers []*sdk.GroupMemberFullInfo) (DBGroupMem return } -func (*DBGroupMember) DB2PB(groupMembers []*relation.GroupMemberModel) (PBGroupMembers []*sdk.GroupMemberFullInfo, err error) { +func (*DBGroupMember) DB2PB(ctx context.Context, groupMembers []*relation.GroupMemberModel) (PBGroupMembers []*sdk.GroupMemberFullInfo, err error) { for _, v := range groupMembers { - u, err := NewDBGroupMember(v).Convert() + u, err := NewDBGroupMember(v).Convert(ctx) if err != nil { return nil, err } @@ -311,15 +309,15 @@ func (pb *PBGroupMember) Convert() (*relation.GroupMemberModel, error) { dst.MuteEndTime = utils.UnixSecondToTime(int64(pb.MuteEndTime)) return dst, nil } -func (db *DBGroupMember) Convert() (*sdk.GroupMemberFullInfo, error) { +func (db *DBGroupMember) Convert(ctx context.Context) (*sdk.GroupMemberFullInfo, error) { dst := &sdk.GroupMemberFullInfo{} utils.CopyStructFields(dst, db) - user, err := getUsersInfo([]string{db.UserID}) + user, err := db.userCheck.GetUsersInfo(ctx, db.UserID) if err != nil { return nil, err } - dst.AppMangerLevel = user[0].AppMangerLevel + dst.AppMangerLevel = user.AppMangerLevel dst.JoinTime = db.JoinTime.Unix() if db.JoinTime.Unix() < 0 { diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index db2f357b0..2b84ff23e 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -217,7 +217,7 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbFriend.G if err != nil { return nil, err } - resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(friends) + resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(ctx, s.RegisterCenter, friends) if err != nil { return nil, err } @@ -235,7 +235,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbF if err != nil { return nil, err } - resp.FriendRequests, err = (*convert.DBFriendRequest)(nil).DB2PB(friendRequests) + resp.FriendRequests, err = (*convert.DBFriendRequest)(nil).DB2PB(ctx, s.RegisterCenter, friendRequests) if err != nil { return nil, err } @@ -253,7 +253,7 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *p if err != nil { return nil, err } - resp.FriendRequests, err = (*convert.DBFriendRequest)(nil).DB2PB(friendRequests) + resp.FriendRequests, err = (*convert.DBFriendRequest)(nil).DB2PB(ctx, s.RegisterCenter, friendRequests) if err != nil { return nil, err } @@ -281,7 +281,7 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbFriend.G if err != nil { return nil, err } - if resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(friends); err != nil { + if resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(ctx, s.RegisterCenter, friends); err != nil { return nil, err } return resp, nil From 446ac638980e04b3a0d3df0be905fde346df2934 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 14 Feb 2023 15:20:02 +0800 Subject: [PATCH 37/48] callback --- pkg/common/http/http_client.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index 2ef3c4be4..7c8395d61 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -80,21 +80,5 @@ func CallBackPostReturn(url, callbackCommand string, input interface{}, output c } func CallBackPostReturnV2(url string, req cbapi.CallbackReq, resp cbapi.CallbackResp, callbackConfig config.CallBackConfig) error { - v := urlLib.Values{} - v.Set("callbackCommand", req.GetCallbackCommand()) - url = url + "?" + v.Encode() - b, err := Post(url, req, callbackConfig.CallbackTimeOut) - if err != nil { - if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue { - return constant.ErrCallbackContinue - } - return constant.NewErrNetwork(err) - } - if err = json.Unmarshal(b, resp); err != nil { - if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue { - return constant.ErrCallbackContinue - } - return constant.NewErrData(err) - } - return resp.Parse() + return CallBackPostReturn(url, req.GetCallbackCommand(), req, resp, callbackConfig) } From 12eba46dab98d708904b354428eede04267f9ac4 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 16:07:35 +0800 Subject: [PATCH 38/48] Error code standardization --- internal/common/convert/convert.go | 51 ++++++++++++++++++++++-------- internal/rpc/friend/black.go | 2 +- internal/rpc/friend/friend.go | 4 +-- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/internal/common/convert/convert.go b/internal/common/convert/convert.go index 8349d5ea7..40a754255 100644 --- a/internal/common/convert/convert.go +++ b/internal/common/convert/convert.go @@ -99,13 +99,26 @@ func (*PBFriendRequest) PB2DB(friendRequests []*sdk.FriendRequest) (DBFriendRequ return } -func (*DBFriendRequest) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, friendRequests []*relation.FriendRequestModel) (PBFriendRequests []*sdk.FriendRequest, err error) { +func (db *DBFriendRequest) DB2PB(ctx context.Context, friendRequests []*relation.FriendRequestModel) (PBFriendRequests []*sdk.FriendRequest, err error) { + userIDs := make([]string, 0) + if len(friendRequests) > 0 { + userIDs = append(userIDs, friendRequests[0].FromUserID) + } + users, err := db.userCheck.GetUsersInfoMap(ctx, userIDs, true) + if err != nil { + return nil, err + } for _, v := range friendRequests { - u, err := NewDBFriendRequest(v, zk).Convert(ctx) - if err != nil { - return nil, err - } - PBFriendRequests = append(PBFriendRequests, u) + pbFriendRequest := &sdk.FriendRequest{} + pbFriendRequest.FromNickname = users[v.FromUserID].Nickname + pbFriendRequest.FromFaceURL = users[v.FromUserID].FaceURL + pbFriendRequest.FromGender = users[v.FromUserID].Gender + pbFriendRequest.ToNickname = users[v.ToUserID].Nickname + pbFriendRequest.ToFaceURL = users[v.ToUserID].FaceURL + pbFriendRequest.ToGender = users[v.ToUserID].Gender + pbFriendRequest.CreateTime = db.CreateTime.Unix() + pbFriendRequest.HandleTime = db.HandleTime.Unix() + PBFriendRequests = append(PBFriendRequests, pbFriendRequest) } return } @@ -155,13 +168,25 @@ func (*PBBlack) PB2DB(blacks []*sdk.BlackInfo) (DBBlacks []*relation.BlackModel, return } -func (*DBBlack) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, blacks []*relation.BlackModel) (PBBlacks []*sdk.BlackInfo, err error) { +func (db *DBBlack) DB2PB(ctx context.Context, blacks []*relation.BlackModel) (PBBlacks []*sdk.BlackInfo, err error) { + userIDs := make([]string, 0) for _, v := range blacks { - u, err := NewDBBlack(v, zk).Convert(ctx) - if err != nil { - return nil, err - } - PBBlacks = append(PBBlacks, u) + userIDs = append(userIDs, v.BlockUserID) + } + if len(blacks) > 0 { + userIDs = append(userIDs, blacks[0].OwnerUserID) + } + + users, err := db.userCheck.GetUsersInfoMap(ctx, userIDs, true) + if err != nil { + return nil, err + } + + for _, v := range blacks { + pbBlack := &sdk.BlackInfo{} + utils.CopyStructFields(pbBlack, users[v.OwnerUserID]) + utils.CopyStructFields(pbBlack.BlackUserInfo, users[v.BlockUserID]) + PBBlacks = append(PBBlacks, pbBlack) } return } @@ -181,7 +206,7 @@ func NewPBBlack(blackInfo *sdk.BlackInfo) *PBBlack { func (pb *PBBlack) Convert() (*relation.BlackModel, error) { dbBlack := &relation.BlackModel{} dbBlack.BlockUserID = pb.BlackUserInfo.UserID - dbBlack.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime)) + dbBlack.CreateTime = utils.UnixSecondToTime(pb.CreateTime) return dbBlack, nil } func (db *DBBlack) Convert(ctx context.Context) (*sdk.BlackInfo, error) { diff --git a/internal/rpc/friend/black.go b/internal/rpc/friend/black.go index 9969fd478..8b01b7fbd 100644 --- a/internal/rpc/friend/black.go +++ b/internal/rpc/friend/black.go @@ -18,7 +18,7 @@ func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbFriend.Ge if err != nil { return nil, err } - resp.Blacks, err = (*convert.DBBlack)(nil).DB2PB(blacks) + resp.Blacks, err = (*convert.NewDBBlack(nil, s.RegisterCenter)).DB2PB(ctx, blacks) if err != nil { return nil, err } diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 2b84ff23e..6f0523fc6 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -235,7 +235,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbF if err != nil { return nil, err } - resp.FriendRequests, err = (*convert.DBFriendRequest)(nil).DB2PB(ctx, s.RegisterCenter, friendRequests) + resp.FriendRequests, err = (*convert.NewDBFriendRequest(nil, s.RegisterCenter)).DB2PB(ctx, friendRequests) if err != nil { return nil, err } @@ -253,7 +253,7 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *p if err != nil { return nil, err } - resp.FriendRequests, err = (*convert.DBFriendRequest)(nil).DB2PB(ctx, s.RegisterCenter, friendRequests) + resp.FriendRequests, err = (*convert.NewDBFriendRequest(nil, s.RegisterCenter)).DB2PB(ctx, friendRequests) if err != nil { return nil, err } From f40ae89c8c3575ccd32d511a132318dec48f6f1c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 16:21:25 +0800 Subject: [PATCH 39/48] Error code standardization --- internal/common/convert/convert.go | 78 ++++++++++++++++-------------- internal/rpc/friend/friend.go | 4 +- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/internal/common/convert/convert.go b/internal/common/convert/convert.go index 40a754255..5b344770e 100644 --- a/internal/common/convert/convert.go +++ b/internal/common/convert/convert.go @@ -5,6 +5,7 @@ import ( "Open_IM/pkg/common/db/table/relation" discoveryRegistry "Open_IM/pkg/discoveryregistry" sdk "Open_IM/pkg/proto/sdkws" + utils2 "Open_IM/pkg/utils" "context" utils "github.com/OpenIMSDK/open_utils" "time" @@ -38,13 +39,18 @@ func (*PBFriend) PB2DB(friends []*sdk.FriendInfo) (DBFriends []*relation.FriendM return } -func (*DBFriend) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, friends []*relation.FriendModel) (PBFriends []*sdk.FriendInfo, err error) { +func (db *DBFriend) DB2PB(ctx context.Context, friends []*relation.FriendModel) (PBFriends []*sdk.FriendInfo, err error) { + userIDs := utils2.Slice(friends, func(e *relation.FriendModel) string { return e.FriendUserID }) + users, err := db.userCheck.GetUsersInfoMap(ctx, userIDs, true) + if err != nil { + return nil, err + } for _, v := range friends { - u, err := NewDBFriend(v, zk).Convert(ctx) - if err != nil { - return nil, err - } - PBFriends = append(PBFriends, u) + pbFriend := &sdk.FriendInfo{FriendUser: &sdk.UserInfo{}} + utils.CopyStructFields(pbFriend, users[v.OwnerUserID]) + utils.CopyStructFields(pbFriend.FriendUser, users[v.FriendUserID]) + pbFriend.CreateTime = v.CreateTime.Unix() + pbFriend.FriendUser.CreateTime = v.CreateTime.Unix() } return } @@ -238,16 +244,16 @@ func (*PBGroup) PB2DB(groups []*sdk.GroupInfo) (DBGroups []*relation.GroupModel, return } -func (db *DBGroup) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, groups []*relation.GroupModel) (PBGroups []*sdk.GroupInfo, err error) { - for _, v := range groups { - u, err := NewDBGroup(v, zk).Convert(ctx) - if err != nil { - return nil, err - } - PBGroups = append(PBGroups, u) - } - return -} +//func (db *DBGroup) DB2PB(ctx context.Context, zk discoveryRegistry.SvcDiscoveryRegistry, groups []*relation.GroupModel) (PBGroups []*sdk.GroupInfo, err error) { +// for _, v := range groups { +// u, err := NewDBGroup(v, zk).Convert(ctx) +// if err != nil { +// return nil, err +// } +// PBGroups = append(PBGroups, u) +// } +// return +//} func NewDBGroup(groupModel *relation.GroupModel, zk discoveryRegistry.SvcDiscoveryRegistry) *DBGroup { return &DBGroup{GroupModel: groupModel, groupCheck: check.NewGroupChecker(zk)} @@ -304,16 +310,16 @@ func (*PBGroupMember) PB2DB(groupMembers []*sdk.GroupMemberFullInfo) (DBGroupMem return } -func (*DBGroupMember) DB2PB(ctx context.Context, groupMembers []*relation.GroupMemberModel) (PBGroupMembers []*sdk.GroupMemberFullInfo, err error) { - for _, v := range groupMembers { - u, err := NewDBGroupMember(v).Convert(ctx) - if err != nil { - return nil, err - } - PBGroupMembers = append(PBGroupMembers, u) - } - return -} +//func (*DBGroupMember) DB2PB(ctx context.Context, groupMembers []*relation.GroupMemberModel) (PBGroupMembers []*sdk.GroupMemberFullInfo, err error) { +// for _, v := range groupMembers { +// u, err := NewDBGroupMember(v).Convert(ctx) +// if err != nil { +// return nil, err +// } +// PBGroupMembers = append(PBGroupMembers, u) +// } +// return +//} func NewDBGroupMember(groupMember *relation.GroupMemberModel) *DBGroupMember { return &DBGroupMember{GroupMemberModel: groupMember} @@ -370,16 +376,16 @@ func (*PBGroupRequest) PB2DB(groupRequests []*sdk.GroupRequest) (DBGroupRequests return } -func (*DBGroupRequest) DB2PB(groupRequests []*relation.GroupRequestModel) (PBGroupRequests []*sdk.GroupRequest, err error) { - for _, v := range groupRequests { - u, err := NewDBGroupRequest(v).Convert() - if err != nil { - return nil, err - } - PBGroupRequests = append(PBGroupRequests, u) - } - return -} +//func (*DBGroupRequest) DB2PB(groupRequests []*relation.GroupRequestModel) (PBGroupRequests []*sdk.GroupRequest, err error) { +// for _, v := range groupRequests { +// u, err := NewDBGroupRequest(v).Convert() +// if err != nil { +// return nil, err +// } +// PBGroupRequests = append(PBGroupRequests, u) +// } +// return +//} func NewDBGroupRequest(groupRequest *relation.GroupRequestModel) *DBGroupRequest { return &DBGroupRequest{GroupRequestModel: groupRequest} diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 6f0523fc6..7a350283a 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -217,7 +217,7 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbFriend.G if err != nil { return nil, err } - resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(ctx, s.RegisterCenter, friends) + resp.FriendsInfo, err = (*convert.NewDBFriend(nil, s.RegisterCenter)).DB2PB(ctx, friends) if err != nil { return nil, err } @@ -281,7 +281,7 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbFriend.G if err != nil { return nil, err } - if resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(ctx, s.RegisterCenter, friends); err != nil { + if resp.FriendsInfo, err = (*convert.NewDBFriend(nil, s.RegisterCenter)).DB2PB(ctx, friends); err != nil { return nil, err } return resp, nil From bba819854c5d1e5c4df6687a6c8aa7bd57932f67 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 14 Feb 2023 16:33:18 +0800 Subject: [PATCH 40/48] group --- internal/common/check/conversation.go | 8 +- internal/rpc/group/db_map.go | 2 +- internal/rpc/group/group.go | 124 ++++++++++++++------- internal/rpc/msg/send_pull.go | 4 +- internal/startrpc/start.go | 6 +- pkg/common/db/cache/redis.go | 85 ++++++++++----- pkg/common/db/relation/mysql_init.go | 148 ++++++++++++++++++++++++++ pkg/common/db/unrelation/mongo.go | 43 +++++++- 8 files changed, 341 insertions(+), 79 deletions(-) create mode 100644 pkg/common/db/relation/mysql_init.go diff --git a/internal/common/check/conversation.go b/internal/common/check/conversation.go index 9ebb1b299..5d6e25537 100644 --- a/internal/common/check/conversation.go +++ b/internal/common/check/conversation.go @@ -17,13 +17,13 @@ func NewConversationChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *Conversa return &ConversationChecker{zk: zk} } -func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (resp *pbConversation.ModifyConversationFieldResp, err error) { +func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) error { cc, err := c.getConn() if err != nil { - return nil, err + return err } - resp, err = conversation.NewConversationClient(cc).ModifyConversationField(ctx, req) - return + _, err = conversation.NewConversationClient(cc).ModifyConversationField(ctx, req) + return err } func (c *ConversationChecker) getConn() (*grpc.ClientConn, error) { diff --git a/internal/rpc/group/db_map.go b/internal/rpc/group/db_map.go index ad9ea4e75..29bfd0de4 100644 --- a/internal/rpc/group/db_map.go +++ b/internal/rpc/group/db_map.go @@ -12,7 +12,7 @@ func UpdateGroupInfoMap(group *sdkws.GroupInfoForSet) map[string]any { m["group_name"] = group.GroupName } if group.Notification != "" { - m["notification"] = group.Notification + m["Notification"] = group.Notification } if group.Introduction != "" { m["introduction"] = group.Introduction diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 824748eaf..b116f833f 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -11,12 +11,13 @@ import ( "Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" - discoveryRegistry "Open_IM/pkg/discoveryregistry" + pbConversation "Open_IM/pkg/proto/conversation" pbGroup "Open_IM/pkg/proto/group" "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" "context" "fmt" + "github.com/OpenIMSDK/openKeeper" "google.golang.org/grpc" "gorm.io/gorm" "math/big" @@ -26,20 +27,35 @@ import ( "time" ) -func Start(server *grpc.Server) error { +func Start(client *openKeeper.ZkClient, server *grpc.Server) error { + mysql, err := relation.NewGormDB() + if err != nil { + return err + } + if err := mysql.AutoMigrate(&relationTb.GroupModel{}, &relationTb.GroupMemberModel{}, &relationTb.GroupRequestModel{}); err != nil { + return err + } + redis, err := cache.NewRedis() + if err != nil { + return err + } + mongo, err := unrelation.NewMongo() + if err != nil { + return err + } pbGroup.RegisterGroupServer(server, &groupServer{ - GroupInterface: controller.NewGroupInterface(nil, cache.NewRedis().GetClient(), unrelation.NewMongo().GetClient()), - registerCenter: nil, - user: check.NewUserCheck(nil), + GroupInterface: controller.NewGroupInterface(mysql, redis.GetClient(), mongo.GetClient()), + UserCheck: check.NewUserCheck(client), + ConversationChecker: check.NewConversationChecker(client), }) return nil } type groupServer struct { - GroupInterface controller.GroupInterface - registerCenter discoveryRegistry.SvcDiscoveryRegistry - user *check.UserCheck - notification *notification.Check + GroupInterface controller.GroupInterface + UserCheck *check.UserCheck + Notification *notification.Check + ConversationChecker *check.ConversationChecker } func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error { @@ -59,7 +75,7 @@ func (s *groupServer) GetUsernameMap(ctx context.Context, userIDs []string, comp if len(userIDs) == 0 { return map[string]string{}, nil } - users, err := s.user.GetPublicUserInfos(ctx, userIDs, complete) + users, err := s.UserCheck.GetPublicUserInfos(ctx, userIDs, complete) if err != nil { return nil, err } @@ -68,7 +84,19 @@ func (s *groupServer) GetUsernameMap(ctx context.Context, userIDs []string, comp }), nil } -func (s *groupServer) GroupNotification(ctx context.Context, groupID string) { +func (s *groupServer) GroupNotification(ctx context.Context, groupID string, userIDs []string) { + + s.ConversationChecker.ModifyConversationField(ctx, &pbConversation.ModifyConversationFieldReq{ + Conversation: &pbConversation.Conversation{ + OwnerUserID: tracelog.GetOpUserID(ctx), + ConversationID: utils.GetConversationIDBySessionType(groupID, constant.GroupChatType), + ConversationType: constant.GroupChatType, + GroupID: groupID, + }, + FieldType: constant.FieldGroupAtType, + UserIDList: userIDs, + }) + // todo 群公告修改通知 //var conversationReq pbConversation.ModifyConversationFieldReq //conversation := pbConversation.Conversation{ @@ -130,7 +158,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if utils.Duplicate(userIDs) { return nil, constant.ErrArgs.Wrap("group member repeated") } - userMap, err := s.user.GetUsersInfoMap(ctx, userIDs, true) + userMap, err := s.UserCheck.GetUsersInfoMap(ctx, userIDs, true) if err != nil { return nil, err } @@ -183,11 +211,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if req.GroupInfo.GroupType == constant.SuperGroup { go func() { for _, userID := range userIDs { - s.notification.SuperGroupNotification(ctx, userID, userID) + s.Notification.SuperGroupNotification(ctx, userID, userID) } }() } else { - s.notification.GroupCreatedNotification(ctx, group.GroupID, userIDs) + s.Notification.GroupCreatedNotification(ctx, group.GroupID, userIDs) } return resp, nil } @@ -256,7 +284,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if ids := utils.Single(req.InvitedUserIDs, utils.Keys(memberMap)); len(ids) > 0 { return nil, constant.ErrArgs.Wrap("user in group " + strings.Join(ids, ",")) } - userMap, err := s.user.GetUsersInfoMap(ctx, req.InvitedUserIDs, true) + userMap, err := s.UserCheck.GetUsersInfoMap(ctx, req.InvitedUserIDs, true) if err != nil { return nil, err } @@ -281,7 +309,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, request := range requests { - s.notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ + s.Notification.JoinGroupApplicationNotification(ctx, &pbGroup.JoinGroupReq{ GroupID: request.GroupID, ReqMessage: request.ReqMsg, JoinSource: request.JoinSource, @@ -297,7 +325,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, err } for _, userID := range req.InvitedUserIDs { - s.notification.SuperGroupNotification(ctx, userID, userID) + s.Notification.SuperGroupNotification(ctx, userID, userID) } } else { opUserID := tracelog.GetOpUserID(ctx) @@ -318,7 +346,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil { return nil, err } - s.notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs) + s.Notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs) } return resp, nil } @@ -395,7 +423,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou } go func() { for _, userID := range req.KickedUserIDs { - s.notification.SuperGroupNotification(ctx, userID, userID) + s.Notification.SuperGroupNotification(ctx, userID, userID) } }() } else { @@ -435,7 +463,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou if err := s.GroupInterface.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil { return nil, err } - s.notification.MemberKickedNotification(ctx, req, req.KickedUserIDs) + s.Notification.MemberKickedNotification(ctx, req, req.KickedUserIDs) } return resp, nil } @@ -487,7 +515,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup. } userIDs = utils.Distinct(userIDs) groupIDs = utils.Distinct(groupIDs) - userMap, err := s.user.GetPublicUserInfoMap(ctx, userIDs, true) + userMap, err := s.UserCheck.GetPublicUserInfoMap(ctx, userIDs, true) if err != nil { return nil, err } @@ -575,7 +603,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup } else if !s.IsNotFound(err) { return nil, err } - user, err := s.user.GetPublicUserInfo(ctx, req.FromUserID) + user, err := s.UserCheck.GetPublicUserInfo(ctx, req.FromUserID) if err != nil { return nil, err } @@ -602,10 +630,10 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup } if !join { if req.HandleResult == constant.GroupResponseAgree { - s.notification.GroupApplicationAcceptedNotification(ctx, req) - s.notification.MemberEnterNotification(ctx, req) + s.Notification.GroupApplicationAcceptedNotification(ctx, req) + s.Notification.MemberEnterNotification(ctx, req) } else if req.HandleResult == constant.GroupResponseRefuse { - s.notification.GroupApplicationRejectedNotification(ctx, req) + s.Notification.GroupApplicationRejectedNotification(ctx, req) } } return resp, nil @@ -613,7 +641,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (*pbGroup.JoinGroupResp, error) { resp := &pbGroup.JoinGroupResp{} - if _, err := s.user.GetPublicUserInfo(ctx, tracelog.GetOpUserID(ctx)); err != nil { + if _, err := s.UserCheck.GetPublicUserInfo(ctx, tracelog.GetOpUserID(ctx)); err != nil { return nil, err } group, err := s.GroupInterface.TakeGroup(ctx, req.GroupID) @@ -643,7 +671,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil { return nil, err } - s.notification.MemberEnterDirectlyNotification(ctx, req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) + s.Notification.MemberEnterDirectlyNotification(ctx, req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) return resp, nil } groupRequest := relationTb.GroupRequestModel{ @@ -656,7 +684,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := s.GroupInterface.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil { return nil, err } - s.notification.JoinGroupApplicationNotification(ctx, req) + s.Notification.JoinGroupApplicationNotification(ctx, req) return resp, nil } @@ -670,13 +698,13 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil { return nil, err } - s.notification.SuperGroupNotification(ctx, tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) + s.Notification.SuperGroupNotification(ctx, tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx)) } else { _, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx)) if err != nil { return nil, err } - s.notification.MemberQuitNotification(ctx, req) + s.Notification.MemberQuitNotification(ctx, req) } return resp, nil } @@ -699,6 +727,10 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf if group.Status == constant.GroupStatusDismissed { return nil, utils.Wrap(constant.ErrDismissedAlready, "") } + userIDs, err := s.GroupInterface.FindGroupMemberUserID(ctx, group.GroupID) + if err != nil { + return nil, err + } data := UpdateGroupInfoMap(req.GroupInfoForSet) if len(data) > 0 { return resp, nil @@ -710,9 +742,21 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf if err != nil { return nil, err } - s.notification.GroupInfoSetNotification(ctx, req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) + s.Notification.GroupInfoSetNotification(ctx, req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification) if req.GroupInfoForSet.Notification != "" { - s.GroupNotification(ctx, group.GroupID) + args := pbConversation.ModifyConversationFieldReq{ + Conversation: &pbConversation.Conversation{ + OwnerUserID: tracelog.GetOpUserID(ctx), + ConversationID: utils.GetConversationIDBySessionType(group.GroupID, constant.GroupChatType), + ConversationType: constant.GroupChatType, + GroupID: group.GroupID, + }, + FieldType: constant.FieldGroupAtType, + UserIDList: userIDs, + } + if err := s.ConversationChecker.ModifyConversationField(ctx, &args); err != nil { + tracelog.SetCtxWarn(ctx, "ModifyConversationField", err, args) + } } return resp, nil } @@ -760,7 +804,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans if err := s.GroupInterface.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID, newOwner.RoleLevel); err != nil { return nil, err } - s.notification.GroupOwnerTransferredNotification(ctx, req) + s.Notification.GroupOwnerTransferredNotification(ctx, req) return resp, nil } @@ -827,7 +871,7 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) { resp := &pbGroup.GetUserReqApplicationListResp{} - user, err := s.user.GetPublicUserInfo(ctx, req.UserID) + user, err := s.UserCheck.GetPublicUserInfo(ctx, req.UserID) if err != nil { return nil, err } @@ -892,7 +936,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou return nil, err } } else { - s.notification.GroupDismissedNotification(ctx, req) + s.Notification.GroupDismissedNotification(ctx, req) } return resp, nil } @@ -916,7 +960,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - s.notification.GroupMemberMutedNotification(ctx, req.GroupID, req.UserID, req.MutedSeconds) + s.Notification.GroupMemberMutedNotification(ctx, req.GroupID, req.UserID, req.MutedSeconds) return resp, nil } @@ -939,7 +983,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil { return nil, err } - s.notification.GroupMemberCancelMutedNotification(ctx, req.GroupID, req.UserID) + s.Notification.GroupMemberCancelMutedNotification(ctx, req.GroupID, req.UserID) return resp, nil } @@ -951,7 +995,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil { return nil, err } - s.notification.GroupMutedNotification(ctx, req.GroupID) + s.Notification.GroupMutedNotification(ctx, req.GroupID) return resp, nil } @@ -963,7 +1007,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil { return nil, err } - s.notification.GroupCancelMutedNotification(ctx, req.GroupID) + s.Notification.GroupCancelMutedNotification(ctx, req.GroupID) return resp, nil } @@ -1040,7 +1084,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr return nil, err } for _, member := range req.Members { - s.notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID) + s.Notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID) } return resp, nil } diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index ebfde0851..4493f9768 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -203,7 +203,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( conversation.GroupAtType = constant.AtMe } - _, err := m.Conversation.ModifyConversationField(ctx, &conversationReq) + err := m.Conversation.ModifyConversationField(ctx, &conversationReq) if err != nil { return } @@ -211,7 +211,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( if tag { conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList) conversation.GroupAtType = constant.AtAll - _, err := m.Conversation.ModifyConversationField(ctx, &conversationReq) + err := m.Conversation.ModifyConversationField(ctx, &conversationReq) if err != nil { return } diff --git a/internal/startrpc/start.go b/internal/startrpc/start.go index ba4b6a5b6..0bdc2a51e 100644 --- a/internal/startrpc/start.go +++ b/internal/startrpc/start.go @@ -15,7 +15,7 @@ import ( "net" ) -func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(server *grpc.Server) error, options []grpc.ServerOption) error { +func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options []grpc.ServerOption) error { flagRpcPort := flag.Int("port", rpcPort, "get RpcGroupPort from cmd,default 16000 as port") flagPrometheusPort := flag.Int("prometheus_port", prometheusPort, "groupPrometheusPort default listen port") flag.Parse() @@ -60,10 +60,10 @@ func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(s return err } } - return rpcFn(srv) + return rpcFn(zkClient, srv) } -func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(server *grpc.Server) error, options ...grpc.ServerOption) { +func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options ...grpc.ServerOption) { err := start(rpcPort, rpcRegisterName, prometheusPort, rpcFn, options) fmt.Println("end", err) } diff --git a/pkg/common/db/cache/redis.go b/pkg/common/db/cache/redis.go index fbafdd83e..34c5ee94b 100644 --- a/pkg/common/db/cache/redis.go +++ b/pkg/common/db/cache/redis.go @@ -50,20 +50,14 @@ type Cache interface { // native redis operate -func NewRedis() *RedisClient { - o := &RedisClient{} - o.InitRedis() - return o -} - -type RedisClient struct { - rdb redis.UniversalClient -} +//func NewRedis() *RedisClient { +// o := &RedisClient{} +// o.InitRedis() +// return o +//} -func (r *RedisClient) InitRedis() { +func NewRedis() (*RedisClient, error) { var rdb redis.UniversalClient - var err error - ctx := context.Background() if config.Config.Redis.EnableCluster { rdb = redis.NewClusterClient(&redis.ClusterOptions{ Addrs: config.Config.Redis.DBAddress, @@ -71,11 +65,10 @@ func (r *RedisClient) InitRedis() { Password: config.Config.Redis.DBPassWord, // no password set PoolSize: 50, }) - _, err = rdb.Ping(ctx).Result() - if err != nil { - fmt.Println("redis cluster failed address ", config.Config.Redis.DBAddress) - panic(err.Error() + " redis cluster " + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord) - } + //if err := rdb.Ping(ctx).Err();err != nil { + // return nil, fmt.Errorf("redis ping %w", err) + //} + //return &RedisClient{rdb: rdb}, nil } else { rdb = redis.NewClient(&redis.Options{ Addr: config.Config.Redis.DBAddress[0], @@ -84,21 +77,63 @@ func (r *RedisClient) InitRedis() { DB: 0, // use default DB PoolSize: 100, // 连接池大小 }) - _, err = rdb.Ping(ctx).Result() - if err != nil { - panic(err.Error() + " redis " + config.Config.Redis.DBAddress[0] + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord) - } + //err := rdb.Ping(ctx).Err() + //if err != nil { + // panic(err.Error() + " redis " + config.Config.Redis.DBAddress[0] + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord) + //} + } + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() + err := rdb.Ping(ctx).Err() + if err != nil { + return nil, fmt.Errorf("redis ping %w", err) } - r.rdb = rdb + return &RedisClient{rdb: rdb}, nil } +type RedisClient struct { + rdb redis.UniversalClient +} + +//func (r *RedisClient) InitRedis() { +// var rdb redis.UniversalClient +// var err error +// ctx := context.Background() +// if config.Config.Redis.EnableCluster { +// rdb = redis.NewClusterClient(&redis.ClusterOptions{ +// Addrs: config.Config.Redis.DBAddress, +// Username: config.Config.Redis.DBUserName, +// Password: config.Config.Redis.DBPassWord, // no password set +// PoolSize: 50, +// }) +// _, err = rdb.Ping(ctx).Result() +// if err != nil { +// fmt.Println("redis cluster failed address ", config.Config.Redis.DBAddress) +// panic(err.Error() + " redis cluster " + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord) +// } +// } else { +// rdb = redis.NewClient(&redis.Options{ +// Addr: config.Config.Redis.DBAddress[0], +// Username: config.Config.Redis.DBUserName, +// Password: config.Config.Redis.DBPassWord, // no password set +// DB: 0, // use default DB +// PoolSize: 100, // 连接池大小 +// }) +// _, err = rdb.Ping(ctx).Result() +// if err != nil { +// panic(err.Error() + " redis " + config.Config.Redis.DBAddress[0] + config.Config.Redis.DBUserName + config.Config.Redis.DBPassWord) +// } +// } +// r.rdb = rdb +//} + func (r *RedisClient) GetClient() redis.UniversalClient { return r.rdb } -func NewRedisClient(rdb redis.UniversalClient) *RedisClient { - return &RedisClient{rdb: rdb} -} +//func NewRedisClient(rdb redis.UniversalClient) *RedisClient { +// return &RedisClient{rdb: rdb} +//} // Perform seq auto-increment operation of user messages func (r *RedisClient) IncrUserSeq(uid string) (uint64, error) { diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go new file mode 100644 index 000000000..d4461c294 --- /dev/null +++ b/pkg/common/db/relation/mysql_init.go @@ -0,0 +1,148 @@ +package relation + +import ( + "Open_IM/pkg/common/config" + "fmt" + "time" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" +) + +func NewGormDB() (*gorm.DB, error) { + dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", + config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], "mysql") + db, err := gorm.Open(mysql.Open(dsn), nil) + if err != nil { + time.Sleep(time.Duration(30) * time.Second) + db, err = gorm.Open(mysql.Open(dsn), nil) + if err != nil { + panic(err.Error() + " open failed " + dsn) + } + } + sqlDB, err := db.DB() + if err != nil { + return nil, err + } + defer sqlDB.Close() + sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s default charset utf8 COLLATE utf8_general_ci;", config.Config.Mysql.DBDatabaseName) + err = db.Exec(sql).Error + if err != nil { + return nil, fmt.Errorf("init db %w", err) + } + dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", + config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName) + newLogger := logger.New( + Writer{}, + logger.Config{ + SlowThreshold: time.Duration(config.Config.Mysql.SlowThreshold) * time.Millisecond, // Slow SQL threshold + LogLevel: logger.LogLevel(config.Config.Mysql.LogLevel), // Log level + IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger + Colorful: true, // Disable color + }, + ) + db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{ + Logger: newLogger, + }) + if err != nil { + return nil, err + } + sqlDB, err = db.DB() + if err != nil { + return nil, err + } + sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.DBMaxLifeTime)) + sqlDB.SetMaxOpenConns(config.Config.Mysql.DBMaxOpenConns) + sqlDB.SetMaxIdleConns(config.Config.Mysql.DBMaxIdleConns) + return db, nil +} + +type Mysql struct { + gormConn *gorm.DB +} + +func (m *Mysql) GormConn() *gorm.DB { + return m.gormConn +} + +//func (m *Mysql) SetGormConn(gormConn *gorm.DB) { +// m.gormConn = gormConn +//} +// +//func (m *Mysql) InitConn() *Mysql { +// dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", +// config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], "mysql") +// var db *gorm.DB +// db, err := gorm.Open(mysql.Open(dsn), nil) +// if err != nil { +// time.Sleep(time.Duration(30) * time.Second) +// db, err = gorm.Open(mysql.Open(dsn), nil) +// if err != nil { +// panic(err.Error() + " open failed " + dsn) +// } +// } +// sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s default charset utf8 COLLATE utf8_general_ci;", config.Config.Mysql.DBDatabaseName) +// err = db.Exec(sql).Error +// if err != nil { +// panic(err.Error() + " Exec failed:" + sql) +// } +// dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", +// config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName) +// newLogger := logger.New( +// Writer{}, +// logger.Config{ +// SlowThreshold: time.Duration(config.Config.Mysql.SlowThreshold) * time.Millisecond, // Slow SQL threshold +// LogLevel: logger.LogLevel(config.Config.Mysql.LogLevel), // Log level +// IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger +// Colorful: true, // Disable color +// }, +// ) +// db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{ +// Logger: newLogger, +// }) +// if err != nil { +// panic(err.Error() + " Open failed " + dsn) +// } +// sqlDB, err := db.DB() +// if err != nil { +// panic(err.Error() + " DB.DB() failed ") +// } +// sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.DBMaxLifeTime)) +// sqlDB.SetMaxOpenConns(config.Config.Mysql.DBMaxOpenConns) +// sqlDB.SetMaxIdleConns(config.Config.Mysql.DBMaxIdleConns) +// if db == nil { +// panic("db is nil") +// } +// m.SetGormConn(db) +// return m +//} + +//models := []interface{}{&Friend{}, &FriendRequest{}, &Group{}, &GroupMember{}, &GroupRequest{}, +// &User{}, &Black{}, &ChatLog{}, &Conversation{}, &AppVersion{}} + +//func (m *Mysql) AutoMigrateModel(model interface{}) error { +// err := m.gormConn.AutoMigrate(model) +// if err != nil { +// return err +// } +// m.gormConn.Set("gorm:table_options", "CHARSET=utf8") +// m.gormConn.Set("gorm:table_options", "collation=utf8_unicode_ci") +// _ = m.gormConn.Migrator().CreateTable(model) +// return nil +//} + +type Writer struct{} + +func (w Writer) Printf(format string, args ...interface{}) { + fmt.Printf(format, args...) +} + +func getDBConn(db *gorm.DB, tx []any) *gorm.DB { + if len(tx) > 0 { + if txDB, ok := tx[0].(*gorm.DB); ok { + return txDB + } + } + return db +} diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go index 7500214ae..9a4c9159a 100644 --- a/pkg/common/db/unrelation/mongo.go +++ b/pkg/common/db/unrelation/mongo.go @@ -13,10 +13,45 @@ import ( "time" ) -func NewMongo() *Mongo { - mgo := &Mongo{} - mgo.InitMongo() - return mgo +//func NewMongo() *Mongo { +// mgo := &Mongo{} +// mgo.InitMongo() +// return mgo +//} + +func NewMongo() (*Mongo, error) { + uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority" + if config.Config.Mongo.DBUri != "" { + // example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize + uri = config.Config.Mongo.DBUri + } else { + //mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB + mongodbHosts := "" + for i, v := range config.Config.Mongo.DBAddress { + if i == len(config.Config.Mongo.DBAddress)-1 { + mongodbHosts += v + } else { + mongodbHosts += v + "," + } + } + if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" { + uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin", + config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, mongodbHosts, + config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize) + } else { + uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin", + mongodbHosts, config.Config.Mongo.DBDatabase, + config.Config.Mongo.DBMaxPoolSize) + } + } + fmt.Println("mongo:", uri) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) + defer cancel() + mongoClient, err := mongo.Connect(ctx, options.Client().ApplyURI(uri)) + if err != nil { + return nil, err + } + return &Mongo{db: mongoClient}, nil } type Mongo struct { From e83a070e81bf8beb37993b9710657e5447a1e0dd Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 14 Feb 2023 16:37:10 +0800 Subject: [PATCH 41/48] group --- internal/rpc/group/group.go | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index b116f833f..55e6d90fd 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -84,35 +84,6 @@ func (s *groupServer) GetUsernameMap(ctx context.Context, userIDs []string, comp }), nil } -func (s *groupServer) GroupNotification(ctx context.Context, groupID string, userIDs []string) { - - s.ConversationChecker.ModifyConversationField(ctx, &pbConversation.ModifyConversationFieldReq{ - Conversation: &pbConversation.Conversation{ - OwnerUserID: tracelog.GetOpUserID(ctx), - ConversationID: utils.GetConversationIDBySessionType(groupID, constant.GroupChatType), - ConversationType: constant.GroupChatType, - GroupID: groupID, - }, - FieldType: constant.FieldGroupAtType, - UserIDList: userIDs, - }) - - // todo 群公告修改通知 - //var conversationReq pbConversation.ModifyConversationFieldReq - //conversation := pbConversation.Conversation{ - // OwnerUserID: tracelog.GetOpUserID(ctx), - // ConversationID: utils.GetConversationIDBySessionType(groupID, constant.GroupChatType), - // ConversationType: constant.GroupChatType, - // GroupID: groupID, - //} - //conversationReq.Conversation = &conversation - //conversationReq.FieldType = constant.FieldGroupAtType - //conversation.GroupAtType = constant.GroupNotification - //conversationReq.UserIDList = userIDs - //_, err := pbConversation.NewConversationClient(s.etcdConn.GetConn("", config.Config.RpcRegisterName.OpenImConversationName)).ModifyConversationField(ctx, &conversationReq) - //tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply) -} - func (s *groupServer) IsNotFound(err error) bool { return utils.Unwrap(err) == gorm.ErrRecordNotFound } From c63b543a4a10dd1099aa898d087925fdf506ad04 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 17:20:39 +0800 Subject: [PATCH 42/48] Error code standardization --- pkg/common/db/relation/group_member_model.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/db/relation/group_member_model.go b/pkg/common/db/relation/group_member_model.go index 14373119a..06b41b43a 100644 --- a/pkg/common/db/relation/group_member_model.go +++ b/pkg/common/db/relation/group_member_model.go @@ -130,5 +130,5 @@ func (g *GroupMemberGorm) FindMemberUserID(ctx context.Context, groupID string, defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userIDs", userIDs) }() - return userIDs, utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id = ?", groupID).Pluck("user_id", &userIDs), "") + return userIDs, utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id = ?", groupID).Pluck("user_id", &userIDs).Error, "") } From e147dc5b1b0bbeceb21798100d9b9bf87d54e8bd Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Tue, 14 Feb 2023 19:28:57 +0800 Subject: [PATCH 43/48] callback start --- cmd/rpc/group/main.go | 2 +- internal/rpc/group/callback.go | 126 ++++++++++-------------------- internal/rpc/group/group.go | 6 +- internal/startrpc/start.go | 20 +++-- pkg/callbackstruct/common.go | 6 +- pkg/callbackstruct/friend.go | 2 +- pkg/callbackstruct/group.go | 34 ++++---- pkg/callbackstruct/message.go | 14 ++-- pkg/callbackstruct/msg_gateway.go | 6 +- pkg/callbackstruct/push.go | 4 +- pkg/common/db/controller/group.go | 58 +++++++++++++- 11 files changed, 142 insertions(+), 136 deletions(-) diff --git a/cmd/rpc/group/main.go b/cmd/rpc/group/main.go index 2ccae9e6b..89451b6ef 100644 --- a/cmd/rpc/group/main.go +++ b/cmd/rpc/group/main.go @@ -7,5 +7,5 @@ import ( ) func main() { - startrpc.Start(config.Config.RpcPort.OpenImGroupPort[0], config.Config.RpcRegisterName.OpenImGroupName, config.Config.Prometheus.GroupPrometheusPort[0], group.Start) + startrpc.Start(config.Config.RpcPort.OpenImGroupPort, config.Config.RpcRegisterName.OpenImGroupName, config.Config.Prometheus.GroupPrometheusPort, group.Start) } diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index 0c174b8bf..47fe90da4 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -12,6 +12,7 @@ import ( "Open_IM/pkg/utils" "context" "google.golang.org/protobuf/types/known/wrapperspb" + "time" ) func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (err error) { @@ -21,72 +22,44 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) ( defer func() { tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", req) }() - operationID := tracelog.GetOperationID(ctx) - commonCallbackReq := &callbackstruct.CallbackBeforeCreateGroupReq{ + cbReq := &callbackstruct.CallbackBeforeCreateGroupReq{ CallbackCommand: constant.CallbackBeforeCreateGroupCommand, - OperationID: operationID, + OperationID: tracelog.GetOperationID(ctx), GroupInfo: *req.GroupInfo, } - commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{ + cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{ UserID: req.OwnerUserID, RoleLevel: constant.GroupOwner, }) for _, userID := range req.AdminUserIDs { - commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{ + cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{ UserID: userID, RoleLevel: constant.GroupAdmin, }) } for _, userID := range req.AdminUserIDs { - commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{ + cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{ UserID: userID, RoleLevel: constant.GroupOrdinaryUsers, }) } - resp := &callbackstruct.CallbackBeforeCreateGroupResp{ - CommonCallbackResp: &callbackstruct.CommonCallbackResp{OperationID: operationID}, - } - err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeCreateGroup) + resp := &callbackstruct.CallbackBeforeCreateGroupResp{} + err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeCreateGroup) if err != nil { return err } - - if resp.GroupID != nil { - req.GroupInfo.GroupID = *resp.GroupID - } - if resp.GroupName != nil { - req.GroupInfo.GroupName = *resp.GroupName - } - if resp.Notification != nil { - req.GroupInfo.Notification = *resp.Notification - } - if resp.Introduction != nil { - req.GroupInfo.Introduction = *resp.Introduction - } - if resp.FaceURL != nil { - req.GroupInfo.FaceURL = *resp.FaceURL - } - if resp.OwnerUserID != nil { - req.GroupInfo.OwnerUserID = *resp.OwnerUserID - } - if resp.Ex != nil { - req.GroupInfo.Ex = *resp.Ex - } - if resp.Status != nil { - req.GroupInfo.Status = *resp.Status - } - if resp.CreatorUserID != nil { - req.GroupInfo.CreatorUserID = *resp.CreatorUserID - } - if resp.GroupType != nil { - req.GroupInfo.GroupType = *resp.GroupType - } - if resp.NeedVerification != nil { - req.GroupInfo.NeedVerification = *resp.NeedVerification - } - if resp.LookMemberInfo != nil { - req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo - } + utils.NotNilReplace(&req.GroupInfo.GroupID, resp.GroupID) + utils.NotNilReplace(&req.GroupInfo.GroupName, resp.GroupName) + utils.NotNilReplace(&req.GroupInfo.Notification, resp.Notification) + utils.NotNilReplace(&req.GroupInfo.Introduction, resp.Introduction) + utils.NotNilReplace(&req.GroupInfo.FaceURL, resp.FaceURL) + utils.NotNilReplace(&req.GroupInfo.OwnerUserID, resp.OwnerUserID) + utils.NotNilReplace(&req.GroupInfo.Ex, resp.Ex) + utils.NotNilReplace(&req.GroupInfo.Status, resp.Status) + utils.NotNilReplace(&req.GroupInfo.CreatorUserID, resp.CreatorUserID) + utils.NotNilReplace(&req.GroupInfo.GroupType, resp.GroupType) + utils.NotNilReplace(&req.GroupInfo.NeedVerification, resp.NeedVerification) + utils.NotNilReplace(&req.GroupInfo.LookMemberInfo, resp.LookMemberInfo) return nil } @@ -97,39 +70,26 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, groupMember *relation.Gr defer func() { tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx) }() - operationID := tracelog.GetOperationID(ctx) - callbackResp := callbackstruct.CommonCallbackResp{OperationID: operationID} - callbackReq := callbackstruct.CallbackBeforeMemberJoinGroupReq{ + callbackReq := &callbackstruct.CallbackBeforeMemberJoinGroupReq{ CallbackCommand: constant.CallbackBeforeMemberJoinGroupCommand, - OperationID: operationID, + OperationID: tracelog.GetOperationID(ctx), GroupID: groupMember.GroupID, UserID: groupMember.UserID, Ex: groupMember.Ex, GroupEx: groupEx, } - resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{ - CommonCallbackResp: &callbackResp, - } - err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeMemberJoinGroupCommand, callbackReq, - resp, config.Config.Callback.CallbackBeforeMemberJoinGroup) + resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{} + err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeMemberJoinGroup) if err != nil { return err } if resp.MuteEndTime != nil { - groupMember.MuteEndTime = utils.UnixSecondToTime(*resp.MuteEndTime) - } - if resp.FaceURL != nil { - groupMember.FaceURL = *resp.FaceURL - } - if resp.Ex != nil { - groupMember.Ex = *resp.Ex - } - if resp.NickName != nil { - groupMember.Nickname = *resp.NickName - } - if resp.RoleLevel != nil { - groupMember.RoleLevel = *resp.RoleLevel + groupMember.MuteEndTime = time.UnixMilli(*resp.MuteEndTime) } + utils.NotNilReplace(&groupMember.FaceURL, resp.FaceURL) + utils.NotNilReplace(&groupMember.Ex, resp.Ex) + utils.NotNilReplace(&groupMember.Nickname, resp.Nickname) + utils.NotNilReplace(&groupMember.RoleLevel, resp.RoleLevel) return nil } @@ -140,44 +100,40 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe defer func() { tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req) }() - operationID := tracelog.GetOperationID(ctx) - callbackResp := callbackstruct.CommonCallbackResp{OperationID: operationID} callbackReq := callbackstruct.CallbackBeforeSetGroupMemberInfoReq{ CallbackCommand: constant.CallbackBeforeSetGroupMemberInfoCommand, - OperationID: operationID, + OperationID: tracelog.GetOperationID(ctx), GroupID: req.GroupID, UserID: req.UserID, } if req.Nickname != nil { - callbackReq.Nickname = req.Nickname.Value + callbackReq.Nickname = &req.Nickname.Value } if req.FaceURL != nil { - callbackReq.FaceURL = req.FaceURL.Value + callbackReq.FaceURL = &req.FaceURL.Value } if req.RoleLevel != nil { - callbackReq.RoleLevel = req.RoleLevel.Value + callbackReq.RoleLevel = &req.RoleLevel.Value } if req.Ex != nil { - callbackReq.Ex = req.Ex.Value - } - resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{ - CommonCallbackResp: &callbackResp, + callbackReq.Ex = &req.Ex.Value } - err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetGroupMemberInfoCommand, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo) + resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{} + err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo) if err != nil { return err } if resp.FaceURL != nil { - req.FaceURL = &wrapperspb.StringValue{Value: *resp.FaceURL} + req.FaceURL = wrapperspb.String(*resp.FaceURL) } if resp.Nickname != nil { - req.Nickname = &wrapperspb.StringValue{Value: *resp.Nickname} + req.Nickname = wrapperspb.String(*resp.Nickname) } if resp.RoleLevel != nil { - req.RoleLevel = &wrapperspb.Int32Value{Value: *resp.RoleLevel} + req.RoleLevel = wrapperspb.Int32(*resp.RoleLevel) } if resp.Ex != nil { - req.Ex = &wrapperspb.StringValue{Value: *resp.Ex} + req.Ex = wrapperspb.String(*resp.Ex) } - return err + return nil } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 55e6d90fd..dfa58f7ef 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -28,11 +28,11 @@ import ( ) func Start(client *openKeeper.ZkClient, server *grpc.Server) error { - mysql, err := relation.NewGormDB() + db, err := relation.NewGormDB() if err != nil { return err } - if err := mysql.AutoMigrate(&relationTb.GroupModel{}, &relationTb.GroupMemberModel{}, &relationTb.GroupRequestModel{}); err != nil { + if err := db.AutoMigrate(&relationTb.GroupModel{}, &relationTb.GroupMemberModel{}, &relationTb.GroupRequestModel{}); err != nil { return err } redis, err := cache.NewRedis() @@ -44,7 +44,7 @@ func Start(client *openKeeper.ZkClient, server *grpc.Server) error { return err } pbGroup.RegisterGroupServer(server, &groupServer{ - GroupInterface: controller.NewGroupInterface(mysql, redis.GetClient(), mongo.GetClient()), + GroupInterface: controller.NewGroupInterface(controller.NewGroupDatabase(db, redis.GetClient(), mongo.GetClient())), UserCheck: check.NewUserCheck(client), ConversationChecker: check.NewConversationChecker(client), }) diff --git a/internal/startrpc/start.go b/internal/startrpc/start.go index 0bdc2a51e..1a487d2b7 100644 --- a/internal/startrpc/start.go +++ b/internal/startrpc/start.go @@ -15,15 +15,13 @@ import ( "net" ) -func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options []grpc.ServerOption) error { - flagRpcPort := flag.Int("port", rpcPort, "get RpcGroupPort from cmd,default 16000 as port") - flagPrometheusPort := flag.Int("prometheus_port", prometheusPort, "groupPrometheusPort default listen port") +func start(rpcPorts []int, rpcRegisterName string, prometheusPorts []int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options []grpc.ServerOption) error { + flagRpcPort := flag.Int("port", rpcPorts[0], "get RpcGroupPort from cmd,default 16000 as port") + flagPrometheusPort := flag.Int("prometheus_port", prometheusPorts[0], "groupPrometheusPort default listen port") flag.Parse() - rpcPort = *flagRpcPort - prometheusPort = *flagPrometheusPort - fmt.Println("start group rpc server, port: ", rpcPort, ", OpenIM version: ", constant.CurrentVersion) + fmt.Println("start group rpc server, port: ", *flagRpcPort, ", OpenIM version: ", constant.CurrentVersion) log.NewPrivateLog(constant.LogFileName) - listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, rpcPort)) + listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, *flagRpcPort)) if err != nil { return err } @@ -50,12 +48,12 @@ func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c } srv := grpc.NewServer(options...) defer srv.GracefulStop() - err = zkClient.Register(rpcRegisterName, registerIP, rpcPort) + err = zkClient.Register(rpcRegisterName, registerIP, *flagRpcPort) if err != nil { return err } if config.Config.Prometheus.Enable { - err := promePkg.StartPromeSrv(prometheusPort) + err := promePkg.StartPromeSrv(*flagPrometheusPort) if err != nil { return err } @@ -63,7 +61,7 @@ func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c return rpcFn(zkClient, srv) } -func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options ...grpc.ServerOption) { - err := start(rpcPort, rpcRegisterName, prometheusPort, rpcFn, options) +func Start(rpcPorts []int, rpcRegisterName string, prometheusPorts []int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options ...grpc.ServerOption) { + err := start(rpcPorts, rpcRegisterName, prometheusPorts, rpcFn, options) fmt.Println("end", err) } diff --git a/pkg/callbackstruct/common.go b/pkg/callbackstruct/common.go index 2f589fc91..098dc8135 100644 --- a/pkg/callbackstruct/common.go +++ b/pkg/callbackstruct/common.go @@ -41,13 +41,9 @@ type CommonCallbackResp struct { ActionCode int `json:"actionCode"` ErrCode int32 `json:"errCode"` ErrMsg string `json:"errMsg"` - //OperationID string `json:"operationID"` } -func (c *CommonCallbackResp) Parse() error { - if c == nil { - return constant.ErrData.Wrap("callback common is nil") - } +func (c CommonCallbackResp) Parse() error { if c.ActionCode != constant.NoError || c.ErrCode != constant.NoError { newErr := constant.ErrCallback newErr.ErrCode = c.ErrCode diff --git a/pkg/callbackstruct/friend.go b/pkg/callbackstruct/friend.go index fa1cffe28..9967707f3 100644 --- a/pkg/callbackstruct/friend.go +++ b/pkg/callbackstruct/friend.go @@ -9,5 +9,5 @@ type CallbackBeforeAddFriendReq struct { } type CallbackBeforeAddFriendResp struct { - *CommonCallbackResp + CommonCallbackResp } diff --git a/pkg/callbackstruct/group.go b/pkg/callbackstruct/group.go index a84753326..136386297 100644 --- a/pkg/callbackstruct/group.go +++ b/pkg/callbackstruct/group.go @@ -5,15 +5,21 @@ import ( common "Open_IM/pkg/proto/sdkws" ) +type CallbackCommand string + +func (c CallbackCommand) GetCallbackCommand() string { + return string(c) +} + type CallbackBeforeCreateGroupReq struct { - CallbackCommand string `json:"callbackCommand"` OperationID string `json:"operationID"` + CallbackCommand `json:"callbackCommand"` common.GroupInfo InitMemberList []*apistruct.GroupAddMemberInfo `json:"initMemberList"` } type CallbackBeforeCreateGroupResp struct { - *CommonCallbackResp + CommonCallbackResp GroupID *string `json:"groupID"` GroupName *string `json:"groupName"` Notification *string `json:"notification"` @@ -30,7 +36,7 @@ type CallbackBeforeCreateGroupResp struct { } type CallbackBeforeMemberJoinGroupReq struct { - CallbackCommand string `json:"callbackCommand"` + CallbackCommand `json:"callbackCommand"` OperationID string `json:"operationID"` GroupID string `json:"groupID"` UserID string `json:"userID"` @@ -39,8 +45,8 @@ type CallbackBeforeMemberJoinGroupReq struct { } type CallbackBeforeMemberJoinGroupResp struct { - *CommonCallbackResp - NickName *string `json:"nickName"` + CommonCallbackResp + Nickname *string `json:"nickname"` FaceURL *string `json:"faceURL"` RoleLevel *int32 `json:"roleLevel"` MuteEndTime *int64 `json:"muteEndTime"` @@ -48,18 +54,18 @@ type CallbackBeforeMemberJoinGroupResp struct { } type CallbackBeforeSetGroupMemberInfoReq struct { - CallbackCommand string `json:"callbackCommand"` - OperationID string `json:"operationID"` - GroupID string `json:"groupID"` - UserID string `json:"userID"` - Nickname string `json:"nickName"` - FaceURL string `json:"faceURL"` - RoleLevel int32 `json:"roleLevel"` - Ex string `json:"ex"` + CallbackCommand `json:"callbackCommand"` + OperationID string `json:"operationID"` + GroupID string `json:"groupID"` + UserID string `json:"userID"` + Nickname *string `json:"nickName"` + FaceURL *string `json:"faceURL"` + RoleLevel *int32 `json:"roleLevel"` + Ex *string `json:"ex"` } type CallbackBeforeSetGroupMemberInfoResp struct { - *CommonCallbackResp + CommonCallbackResp Ex *string `json:"ex"` Nickname *string `json:"nickName"` FaceURL *string `json:"faceURL"` diff --git a/pkg/callbackstruct/message.go b/pkg/callbackstruct/message.go index efb26f4a3..39276cdb1 100644 --- a/pkg/callbackstruct/message.go +++ b/pkg/callbackstruct/message.go @@ -11,7 +11,7 @@ type CallbackBeforeSendSingleMsgReq struct { } type CallbackBeforeSendSingleMsgResp struct { - *CommonCallbackResp + CommonCallbackResp } type CallbackAfterSendSingleMsgReq struct { @@ -20,7 +20,7 @@ type CallbackAfterSendSingleMsgReq struct { } type CallbackAfterSendSingleMsgResp struct { - *CommonCallbackResp + CommonCallbackResp } type CallbackBeforeSendGroupMsgReq struct { @@ -29,7 +29,7 @@ type CallbackBeforeSendGroupMsgReq struct { } type CallbackBeforeSendGroupMsgResp struct { - *CommonCallbackResp + CommonCallbackResp } type CallbackAfterSendGroupMsgReq struct { @@ -38,7 +38,7 @@ type CallbackAfterSendGroupMsgReq struct { } type CallbackAfterSendGroupMsgResp struct { - *CommonCallbackResp + CommonCallbackResp } type CallbackMsgModifyCommandReq struct { @@ -46,7 +46,7 @@ type CallbackMsgModifyCommandReq struct { } type CallbackMsgModifyCommandResp struct { - *CommonCallbackResp + CommonCallbackResp Content *string `json:"content"` RecvID *string `json:"recvID"` GroupID *string `json:"groupID"` @@ -79,7 +79,7 @@ type CallbackBeforeSetMessageReactionExtReq struct { MsgFirstModifyTime int64 `json:"msgFirstModifyTime"` } type CallbackBeforeSetMessageReactionExtResp struct { - *CommonCallbackResp + CommonCallbackResp ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"` MsgFirstModifyTime int64 `json:"msgFirstModifyTime"` } @@ -95,7 +95,7 @@ type CallbackDeleteMessageReactionExtReq struct { MsgFirstModifyTime int64 `json:"msgFirstModifyTime"` } type CallbackDeleteMessageReactionExtResp struct { - *CommonCallbackResp + CommonCallbackResp ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"` MsgFirstModifyTime int64 `json:"msgFirstModifyTime"` } diff --git a/pkg/callbackstruct/msg_gateway.go b/pkg/callbackstruct/msg_gateway.go index 02509ac3f..34bb14e69 100644 --- a/pkg/callbackstruct/msg_gateway.go +++ b/pkg/callbackstruct/msg_gateway.go @@ -9,7 +9,7 @@ type CallbackUserOnlineReq struct { } type CallbackUserOnlineResp struct { - *CommonCallbackResp + CommonCallbackResp } type CallbackUserOfflineReq struct { @@ -19,7 +19,7 @@ type CallbackUserOfflineReq struct { } type CallbackUserOfflineResp struct { - *CommonCallbackResp + CommonCallbackResp } type CallbackUserKickOffReq struct { @@ -28,5 +28,5 @@ type CallbackUserKickOffReq struct { } type CallbackUserKickOffResp struct { - *CommonCallbackResp + CommonCallbackResp } diff --git a/pkg/callbackstruct/push.go b/pkg/callbackstruct/push.go index 483a2dffb..9a686b011 100644 --- a/pkg/callbackstruct/push.go +++ b/pkg/callbackstruct/push.go @@ -15,7 +15,7 @@ type CallbackBeforePushReq struct { } type CallbackBeforePushResp struct { - *CommonCallbackResp + CommonCallbackResp UserIDList []string `json:"userIDList"` OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"` } @@ -34,7 +34,7 @@ type CallbackBeforeSuperGroupOnlinePushReq struct { } type CallbackBeforeSuperGroupOnlinePushResp struct { - *CommonCallbackResp + CommonCallbackResp UserIDList []string `json:"userIDList"` OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"` } diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index 8a39442c8..2fb6a8551 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -55,8 +55,8 @@ type GroupInterface interface { var _ GroupInterface = (*GroupController)(nil) -func NewGroupInterface(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupInterface { - return &GroupController{database: NewGroupDatabase(db, rdb, mgoClient)} +func NewGroupInterface(database GroupDataBaseInterface) GroupInterface { + return &GroupController{database: database} } type GroupController struct { @@ -72,7 +72,7 @@ func (g *GroupController) CreateGroup(ctx context.Context, groups []*relationTb. } func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) { - return g.TakeGroup(ctx, groupID) + return g.database.TakeGroup(ctx, groupID) } func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) { @@ -175,6 +175,53 @@ func (g *GroupController) CreateSuperGroupMember(ctx context.Context, groupID st return g.database.CreateSuperGroupMember(ctx, groupID, userIDs) } +type Group interface { + CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error + TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) + FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) + SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error) + UpdateGroup(ctx context.Context, groupID string, data map[string]any) error + DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员 +} + +type GroupMember interface { + TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) + TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) + FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) + FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error) + PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) + SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) + HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error + DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error + MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error) + MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) + TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群 + UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error + UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error +} + +type GroupRequest interface { + CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error + TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) + PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error) +} + +type SuperGroup interface { + FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationTb.SuperGroupModel, error) + FindJoinSuperGroup(ctx context.Context, userID string) (*unrelationTb.UserToSuperGroupModel, error) + CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error + DeleteSuperGroup(ctx context.Context, groupID string) error + DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error + CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error +} + +type GroupDataBase1 interface { + Group + GroupMember + GroupRequest + SuperGroup +} + type GroupDataBaseInterface interface { CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) @@ -291,7 +338,10 @@ func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relationTb.Gr } func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) { - return g.cache.GetGroupInfo(ctx, groupID) + //return g.cache.GetGroupInfo(ctx, groupID) + return cache.GetCache(ctx, g.rcClient, g.getGroupInfoKey(groupID), g.expireTime, func(ctx context.Context) (*relationTb.GroupModel, error) { + return g.group.Take(ctx, groupID) + }) } func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) { From dea9a4c8fa87bc24cfc86edb5b7de0611ef9373f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 19:34:19 +0800 Subject: [PATCH 44/48] Error code standardization --- cmd/rpc/auth/main.go | 21 +--- cmd/rpc/friend/main.go | 19 +--- cmd/rpc/user/main.go | 21 +--- go.mod | 2 +- internal/common/convert/convert.go | 22 ++-- internal/rpc/auth/auth.go | 73 +++++------- internal/rpc/friend/friend.go | 129 +++++++-------------- internal/rpc/user/user.go | 174 +++-------------------------- 8 files changed, 103 insertions(+), 358 deletions(-) diff --git a/cmd/rpc/auth/main.go b/cmd/rpc/auth/main.go index b9485454d..4625fa2d0 100644 --- a/cmd/rpc/auth/main.go +++ b/cmd/rpc/auth/main.go @@ -1,26 +1,11 @@ package main import ( - rpcAuth "Open_IM/internal/rpc/auth" + "Open_IM/internal/rpc/auth" + "Open_IM/internal/startrpc" "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - promePkg "Open_IM/pkg/common/prometheus" - "flag" - "fmt" ) func main() { - defaultPorts := config.Config.RpcPort.OpenImAuthPort - rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800") - prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.AuthPrometheusPort[0], "authPrometheusPort default listen port") - flag.Parse() - fmt.Println("start auth rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n") - rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort) - go func() { - err := promePkg.StartPromeSrv(*prometheusPort) - if err != nil { - panic(err) - } - }() - rpcServer.Run() + startrpc.Start(config.Config.RpcPort.OpenImAuthPort[0], config.Config.RpcRegisterName.OpenImAuthName, config.Config.Prometheus.AuthPrometheusPort[0], auth.Start) } diff --git a/cmd/rpc/friend/main.go b/cmd/rpc/friend/main.go index 3b88d6964..907ee7dbd 100644 --- a/cmd/rpc/friend/main.go +++ b/cmd/rpc/friend/main.go @@ -2,25 +2,10 @@ package main import ( "Open_IM/internal/rpc/friend" + "Open_IM/internal/startrpc" "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - promePkg "Open_IM/pkg/common/prometheus" - "flag" - "fmt" ) func main() { - defaultPorts := config.Config.RpcPort.OpenImFriendPort - rpcPort := flag.Int("port", defaultPorts[0], "get RpcFriendPort from cmd,default 12000 as port") - prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.FriendPrometheusPort[0], "friendPrometheusPort default listen port") - flag.Parse() - fmt.Println("start friend rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n") - rpcServer := friend.NewFriendServer(*rpcPort) - go func() { - err := promePkg.StartPromeSrv(*prometheusPort) - if err != nil { - panic(err) - } - }() - rpcServer.Run() + startrpc.Start(config.Config.RpcPort.OpenImFriendPort[0], config.Config.RpcRegisterName.OpenImFriendName, config.Config.Prometheus.FriendPrometheusPort[0], friend.Start) } diff --git a/cmd/rpc/user/main.go b/cmd/rpc/user/main.go index f6191280f..331daa8f4 100644 --- a/cmd/rpc/user/main.go +++ b/cmd/rpc/user/main.go @@ -2,25 +2,12 @@ package main import ( "Open_IM/internal/rpc/user" + "Open_IM/internal/startrpc" "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - promePkg "Open_IM/pkg/common/prometheus" - "flag" - "fmt" ) func main() { - defaultPorts := config.Config.RpcPort.OpenImUserPort - rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port") - prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.UserPrometheusPort[0], "userPrometheusPort default listen port") - flag.Parse() - fmt.Println("start user rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n") - rpcServer := user.NewUserServer(*rpcPort) - go func() { - err := promePkg.StartPromeSrv(*prometheusPort) - if err != nil { - panic(err) - } - }() - rpcServer.Run() + + startrpc.Start(config.Config.RpcPort.OpenImUserPort[0], config.Config.RpcRegisterName.OpenImUserName, config.Config.Prometheus.UserPrometheusPort[0], user.Start) + } diff --git a/go.mod b/go.mod index 5781ef0f5..238c77914 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/stretchr/testify v1.8.1 github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe github.com/swaggo/gin-swagger v1.5.0 - github.com/swaggo/swag v1.8.3 + github.com/swaggo/swag v1.8.3 // indirect github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca go.etcd.io/etcd/client/v3 v3.5.6 // indirect go.mongodb.org/mongo-driver v1.8.3 diff --git a/internal/common/convert/convert.go b/internal/common/convert/convert.go index 5b344770e..861027167 100644 --- a/internal/common/convert/convert.go +++ b/internal/common/convert/convert.go @@ -46,27 +46,27 @@ func (db *DBFriend) DB2PB(ctx context.Context, friends []*relation.FriendModel) return nil, err } for _, v := range friends { - pbFriend := &sdk.FriendInfo{FriendUser: &sdk.UserInfo{}} - utils.CopyStructFields(pbFriend, users[v.OwnerUserID]) - utils.CopyStructFields(pbFriend.FriendUser, users[v.FriendUserID]) - pbFriend.CreateTime = v.CreateTime.Unix() - pbFriend.FriendUser.CreateTime = v.CreateTime.Unix() + pbfriend := &sdk.FriendInfo{FriendUser: &sdk.UserInfo{}} + utils.CopyStructFields(pbfriend, users[v.OwnerUserID]) + utils.CopyStructFields(pbfriend.FriendUser, users[v.FriendUserID]) + pbfriend.CreateTime = v.CreateTime.Unix() + pbfriend.FriendUser.CreateTime = v.CreateTime.Unix() } return } func (db *DBFriend) Convert(ctx context.Context) (*sdk.FriendInfo, error) { - pbFriend := &sdk.FriendInfo{FriendUser: &sdk.UserInfo{}} - utils.CopyStructFields(pbFriend, db) + pbfriend := &sdk.FriendInfo{FriendUser: &sdk.UserInfo{}} + utils.CopyStructFields(pbfriend, db) user, err := db.userCheck.GetUsersInfo(ctx, db.FriendUserID) if err != nil { return nil, err } - utils.CopyStructFields(pbFriend.FriendUser, user) - pbFriend.CreateTime = db.CreateTime.Unix() + utils.CopyStructFields(pbfriend.FriendUser, user) + pbfriend.CreateTime = db.CreateTime.Unix() - pbFriend.FriendUser.CreateTime = db.CreateTime.Unix() - return pbFriend, nil + pbfriend.FriendUser.CreateTime = db.CreateTime.Unix() + return pbfriend, nil } func (pb *PBFriend) Convert() (*relation.FriendModel, error) { diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 603f60c22..e3a3bea04 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -2,68 +2,45 @@ package auth import ( "Open_IM/internal/common/check" - "Open_IM/internal/common/rpcserver" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/controller" + "Open_IM/pkg/common/db/relation" + relationTb "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/log" - promePkg "Open_IM/pkg/common/prometheus" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" + discoveryRegistry "Open_IM/pkg/discoveryregistry" pbAuth "Open_IM/pkg/proto/auth" pbRelay "Open_IM/pkg/proto/relay" "Open_IM/pkg/utils" "context" - grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "github.com/OpenIMSDK/openKeeper" "google.golang.org/grpc" ) -func NewRpcAuthServer(port int) *rpcAuth { - r, err := rpcserver.NewRpcServer(config.Config.RpcRegisterIP, port, config.Config.RpcRegisterName.OpenImAuthName, config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema) +func Start(client *openKeeper.ZkClient, server *grpc.Server) error { + mysql, err := relation.NewGormDB() if err != nil { - panic(err) - } - var redis cache.RedisClient - redis.InitRedis() - return &rpcAuth{ - RpcServer: r, - AuthInterface: controller.NewAuthController(redis.GetClient(), config.Config.TokenPolicy.AccessSecret, config.Config.TokenPolicy.AccessExpire), - } -} - -func (s *rpcAuth) Run() { - operationID := utils.OperationIDGenerator() - log.NewInfo(operationID, "rpc auth start...") - listener, address, err := rpcserver.GetTcpListen(config.Config.ListenIP, s.Port) - if err != nil { - panic(err) + return err } - log.NewInfo(operationID, "listen network success ", listener, address) - var grpcOpts []grpc.ServerOption - if config.Config.Prometheus.Enable { - promePkg.NewGrpcRequestCounter() - promePkg.NewGrpcRequestFailedCounter() - promePkg.NewGrpcRequestSuccessCounter() - promePkg.NewUserRegisterCounter() - promePkg.NewUserLoginCounter() - grpcOpts = append(grpcOpts, []grpc.ServerOption{ - // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), - grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), - grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), - }...) + if err := mysql.AutoMigrate(&relationTb.FriendModel{}, &relationTb.FriendRequestModel{}, &relationTb.BlackModel{}); err != nil { + return err } - srv := grpc.NewServer(grpcOpts...) - defer srv.GracefulStop() - pbAuth.RegisterAuthServer(srv, s) - err = srv.Serve(listener) + redis, err := cache.NewRedis() if err != nil { - panic(err) + return err } - log.NewInfo(operationID, "rpc auth ok") + pbAuth.RegisterAuthServer(server, &authServer{ + userCheck: check.NewUserCheck(client), + RegisterCenter: client, + AuthInterface: controller.NewAuthController(redis.GetClient(), config.Config.TokenPolicy.AccessSecret, config.Config.TokenPolicy.AccessExpire), + }) + return nil } -func (s *rpcAuth) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) { +func (s *authServer) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) { resp := pbAuth.UserTokenResp{} if _, err := s.userCheck.GetUsersInfo(ctx, req.UserID); err != nil { return nil, err @@ -77,7 +54,7 @@ func (s *rpcAuth) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*pbA return &resp, nil } -func (s *rpcAuth) parseToken(ctx context.Context, tokensString string) (claims *tokenverify.Claims, err error) { +func (s *authServer) parseToken(ctx context.Context, tokensString string) (claims *tokenverify.Claims, err error) { claims, err = tokenverify.GetClaimFromToken(tokensString) if err != nil { return nil, utils.Wrap(err, "") @@ -102,7 +79,7 @@ func (s *rpcAuth) parseToken(ctx context.Context, tokensString string) (claims * return nil, constant.ErrTokenNotExist.Wrap() } -func (s *rpcAuth) ParseToken(ctx context.Context, req *pbAuth.ParseTokenReq) (resp *pbAuth.ParseTokenResp, err error) { +func (s *authServer) ParseToken(ctx context.Context, req *pbAuth.ParseTokenReq) (resp *pbAuth.ParseTokenResp, err error) { resp = &pbAuth.ParseTokenResp{} claims, err := s.parseToken(ctx, req.Token) if err != nil { @@ -114,7 +91,7 @@ func (s *rpcAuth) ParseToken(ctx context.Context, req *pbAuth.ParseTokenReq) (re return resp, nil } -func (s *rpcAuth) ForceLogout(ctx context.Context, req *pbAuth.ForceLogoutReq) (*pbAuth.ForceLogoutResp, error) { +func (s *authServer) ForceLogout(ctx context.Context, req *pbAuth.ForceLogoutReq) (*pbAuth.ForceLogoutResp, error) { resp := pbAuth.ForceLogoutResp{} if err := tokenverify.CheckAdmin(ctx); err != nil { return nil, err @@ -125,7 +102,7 @@ func (s *rpcAuth) ForceLogout(ctx context.Context, req *pbAuth.ForceLogoutReq) ( return &resp, nil } -func (s *rpcAuth) forceKickOff(ctx context.Context, userID string, platformID int32, operationID string) error { +func (s *authServer) forceKickOff(ctx context.Context, userID string, platformID int32, operationID string) error { grpcCons, err := s.RegisterCenter.GetConns(config.Config.RpcRegisterName.OpenImRelayName) if err != nil { return err @@ -140,8 +117,8 @@ func (s *rpcAuth) forceKickOff(ctx context.Context, userID string, platformID in return constant.ErrInternalServer.Wrap() } -type rpcAuth struct { - *rpcserver.RpcServer +type authServer struct { controller.AuthInterface - userCheck *check.UserCheck + userCheck *check.UserCheck + RegisterCenter discoveryRegistry.SvcDiscoveryRegistry } diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 7a350283a..734e1d7ed 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -4,100 +4,49 @@ import ( "Open_IM/internal/common/check" "Open_IM/internal/common/convert" "Open_IM/internal/common/notification" - "Open_IM/internal/common/rpcserver" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/controller" "Open_IM/pkg/common/db/relation" relationTb "Open_IM/pkg/common/db/table/relation" - "Open_IM/pkg/common/log" - "Open_IM/pkg/common/middleware" - promePkg "Open_IM/pkg/common/prometheus" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" - pbFriend "Open_IM/pkg/proto/friend" + discoveryRegistry "Open_IM/pkg/discoveryregistry" + pbfriend "Open_IM/pkg/proto/friend" "Open_IM/pkg/utils" "context" - grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "github.com/OpenIMSDK/openKeeper" "google.golang.org/grpc" ) type friendServer struct { - *rpcserver.RpcServer controller.FriendInterface controller.BlackInterface - notification *notification.Check - userCheck *check.UserCheck + notification *notification.Check + userCheck *check.UserCheck + RegisterCenter discoveryRegistry.SvcDiscoveryRegistry } -func NewFriendServer(port int) *friendServer { - r, err := rpcserver.NewRpcServer(config.Config.RpcRegisterIP, port, config.Config.RpcRegisterName.OpenImFriendName, config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema) +func Start(client *openKeeper.ZkClient, server *grpc.Server) error { + mysql, err := relation.NewGormDB() if err != nil { - panic(err) + return err } - //mysql init - var mysql relation.Mysql - var model relation.FriendGorm - err = mysql.InitConn().AutoMigrateModel(&relationTb.FriendModel{}) - if err != nil { - panic("db init err:" + err.Error()) - } - err = mysql.InitConn().AutoMigrateModel(&relationTb.FriendRequestModel{}) - if err != nil { - panic("db init err:" + err.Error()) - } - err = mysql.InitConn().AutoMigrateModel(&relationTb.BlackModel{}) - if err != nil { - panic("db init err:" + err.Error()) - } - if mysql.GormConn() != nil { - model.DB = mysql.GormConn() - } else { - panic("db init err:" + "conn is nil") - } - return &friendServer{ - RpcServer: r, - FriendInterface: controller.NewFriendController(model.DB), - BlackInterface: controller.NewBlackController(model.DB), - } -} - -func (s *friendServer) Run() { - operationID := utils.OperationIDGenerator() - log.NewInfo(operationID, "friendServer run...") - listener, address, err := rpcserver.GetTcpListen(config.Config.ListenIP, s.Port) - if err != nil { - panic(err) - } - - log.NewInfo(operationID, "listen ok ", address) - defer listener.Close() - //grpc server - var grpcOpts []grpc.ServerOption - grpcOpts = append(grpcOpts, grpc.UnaryInterceptor(middleware.RpcServerInterceptor)) - if config.Config.Prometheus.Enable { - promePkg.NewGrpcRequestCounter() - promePkg.NewGrpcRequestFailedCounter() - promePkg.NewGrpcRequestSuccessCounter() - grpcOpts = append(grpcOpts, []grpc.ServerOption{ - // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), - grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), - grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), - }...) - } - srv := grpc.NewServer(grpcOpts...) - defer srv.GracefulStop() - pbFriend.RegisterFriendServer(srv, s) - err = srv.Serve(listener) - if err != nil { - log.NewError(operationID, "Serve failed ", err.Error(), listener) - return + if err := mysql.AutoMigrate(&relationTb.FriendModel{}, &relationTb.FriendRequestModel{}, &relationTb.BlackModel{}); err != nil { + return err } + pbfriend.RegisterFriendServer(server, &friendServer{ + FriendInterface: controller.NewFriendController(mysql), + BlackInterface: controller.NewBlackController(mysql), + notification: notification.NewCheck(client), + userCheck: check.NewUserCheck(client), + RegisterCenter: client, + }) + return nil } // ok -func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) (resp *pbFriend.ApplyToAddFriendResp, err error) { - resp = &pbFriend.ApplyToAddFriendResp{} +func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) { + resp = &pbfriend.ApplyToAddFriendResp{} if err := tokenverify.CheckAccessV3(ctx, req.FromUserID); err != nil { return nil, err } @@ -125,8 +74,8 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.Apply } // ok -func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFriendReq) (resp *pbFriend.ImportFriendResp, err error) { - resp = &pbFriend.ImportFriendResp{} +func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFriendReq) (resp *pbfriend.ImportFriendResp, err error) { + resp = &pbfriend.ImportFriendResp{} if err := tokenverify.CheckAdmin(ctx); err != nil { return nil, err } @@ -148,8 +97,8 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFr } // ok -func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.RespondFriendApplyReq) (resp *pbFriend.RespondFriendApplyResp, err error) { - resp = &pbFriend.RespondFriendApplyResp{} +func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.RespondFriendApplyReq) (resp *pbfriend.RespondFriendApplyResp, err error) { + resp = &pbfriend.RespondFriendApplyResp{} if err := s.userCheck.Access(ctx, req.ToUserID); err != nil { return nil, err } @@ -174,8 +123,8 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res } // ok -func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (resp *pbFriend.DeleteFriendResp, err error) { - resp = &pbFriend.DeleteFriendResp{} +func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) (resp *pbfriend.DeleteFriendResp, err error) { + resp = &pbfriend.DeleteFriendResp{} if err := s.userCheck.Access(ctx, req.OwnerUserID); err != nil { return nil, err } @@ -191,8 +140,8 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri } // ok -func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFriendRemarkReq) (resp *pbFriend.SetFriendRemarkResp, err error) { - resp = &pbFriend.SetFriendRemarkResp{} +func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFriendRemarkReq) (resp *pbfriend.SetFriendRemarkResp, err error) { + resp = &pbfriend.SetFriendRemarkResp{} if err := s.userCheck.Access(ctx, req.OwnerUserID); err != nil { return nil, err } @@ -208,8 +157,8 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFri } // ok -func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbFriend.GetDesignatedFriendsReq) (resp *pbFriend.GetDesignatedFriendsResp, err error) { - resp = &pbFriend.GetDesignatedFriendsResp{} +func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.GetDesignatedFriendsReq) (resp *pbfriend.GetDesignatedFriendsResp, err error) { + resp = &pbfriend.GetDesignatedFriendsResp{} if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } @@ -226,8 +175,8 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbFriend.G } // ok 获取接收到的好友申请(即别人主动申请的) -func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbFriend.GetPaginationFriendsApplyToReq) (resp *pbFriend.GetPaginationFriendsApplyToResp, err error) { - resp = &pbFriend.GetPaginationFriendsApplyToResp{} +func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyToReq) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) { + resp = &pbfriend.GetPaginationFriendsApplyToResp{} if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } @@ -244,8 +193,8 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbF } // ok 获取主动发出去的好友申请列表 -func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbFriend.GetPaginationFriendsApplyFromReq) (resp *pbFriend.GetPaginationFriendsApplyFromResp, err error) { - resp = &pbFriend.GetPaginationFriendsApplyFromResp{} +func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyFromReq) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) { + resp = &pbfriend.GetPaginationFriendsApplyFromResp{} if err := s.userCheck.Access(ctx, req.UserID); err != nil { return nil, err } @@ -262,8 +211,8 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *p } // ok -func (s *friendServer) IsFriend(ctx context.Context, req *pbFriend.IsFriendReq) (resp *pbFriend.IsFriendResp, err error) { - resp = &pbFriend.IsFriendResp{} +func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq) (resp *pbfriend.IsFriendResp, err error) { + resp = &pbfriend.IsFriendResp{} resp.InUser1Friends, resp.InUser2Friends, err = s.FriendInterface.CheckIn(ctx, req.UserID1, req.UserID2) if err != nil { return nil, err @@ -272,8 +221,8 @@ func (s *friendServer) IsFriend(ctx context.Context, req *pbFriend.IsFriendReq) } // ok -func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbFriend.GetPaginationFriendsReq) (resp *pbFriend.GetPaginationFriendsResp, err error) { - resp = &pbFriend.GetPaginationFriendsResp{} +func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) { + resp = &pbfriend.GetPaginationFriendsResp{} if utils.Duplicate(req.FriendUserIDs) { return nil, constant.ErrArgs.Wrap("friend userID repeated") } diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 658de155d..72ed92759 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -4,184 +4,46 @@ import ( "Open_IM/internal/common/check" "Open_IM/internal/common/convert" "Open_IM/internal/common/notification" - "Open_IM/internal/common/rpcserver" - "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/controller" "Open_IM/pkg/common/db/relation" tablerelation "Open_IM/pkg/common/db/table/relation" - "Open_IM/pkg/common/log" - prome "Open_IM/pkg/common/prometheus" "Open_IM/pkg/common/tokenverify" "Open_IM/pkg/common/tracelog" + discoveryRegistry "Open_IM/pkg/discoveryregistry" "Open_IM/pkg/proto/sdkws" pbuser "Open_IM/pkg/proto/user" "Open_IM/pkg/utils" "context" - grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - + "github.com/OpenIMSDK/openKeeper" "google.golang.org/grpc" ) type userServer struct { - *rpcserver.RpcServer controller.UserInterface - notification *notification.Check - userCheck *check.UserCheck + notification *notification.Check + userCheck *check.UserCheck + ConversationChecker *check.ConversationChecker + RegisterCenter discoveryRegistry.SvcDiscoveryRegistry } -func NewUserServer(port int) *userServer { - r, err := rpcserver.NewRpcServer(config.Config.RpcRegisterIP, port, config.Config.RpcRegisterName.OpenImUserName, config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema) - if err != nil { - panic(err) - } - //mysql init - var mysql relation.Mysql - var model relation.UserGorm - err = mysql.InitConn().AutoMigrateModel(&model) +func Start(client *openKeeper.ZkClient, server *grpc.Server) error { + mysql, err := relation.NewGormDB() if err != nil { - panic("db init err:" + err.Error()) + return err } - if mysql.GormConn() != nil { - model.DB = mysql.GormConn() - } else { - panic("db init err:" + "conn is nil") + if err := mysql.AutoMigrate(&tablerelation.UserModel{}); err != nil { + return err } - return &userServer{RpcServer: r, UserInterface: controller.NewUserController(model.DB)} + pbuser.RegisterUserServer(server, &userServer{ + UserInterface: controller.NewUserController(mysql), + notification: notification.NewCheck(client), + userCheck: check.NewUserCheck(client), + RegisterCenter: client, + }) + return nil } -func (s *userServer) Run() { - operationID := utils.OperationIDGenerator() - log.NewInfo(operationID, "rpc user start...") - listener, address, err := rpcserver.GetTcpListen(config.Config.ListenIP, s.Port) - if err != nil { - panic(err) - } - log.NewInfo(operationID, "listen ok ", address) - defer listener.Close() - //grpc server - var grpcOpts []grpc.ServerOption - if config.Config.Prometheus.Enable { - prome.NewGrpcRequestCounter() - prome.NewGrpcRequestFailedCounter() - prome.NewGrpcRequestSuccessCounter() - grpcOpts = append(grpcOpts, []grpc.ServerOption{ - // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), - grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), - grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), - }...) - } - srv := grpc.NewServer(grpcOpts...) - defer srv.GracefulStop() - //Service registers with etcd - pbuser.RegisterUserServer(srv, s) - - err = srv.Serve(listener) - if err != nil { - panic(err) - } - log.NewInfo(operationID, "rpc user success") -} - -// ok -//func (s *userServer) SyncJoinedGroupMemberFaceURL(ctx context.Context, userID string, faceURL string, operationID string, opUserID string) { -// members, err := s.GetJoinedGroupMembers(ctx, userID) -// if err != nil { -// return -// } -// groupIDs := make([]string, 0) -// for _, v := range members { -// groupIDs = append(groupIDs, v.GroupID) -// } -// if s.SetGroupMemberInfo(ctx, "", faceURL, "", 0, groupIDs, userID) != nil { -// return -// } -// for _, v := range groupIDs { -// chat.GroupMemberInfoSetNotification(operationID, opUserID, v, userID) -// } -//} - -// ok -//func (s *userServer) SyncJoinedGroupMemberNickname(ctx context.Context, userID string, newNickname, oldNickname string, operationID string, opUserID string) { -// members, err := s.GetJoinedGroupMembers(ctx, userID) -// if err != nil { -// return -// } -// groupIDs := make([]string, 0) -// for _, v := range members { -// if v.Nickname == oldNickname { -// groupIDs = append(groupIDs, v.GroupID) -// } -// } -// s.SetGroupMemberInfo(ctx, newNickname, "", "", 0, groupIDs, userID) -// for _, v := range groupIDs { -// chat.GroupMemberInfoSetNotification(operationID, opUserID, v, userID) -// } -//} - -// 设置群头像 -//func (s *userServer) SetGroupMemberInfo(ctx context.Context, nickname, faceURL, ex string, roleLevel int32, groupIDs []string, userID string) (err error) { -// -// req := pbgroup.SetGroupMemberInfo{UserID: userID} -// if nickname != "" { -// req.Nickname = &wrappers.StringValue{Value: nickname} -// } -// if faceURL != "" { -// req.FaceURL = &wrappers.StringValue{Value: faceURL} -// } -// if ex != "" { -// req.Ex = &wrappers.StringValue{Value: ex} -// } -// if roleLevel != 0 { -// req.RoleLevel = &wrappers.Int32Value{Value: roleLevel} -// } -// -// setGroupMemberInfoReq := &pbgroup.SetGroupMemberInfoReq{} -// for _, v := range groupIDs { -// req.GroupID = v -// setGroupMemberInfoReq.Members = append(setGroupMemberInfoReq.Members, &req) -// } -// conn, err := s.RegisterCenter.GetConn(config.Config.RpcRegisterName.OpenImGroupName) -// if err != nil { -// return err -// } -// client := group.NewGroupClient(conn) -// _, err = client.SetGroupMemberInfo(ctx, setGroupMemberInfoReq) -// return -//} - -// 获取加入的群成员信息 -//func (s *userServer) GetJoinedGroupMembers(ctx context.Context, userID string) (members []*sdkws.GroupMemberFullInfo, err error) { -// conn, err := s.RegisterCenter.GetConn(config.Config.RpcRegisterName.OpenImGroupName) -// if err != nil { -// return nil, err -// } -// -// client := group.NewGroupClient(conn) -// for { -// idx := int32(0) -// req := pbgroup.GetJoinedGroupListReq{FromUserID: userID, Pagination: &sdkws.RequestPagination{PageNumber: idx, ShowNumber: constant.ShowNumber}} -// resp, err := client.GetJoinedGroupList(ctx, &req) -// if err != nil { -// return nil, err -// } -// groupIDs := make([]string, 0) -// -// for _, v := range resp.Groups { -// groupIDs = append(groupIDs, v.GroupID) -// } -// -// client.GetGroupMembersInfo() -// -// if len(resp.Groups) < constant.ShowNumber { -// break -// } -// idx++ -// } -// -// return -//} - // ok func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbuser.GetDesignateUsersReq) (resp *pbuser.GetDesignateUsersResp, err error) { resp = &pbuser.GetDesignateUsersResp{} From 64caafd6b67162c8274e174184cb09f8abc5b997 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 20:01:44 +0800 Subject: [PATCH 45/48] Error code standardization --- cmd/rpc/auth/main.go | 2 +- cmd/rpc/msg/main.go | 19 +-- internal/rpc/msg/extend_msg_callback.go | 24 ++-- internal/rpc/msg/server.go | 144 +++++------------------ pkg/common/db/cache/redis.go | 4 + pkg/common/db/controller/auth.go | 1 - pkg/common/db/controller/conversation.go | 2 +- 7 files changed, 47 insertions(+), 149 deletions(-) diff --git a/cmd/rpc/auth/main.go b/cmd/rpc/auth/main.go index 4625fa2d0..a89ff6845 100644 --- a/cmd/rpc/auth/main.go +++ b/cmd/rpc/auth/main.go @@ -7,5 +7,5 @@ import ( ) func main() { - startrpc.Start(config.Config.RpcPort.OpenImAuthPort[0], config.Config.RpcRegisterName.OpenImAuthName, config.Config.Prometheus.AuthPrometheusPort[0], auth.Start) + startrpc.Start(config.Config.RpcPort.OpenImAuthPort, config.Config.RpcRegisterName.OpenImAuthName, config.Config.Prometheus.AuthPrometheusPort, auth.Start) } diff --git a/cmd/rpc/msg/main.go b/cmd/rpc/msg/main.go index c9bcecf9c..7900b1d4e 100644 --- a/cmd/rpc/msg/main.go +++ b/cmd/rpc/msg/main.go @@ -2,25 +2,10 @@ package main import ( "Open_IM/internal/rpc/msg" + "Open_IM/internal/startrpc" "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" - promePkg "Open_IM/pkg/common/prometheus" - "flag" - "fmt" ) func main() { - defaultPorts := config.Config.RpcPort.OpenImMessagePort - rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port") - prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessagePrometheusPort[0], "msgPrometheusPort default listen port") - flag.Parse() - fmt.Println("start msg rpc server, port: ", *rpcPort, ", OpenIM version: ", constant.CurrentVersion, "\n") - rpcServer := msg.NewRpcChatServer(*rpcPort) - go func() { - err := promePkg.StartPromeSrv(*prometheusPort) - if err != nil { - panic(err) - } - }() - rpcServer.Run() + startrpc.Start(config.Config.RpcPort.OpenImMessagePort, config.Config.RpcRegisterName.OpenImMsgName, config.Config.Prometheus.AuthPrometheusPort, msg.Start) } diff --git a/internal/rpc/msg/extend_msg_callback.go b/internal/rpc/msg/extend_msg_callback.go index eefcb419e..949e30c3f 100644 --- a/internal/rpc/msg/extend_msg_callback.go +++ b/internal/rpc/msg/extend_msg_callback.go @@ -1,7 +1,7 @@ package msg import ( - cbApi "Open_IM/pkg/call_back_struct" + cb "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" @@ -11,10 +11,10 @@ import ( http2 "net/http" ) -func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensionsReq) *cbApi.CallbackBeforeSetMessageReactionExtResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} +func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensionsReq) *cb.CallbackBeforeSetMessageReactionExtResp { + callbackResp := cb.CommonCallbackResp{OperationID: setReq.OperationID} log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) - req := cbApi.CallbackBeforeSetMessageReactionExtReq{ + req := cb.CallbackBeforeSetMessageReactionExtReq{ OperationID: setReq.OperationID, CallbackCommand: constant.CallbackBeforeSetMessageReactionExtensionCommand, SourceID: setReq.SourceID, @@ -26,7 +26,7 @@ func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensio IsExternalExtensions: setReq.IsExternalExtensions, MsgFirstModifyTime: setReq.MsgFirstModifyTime, } - resp := &cbApi.CallbackBeforeSetMessageReactionExtResp{CommonCallbackResp: &callbackResp} + resp := &cb.CallbackBeforeSetMessageReactionExtResp{CommonCallbackResp: &callbackResp} defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp) if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetMessageReactionExtensionCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError @@ -36,8 +36,8 @@ func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensio } -func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReactionExtensionsReq) *cbApi.CallbackDeleteMessageReactionExtResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} +func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReactionExtensionsReq) *cb.CallbackDeleteMessageReactionExtResp { + callbackResp := cb.CommonCallbackResp{OperationID: setReq.OperationID} log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) req := cbApi.CallbackDeleteMessageReactionExtReq{ OperationID: setReq.OperationID, @@ -58,8 +58,8 @@ func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReacti } return resp } -func callbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) *cbApi.CallbackGetMessageListReactionExtResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: getReq.OperationID} +func callbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) *cb.CallbackGetMessageListReactionExtResp { + callbackResp := cb.CommonCallbackResp{OperationID: getReq.OperationID} log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), getReq.String()) req := cbApi.CallbackGetMessageListReactionExtReq{ OperationID: getReq.OperationID, @@ -78,8 +78,8 @@ func callbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReaction } return resp } -func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensionsReq) *cbApi.CallbackAddMessageReactionExtResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: setReq.OperationID} +func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensionsReq) *cb.CallbackAddMessageReactionExtResp { + callbackResp := cb.CommonCallbackResp{OperationID: setReq.OperationID} log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) req := cbApi.CallbackAddMessageReactionExtReq{ OperationID: setReq.OperationID, @@ -93,7 +93,7 @@ func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensio IsExternalExtensions: setReq.IsExternalExtensions, MsgFirstModifyTime: setReq.MsgFirstModifyTime, } - resp := &cbApi.CallbackAddMessageReactionExtResp{CommonCallbackResp: &callbackResp} + resp := &cb.CallbackAddMessageReactionExtResp{CommonCallbackResp: &callbackResp} defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp, *resp.CommonCallbackResp, resp.IsReact, resp.MsgFirstModifyTime) if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAddMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index ae416ccf3..28d5c14a2 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -2,33 +2,23 @@ package msg import ( "Open_IM/internal/common/check" - "Open_IM/internal/common/notification" - "Open_IM/internal/common/rpcserver" - "Open_IM/pkg/common/config" - "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/controller" + "Open_IM/pkg/common/db/relation" + tablerelation "Open_IM/pkg/common/db/table/relation" + discoveryRegistry "Open_IM/pkg/discoveryregistry" + "github.com/OpenIMSDK/openKeeper" - "Open_IM/pkg/common/kafka" - "Open_IM/pkg/common/log" promePkg "Open_IM/pkg/common/prometheus" "Open_IM/pkg/proto/msg" - "Open_IM/pkg/utils" - "github.com/OpenIMSDK/getcdv3" - "net" - "strconv" - "strings" - - grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - "google.golang.org/grpc" ) type msgServer struct { - *rpcserver.RpcServer - MsgInterface controller.MsgInterface - Group *check.GroupChecker - User *check.UserCheck - Conversation *check.ConversationChecker + RegisterCenter discoveryRegistry.SvcDiscoveryRegistry + MsgInterface controller.MsgInterface + Group *check.GroupChecker + User *check.UserCheck + Conversation *check.ConversationChecker } type deleteMsg struct { @@ -38,39 +28,34 @@ type deleteMsg struct { OperationID string } -func NewRpcChatServer(port int) *msgServer { - log.NewPrivateLog(constant.LogFileName) - rc := msgServer{ - rpcPort: port, - rpcRegisterName: config.Config.RpcRegisterName.OpenImMsgName, - etcdSchema: config.Config.Etcd.EtcdSchema, - etcdAddr: config.Config.Etcd.EtcdAddr, - dMessageLocker: NewLockerMessage(), +func Start(client *openKeeper.ZkClient, server *grpc.Server) error { + mysql, err := relation.NewGormDB() + if err != nil { + return err } - rc.messageWriter = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic) - //rc.offlineProducer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschatOffline.Addr, config.Config.Kafka.Ws2mschatOffline.Topic) - rc.delMsgCh = make(chan deleteMsg, 1000) - return &rc + if err := mysql.AutoMigrate(&tablerelation.UserModel{}); err != nil { + return err + } + s := &msgServer{ + Conversation: check.NewConversationChecker(client), + User: check.NewUserCheck(client), + Group: check.NewGroupChecker(client), + //MsgInterface: controller.MsgInterface(), + RegisterCenter: client, + } + s.initPrometheus() + msg.RegisterMsgServer(server, s) + return nil } -func (rpc *rpcChat) initPrometheus() { - //sendMsgSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{ - // Name: "send_msg_success", - // Help: "The number of send msg success", - //}) - //sendMsgFailedCounter = promauto.NewCounter(prometheus.CounterOpts{ - // Name: "send_msg_failed", - // Help: "The number of send msg failed", - //}) +func (m *msgServer) initPrometheus() { promePkg.NewMsgPullFromRedisSuccessCounter() promePkg.NewMsgPullFromRedisFailedCounter() promePkg.NewMsgPullFromMongoSuccessCounter() promePkg.NewMsgPullFromMongoFailedCounter() - promePkg.NewSingleChatMsgRecvSuccessCounter() promePkg.NewGroupChatMsgRecvSuccessCounter() promePkg.NewWorkSuperGroupChatMsgRecvSuccessCounter() - promePkg.NewSingleChatMsgProcessSuccessCounter() promePkg.NewSingleChatMsgProcessFailedCounter() promePkg.NewGroupChatMsgProcessSuccessCounter() @@ -78,78 +63,3 @@ func (rpc *rpcChat) initPrometheus() { promePkg.NewWorkSuperGroupChatMsgProcessSuccessCounter() promePkg.NewWorkSuperGroupChatMsgProcessFailedCounter() } - -func (m *msgServer) Run() { - log.Info("", "rpcChat init...") - listenIP := "" - if config.Config.ListenIP == "" { - listenIP = "0.0.0.0" - } else { - listenIP = config.Config.ListenIP - } - address := listenIP + ":" + strconv.Itoa(m.rpcPort) - listener, err := net.Listen("tcp", address) - if err != nil { - panic("listening err:" + err.Error() + m.rpcRegisterName) - } - log.Info("", "listen network success, address ", address) - recvSize := 1024 * 1024 * 30 - sendSize := 1024 * 1024 * 30 - var grpcOpts = []grpc.ServerOption{ - grpc.MaxRecvMsgSize(recvSize), - grpc.MaxSendMsgSize(sendSize), - } - if config.Config.Prometheus.Enable { - promePkg.NewGrpcRequestCounter() - promePkg.NewGrpcRequestFailedCounter() - promePkg.NewGrpcRequestSuccessCounter() - grpcOpts = append(grpcOpts, []grpc.ServerOption{ - // grpc.UnaryInterceptor(promePkg.UnaryServerInterceptorProme), - grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor), - grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor), - }...) - } - srv := grpc.NewServer(grpcOpts...) - defer srv.GracefulStop() - - rpcRegisterIP := config.Config.RpcRegisterIP - msg.RegisterMsgServer(srv, m) - if config.Config.RpcRegisterIP == "" { - rpcRegisterIP, err = utils.GetLocalIP() - if err != nil { - log.Error("", "GetLocalIP failed ", err.Error()) - } - } - err = getcdv3.RegisterEtcd(m.etcdSchema, strings.Join(m.etcdAddr, ","), rpcRegisterIP, m.rpcPort, m.rpcRegisterName, 10, "") - if err != nil { - log.Error("", "register rpcChat to etcd failed ", err.Error()) - panic(utils.Wrap(err, "register chat module m to etcd err")) - } - go m.runCh() - m.initPrometheus() - err = srv.Serve(listener) - if err != nil { - log.Error("", "m rpcChat failed ", err.Error()) - return - } - log.Info("", "m rpcChat init success") -} - -func (rpc *rpcChat) runCh() { - log.NewInfo("", "start del msg chan ") - for { - select { - case msg := <-rpc.delMsgCh: - log.NewInfo(msg.OperationID, utils.GetSelfFuncName(), "delmsgch recv new: ", msg) - db.DB.DelMsgFromCache(msg.UserID, msg.SeqList, msg.OperationID) - unexistSeqList, err := db.DB.DelMsgBySeqList(msg.UserID, msg.SeqList, msg.OperationID) - if err != nil { - log.NewError(msg.OperationID, utils.GetSelfFuncName(), "DelMsgBySeqList args: ", msg.UserID, msg.SeqList, msg.OperationID, err.Error()) - continue - } - if len(unexistSeqList) > 0 { - notification.DeleteMessageNotification(msg.OpUserID, msg.UserID, unexistSeqList, msg.OperationID) - } - } - } -} diff --git a/pkg/common/db/cache/redis.go b/pkg/common/db/cache/redis.go index 34c5ee94b..27f4bec13 100644 --- a/pkg/common/db/cache/redis.go +++ b/pkg/common/db/cache/redis.go @@ -95,6 +95,10 @@ type RedisClient struct { rdb redis.UniversalClient } +func NewRedisClient(rdb redis.UniversalClient) *RedisClient { + return &RedisClient{rdb: rdb} +} + //func (r *RedisClient) InitRedis() { // var rdb redis.UniversalClient // var err error diff --git a/pkg/common/db/controller/auth.go b/pkg/common/db/controller/auth.go index eba88fd7d..ad485f117 100644 --- a/pkg/common/db/controller/auth.go +++ b/pkg/common/db/controller/auth.go @@ -19,7 +19,6 @@ type AuthController struct { } func NewAuthController(rdb redis.UniversalClient, accessSecret string, accessExpire int64) *AuthController { - cache.NewRedisClient(rdb) return &AuthController{database: cache.NewTokenRedis(cache.NewRedisClient(rdb), accessSecret, accessExpire)} } diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index 093249940..863026909 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -142,7 +142,7 @@ func NewConversationDataBase(db relation.Conversation, cache cache.ConversationC } func (c ConversationDataBase) GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) { - + panic("implement me") } func (c ConversationDataBase) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error { From 71f1fcee57a057416753da5eb467190c8ce5071d Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Tue, 14 Feb 2023 21:08:36 +0800 Subject: [PATCH 46/48] msggateway refactor --- cmd/msggateway/main.go | 6 +- internal/msggateway/new/client.go | 148 +++++++++++++++++++++ internal/msggateway/new/compressor.go | 44 ++++++ internal/msggateway/new/context.go | 27 ++++ internal/msggateway/new/encoder.go | 37 ++++++ internal/msggateway/new/long_conn.go | 83 ++++++++++++ internal/msggateway/new/message_handler.go | 49 +++++++ internal/msggateway/new/n_ws_server.go | 81 +++++++++++ internal/msggateway/new/options.go | 36 +++++ internal/msggateway/new/user_map.go | 64 +++++++++ 10 files changed, 572 insertions(+), 3 deletions(-) create mode 100644 internal/msggateway/new/client.go create mode 100644 internal/msggateway/new/compressor.go create mode 100644 internal/msggateway/new/context.go create mode 100644 internal/msggateway/new/encoder.go create mode 100644 internal/msggateway/new/long_conn.go create mode 100644 internal/msggateway/new/message_handler.go create mode 100644 internal/msggateway/new/n_ws_server.go create mode 100644 internal/msggateway/new/options.go create mode 100644 internal/msggateway/new/user_map.go diff --git a/cmd/msggateway/main.go b/cmd/msggateway/main.go index 0eb8adb1a..86de2dcc9 100644 --- a/cmd/msggateway/main.go +++ b/cmd/msggateway/main.go @@ -1,7 +1,7 @@ package main import ( - "Open_IM/internal/msg_gateway/gate" + "Open_IM/internal/msggateway" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/log" @@ -22,7 +22,7 @@ func main() { var wg sync.WaitGroup wg.Add(1) fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort, *prometheusPort, ", OpenIM version: ", constant.CurrentVersion, "\n") - gate.Init(*rpcPort, *wsPort) - gate.Run(*prometheusPort) + msggateway.Init(*rpcPort, *wsPort) + msggateway.Run(*prometheusPort) wg.Wait() } diff --git a/internal/msggateway/new/client.go b/internal/msggateway/new/client.go new file mode 100644 index 000000000..3feca66af --- /dev/null +++ b/internal/msggateway/new/client.go @@ -0,0 +1,148 @@ +package new + +import ( + "Open_IM/pkg/common/constant" + promePkg "Open_IM/pkg/common/prometheus" + "context" + "errors" + "fmt" + "github.com/envoyproxy/protoc-gen-validate/validate" + "github.com/go-playground/validator/v10" + "open_im_sdk/pkg/log" + "open_im_sdk/pkg/utils" + "runtime/debug" + "sync" +) + +const ( + // MessageText is for UTF-8 encoded text messages like JSON. + MessageText = iota + 1 + // MessageBinary is for binary messages like protobufs. + MessageBinary + // CloseMessage denotes a close control message. The optional message + // payload contains a numeric code and text. Use the FormatCloseMessage + // function to format a close message payload. + CloseMessage = 8 + + // PingMessage denotes a ping control message. The optional message payload + // is UTF-8 encoded text. + PingMessage = 9 + + // PongMessage denotes a pong control message. The optional message payload + // is UTF-8 encoded text. + PongMessage = 10 +) + +type Client struct { + w *sync.Mutex + conn LongConn + PlatformID int32 + PushedMaxSeq uint32 + IsCompress bool + userID string + IsBackground bool + token string + connID string + onlineAt int64 // 上线时间戳(毫秒) + handler MessageHandler + unregisterChan chan *Client + compressor Compressor + encoder Encoder + userContext UserConnContext + validate *validator.Validate +} + +func newClient( conn LongConn,isCompress bool, userID string, isBackground bool, token string, + connID string, onlineAt int64, handler MessageHandler,unregisterChan chan *Client) *Client { + return &Client{ + conn: conn, + IsCompress: isCompress, + userID: userID, IsBackground: + isBackground, token: token, + connID: connID, + onlineAt: onlineAt, + handler: handler, + unregisterChan: unregisterChan, + } +} +func(c *Client) readMessage(){ + defer func() { + if r:=recover(); r != nil { + fmt.Println("socket have panic err:", r, string(debug.Stack())) + } + //c.close() + }() + var returnErr error + for { + messageType, message, returnErr := c.conn.ReadMessage() + if returnErr!=nil{ + break + } + switch messageType { + case PingMessage: + case PongMessage: + case CloseMessage: + return + case MessageText: + case MessageBinary: + if len(message) == 0 { + continue + } + returnErr = c.handleMessage(message) + if returnErr!=nil{ + break + } + + } + } + +} +func (c *Client) handleMessage(message []byte)error { + if c.IsCompress { + var decompressErr error + message,decompressErr = c.compressor.DeCompress(message) + if decompressErr != nil { + return utils.Wrap(decompressErr,"") + } + } + var binaryReq Req + err := c.encoder.Decode(message, &binaryReq) + if err != nil { + return utils.Wrap(err,"") + } + if err := c.validate.Struct(binaryReq); err != nil { + return utils.Wrap(err,"") + } + if binaryReq.SendID != c.userID { + return errors.New("exception conn userID not same to req userID") + } + ctx:=context.Background() + ctx =context.WithValue(ctx,"operationID",binaryReq.OperationID) + ctx = context.WithValue(ctx,"userID",binaryReq.SendID) + var messageErr error + var resp []byte + switch binaryReq.ReqIdentifier { + case constant.WSGetNewestSeq: + resp,messageErr=c.handler.GetSeq(ctx,binaryReq) + case constant.WSSendMsg: + resp,messageErr=c.handler.SendMessage(ctx,binaryReq) + case constant.WSSendSignalMsg: + resp,messageErr=c.handler.SendSignalMessage(ctx,binaryReq) + case constant.WSPullMsgBySeqList: + resp,messageErr=c.handler.PullMessageBySeqList(ctx,binaryReq) + case constant.WsLogoutMsg: + resp,messageErr=c.handler.UserLogout(ctx,binaryReq) + case constant.WsSetBackgroundStatus: + resp,messageErr=c.handler.SetUserDeviceBackground(ctx,binaryReq) + default: + return errors.New(fmt.Sprintf("ReqIdentifier failed,sendID:%d,msgIncr:%s,reqIdentifier:%s",binaryReq.SendID,binaryReq.MsgIncr,binaryReq.ReqIdentifier)) + } + + +} +func (c *Client) close() { + +} +func () { + +} diff --git a/internal/msggateway/new/compressor.go b/internal/msggateway/new/compressor.go new file mode 100644 index 000000000..42abcccd1 --- /dev/null +++ b/internal/msggateway/new/compressor.go @@ -0,0 +1,44 @@ +package new + +import ( + "bytes" + "compress/gzip" + "io/ioutil" + "open_im_sdk/pkg/utils" +) + +type Compressor interface { + Compress(rawData []byte) ([]byte, error) + DeCompress(compressedData []byte) ([]byte, error) +} +type GzipCompressor struct { + compressProtocol string +} + +func NewGzipCompressor() *GzipCompressor { + return &GzipCompressor{compressProtocol: "gzip"} +} +func (g *GzipCompressor) Compress(rawData []byte) ([]byte, error) { + gzipBuffer := bytes.Buffer{} + gz := gzip.NewWriter(&gzipBuffer) + if _, err := gz.Write(rawData); err != nil { + return nil, utils.Wrap(err, "") + } + if err := gz.Close(); err != nil { + return nil, utils.Wrap(err, "") + } + return gzipBuffer.Bytes(), nil +} +func (g *GzipCompressor) DeCompress(compressedData []byte) ([]byte, error) { + buff := bytes.NewBuffer(compressedData) + reader, err := gzip.NewReader(buff) + if err != nil { + return nil, utils.Wrap(err, "NewReader failed") + } + compressedData, err = ioutil.ReadAll(reader) + if err != nil { + return nil, utils.Wrap(err, "ReadAll failed") + } + _ = reader.Close() + return compressedData, nil +} diff --git a/internal/msggateway/new/context.go b/internal/msggateway/new/context.go new file mode 100644 index 000000000..9ab353351 --- /dev/null +++ b/internal/msggateway/new/context.go @@ -0,0 +1,27 @@ +package new + +import "net/http" + +type UserConnContext struct { + RespWriter http.ResponseWriter + Req *http.Request + Path string + Method string + RemoteAddr string +} + +func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnContext { + return &UserConnContext{ + RespWriter: respWriter, + Req: req, + Path: req.URL.Path, + Method: req.Method, + RemoteAddr: req.RemoteAddr, + } +} +func (c *UserConnContext) Query(key string) string { + return c.Req.URL.Query().Get(key) +} +func (c *UserConnContext) GetHeader(key string) string { + return c.Req.Header.Get(key) +} diff --git a/internal/msggateway/new/encoder.go b/internal/msggateway/new/encoder.go new file mode 100644 index 000000000..10f369d2b --- /dev/null +++ b/internal/msggateway/new/encoder.go @@ -0,0 +1,37 @@ +package new + +import ( + "bytes" + "encoding/gob" + "open_im_sdk/pkg/utils" +) + +type Encoder interface { + Encode(data interface{}) ([]byte, error) + Decode(encodeData []byte, decodeData interface{}) error +} + +type GobEncoder struct { +} + +func NewGobEncoder() *GobEncoder { + return &GobEncoder{} +} +func (g *GobEncoder) Encode(data interface{}) ([]byte, error) { + buff := bytes.Buffer{} + enc := gob.NewEncoder(&buff) + err := enc.Encode(data) + if err != nil { + return nil, err + } + return buff.Bytes(), nil +} +func (g *GobEncoder) Decode(encodeData []byte, decodeData interface{}) error { + buff := bytes.NewBuffer(encodeData) + dec := gob.NewDecoder(buff) + err := dec.Decode(decodeData) + if err != nil { + return utils.Wrap(err, "") + } + return nil +} diff --git a/internal/msggateway/new/long_conn.go b/internal/msggateway/new/long_conn.go new file mode 100644 index 000000000..823964e40 --- /dev/null +++ b/internal/msggateway/new/long_conn.go @@ -0,0 +1,83 @@ +package new + +import ( + "github.com/gorilla/websocket" + "net/http" + "time" +) + +type LongConn interface { + //Close this connection + Close() error + //Write message to connection,messageType means data type,can be set binary(2) and text(1). + WriteMessage(messageType int, message []byte) error + //Read message from connection. + ReadMessage() (int, []byte, error) + //SetReadTimeout sets the read deadline on the underlying network connection, + //after a read has timed out, will return an error. + SetReadTimeout(timeout int) error + //SetWriteTimeout sets the write deadline when send message,when read has timed out,will return error. + SetWriteTimeout(timeout int) error + //Try to dial a connection,url must set auth args,header can control compress data + Dial(urlStr string, requestHeader http.Header) (*http.Response, error) + //Whether the connection of the current long connection is nil + IsNil() bool + //Set the connection of the current long connection to nil + SetConnNil() + //Check the connection of the current and when it was sent are the same + CheckSendConnDiffNow() bool +} +type GWebSocket struct { + protocolType int + conn *websocket.Conn +} + +func NewDefault(protocolType int) *GWebSocket { + return &GWebSocket{protocolType: protocolType} +} +func (d *GWebSocket) Close() error { + return d.conn.Close() +} + +func (d *GWebSocket) WriteMessage(messageType int, message []byte) error { + d.setSendConn(d.conn) + return d.conn.WriteMessage(messageType, message) +} + +func (d *GWebSocket) setSendConn(sendConn *websocket.Conn) { + d.sendConn = sendConn +} + +func (d *GWebSocket) ReadMessage() (int, []byte, error) { + return d.conn.ReadMessage() +} +func (d *GWebSocket) SetReadTimeout(timeout int) error { + return d.conn.SetReadDeadline(time.Now().Add(time.Duration(timeout) * time.Second)) +} + +func (d *GWebSocket) SetWriteTimeout(timeout int) error { + return d.conn.SetWriteDeadline(time.Now().Add(time.Duration(timeout) * time.Second)) +} + +func (d *GWebSocket) Dial(urlStr string, requestHeader http.Header) (*http.Response, error) { + conn, httpResp, err := websocket.DefaultDialer.Dial(urlStr, requestHeader) + if err == nil { + d.conn = conn + } + return httpResp, err + +} + +func (d *GWebSocket) IsNil() bool { + if d.conn != nil { + return false + } + return true +} + +func (d *GWebSocket) SetConnNil() { + d.conn = nil +} +func (d *GWebSocket) CheckSendConnDiffNow() bool { + return d.conn == d.sendConn +} diff --git a/internal/msggateway/new/message_handler.go b/internal/msggateway/new/message_handler.go new file mode 100644 index 000000000..f280992a9 --- /dev/null +++ b/internal/msggateway/new/message_handler.go @@ -0,0 +1,49 @@ +package new + +import "context" + +type Req struct { + ReqIdentifier int32 `json:"reqIdentifier" validate:"required"` + Token string `json:"token" ` + SendID string `json:"sendID" validate:"required"` + OperationID string `json:"operationID" validate:"required"` + MsgIncr string `json:"msgIncr" validate:"required"` + Data []byte `json:"data"` +} +type MessageHandler interface { + GetSeq(context context.Context, data Req) ([]byte, error) + SendMessage(context context.Context, data Req) ([]byte, error) + SendSignalMessage(context context.Context, data Req) ([]byte, error) + PullMessageBySeqList(context context.Context, data Req) ([]byte, error) + UserLogout(context context.Context, data Req) ([]byte, error) + SetUserDeviceBackground(context context.Context, data Req) ([]byte, error) +} + +var _ MessageHandler = (*GrpcHandler)(nil) + +type GrpcHandler struct { +} + +func (g GrpcHandler) GetSeq(context context.Context, data Req) ([]byte, error) { + panic("implement me") +} + +func (g GrpcHandler) SendMessage(context context.Context, data Req) ([]byte, error) { + panic("implement me") +} + +func (g GrpcHandler) SendSignalMessage(context context.Context, data Req) ([]byte, error) { + panic("implement me") +} + +func (g GrpcHandler) PullMessageBySeqList(context context.Context, data Req) ([]byte, error) { + panic("implement me") +} + +func (g GrpcHandler) UserLogout(context context.Context, data Req) ([]byte, error) { + panic("implement me") +} + +func (g GrpcHandler) SetUserDeviceBackground(context context.Context, data Req) ([]byte, error) { + panic("implement me") +} diff --git a/internal/msggateway/new/n_ws_server.go b/internal/msggateway/new/n_ws_server.go new file mode 100644 index 000000000..3c08385cd --- /dev/null +++ b/internal/msggateway/new/n_ws_server.go @@ -0,0 +1,81 @@ +package new + +import ( + "errors" + "github.com/gorilla/websocket" + "net/http" + "open_im_sdk/pkg/utils" + "sync" + "time" +) + +type LongConnServer interface { + Run() error +} + +type Server struct { + rpcPort int + wsMaxConnNum int + longConnServer *LongConnServer + rpcServer *RpcServer +} +type WsServer struct { + port int + wsMaxConnNum int + wsUpGrader *websocket.Upgrader + registerChan chan *Client + unregisterChan chan *Client + clients *UserMap + clientPool sync.Pool + onlineUserNum int64 + onlineUserConnNum int64 + compressor Compressor + handler MessageHandler +} + +func newWsServer(opts ...Option) (*WsServer, error) { + var config configs + for _, o := range opts { + o(&config) + } + if config.port < 1024 { + return nil, errors.New("port not allow to listen") + + } + return &WsServer{ + port: config.port, + wsMaxConnNum: config.maxConnNum, + wsUpGrader: &websocket.Upgrader{ + HandshakeTimeout: config.handshakeTimeout, + ReadBufferSize: config.messageMaxMsgLength, + CheckOrigin: func(r *http.Request) bool { return true }, + }, + clientPool: sync.Pool{ + New: func() interface{} { + return new(Client) + }, + }, + }, nil +} +func (ws *WsServer) Run() error { + http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler + return http.ListenAndServe(":"+utils.IntToString(ws.port), nil) //Start listening + +} +func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) { + context := newContext(w, r) + if isPass, compression := ws.headerCheck(w, r, operationID); isPass { + conn, err := ws.wsUpGrader.Upgrade(w, r, nil) //Conn is obtained through the upgraded escalator + if err != nil { + log.Error(operationID, "upgrade http conn err", err.Error(), query) + return + } else { + newConn := &UserConn{conn, new(sync.Mutex), utils.StringToInt32(query["platformID"][0]), 0, compression, query["sendID"][0], false, query["token"][0], conn.RemoteAddr().String() + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))} + userCount++ + ws.addUserConn(query["sendID"][0], utils.StringToInt(query["platformID"][0]), newConn, query["token"][0], newConn.connID, operationID) + go ws.readMsg(newConn) + } + } else { + log.Error(operationID, "headerCheck failed ") + } +} diff --git a/internal/msggateway/new/options.go b/internal/msggateway/new/options.go new file mode 100644 index 000000000..71a732751 --- /dev/null +++ b/internal/msggateway/new/options.go @@ -0,0 +1,36 @@ +package new + +import "time" + +type Option func(opt *configs) +type configs struct { + //长连接监听端口 + port int + //长连接允许最大链接数 + maxConnNum int + //连接握手超时时间 + handshakeTimeout time.Duration + //允许消息最大长度 + messageMaxMsgLength int +} + +func WithPort(port int) Option { + return func(opt *configs) { + opt.port = port + } +} +func WithMaxConnNum(num int) Option { + return func(opt *configs) { + opt.maxConnNum = num + } +} +func WithHandshakeTimeout(t time.Duration) Option { + return func(opt *configs) { + opt.handshakeTimeout = t + } +} +func WithMessageMaxMsgLength(length int) Option { + return func(opt *configs) { + opt.messageMaxMsgLength = length + } +} diff --git a/internal/msggateway/new/user_map.go b/internal/msggateway/new/user_map.go new file mode 100644 index 000000000..82615e827 --- /dev/null +++ b/internal/msggateway/new/user_map.go @@ -0,0 +1,64 @@ +package new + +import "sync" + +type UserMap struct { + m sync.Map +} + +func newUserMap() *UserMap { + return &UserMap{} +} +func (u *UserMap) GetAll(key string) []*Client { + allClients, ok := u.m.Load(key) + if ok { + return allClients.([]*Client) + } + return nil +} +func (u *UserMap) Get(key string, platformID int32) (*Client, bool) { + allClients, existed := u.m.Load(key) + if existed { + for _, client := range allClients.([]*Client) { + if client.PlatformID == platformID { + return client, existed + } + } + return nil, false + } + return nil, existed +} +func (u *UserMap) Set(key string, v *Client) { + allClients, existed := u.m.Load(key) + if existed { + oldClients := allClients.([]*Client) + oldClients = append(oldClients, v) + u.m.Store(key, oldClients) + } else { + clients := make([]*Client, 3) + clients = append(clients, v) + u.m.Store(key, clients) + } +} +func (u *UserMap) delete(key string, platformID int32) { + allClients, existed := u.m.Load(key) + if existed { + oldClients := allClients.([]*Client) + + a := make([]*Client, len(oldClients)) + for _, client := range oldClients { + if client.PlatformID != platformID { + a = append(a, client) + } + } + if len(a) == 0 { + u.m.Delete(key) + } else { + u.m.Store(key, a) + + } + } +} +func (u *UserMap) DeleteAll(key string) { + u.m.Delete(key) +} From 5baf05ba5e497f38e1816a3037d85f5f1eb90d62 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Feb 2023 22:04:03 +0800 Subject: [PATCH 47/48] Error code standardization --- internal/common/check/black.go | 21 ++++++++ internal/common/check/conversation.go | 4 ++ internal/common/check/friend.go | 5 ++ internal/common/check/user.go | 4 ++ internal/rpc/msg/send_msg.go | 77 ++++++++------------------- internal/rpc/msg/send_pull.go | 14 ++--- internal/rpc/msg/server.go | 9 +++- pkg/proto/user/user.proto | 10 +++- 8 files changed, 79 insertions(+), 65 deletions(-) create mode 100644 internal/common/check/black.go diff --git a/internal/common/check/black.go b/internal/common/check/black.go new file mode 100644 index 000000000..3e15bec0b --- /dev/null +++ b/internal/common/check/black.go @@ -0,0 +1,21 @@ +package check + +import ( + discoveryRegistry "Open_IM/pkg/discoveryregistry" + "context" +) + +type BlackChecker struct { + zk discoveryRegistry.SvcDiscoveryRegistry +} + +func NewBlackChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *BlackChecker { + return &BlackChecker{ + zk: zk, + } +} + +// possibleBlackUserID是否被userID拉黑,也就是是否在userID的黑名单中 +func (b *BlackChecker) IsBlocked(ctx context.Context, possibleBlackUserID, userID string) (bool, error) { + +} diff --git a/internal/common/check/conversation.go b/internal/common/check/conversation.go index 5d6e25537..c56330c5b 100644 --- a/internal/common/check/conversation.go +++ b/internal/common/check/conversation.go @@ -29,3 +29,7 @@ func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req * func (c *ConversationChecker) getConn() (*grpc.ClientConn, error) { return c.zk.GetConn(config.Config.RpcRegisterName.OpenImConversationName) } + +func (c *ConversationChecker) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) { + +} diff --git a/internal/common/check/friend.go b/internal/common/check/friend.go index 6c258a38c..6c4a50a48 100644 --- a/internal/common/check/friend.go +++ b/internal/common/check/friend.go @@ -34,3 +34,8 @@ func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendU func (f *FriendChecker) getConn() (*grpc.ClientConn, error) { return f.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName) } + +// possibleFriendUserID是否在userID的好友中 +func (f *FriendChecker) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) { + +} diff --git a/internal/common/check/user.go b/internal/common/check/user.go index 8178cbf1a..5e5b38ee7 100644 --- a/internal/common/check/user.go +++ b/internal/common/check/user.go @@ -102,3 +102,7 @@ func (u *UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, return e.UserID }), nil } + +func (u *UserCheck) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) { + +} diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index c9ec6bd8c..150da4ae1 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -1,10 +1,8 @@ package msg import ( - "Open_IM/internal/common/check" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db/localcache" "Open_IM/pkg/common/tracelog" "Open_IM/pkg/proto/msg" "Open_IM/pkg/proto/sdkws" @@ -58,8 +56,8 @@ type MsgCallBackResp struct { } } -func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (isMute bool, err error) { - groupMemberInfo, err := check.NewGroupChecker().GetGroupMemberInfo(ctx, groupID, userID) +func (m *msgServer) userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (isMute bool, err error) { + groupMemberInfo, err := m.Group.GetGroupMemberInfo(ctx, groupID, userID) if err != nil { return false, err } @@ -70,14 +68,14 @@ func userIsMuteAndIsAdminInGroup(ctx context.Context, groupID, userID string) (i } // 如果禁言了,再看下是否群管理员 -func groupIsMuted(ctx context.Context, groupID string, userID string) (bool, bool, error) { - groupInfo, err := check.NewGroupChecker().GetGroupInfo(ctx, groupID) +func (m *msgServer) groupIsMuted(ctx context.Context, groupID string, userID string) (bool, bool, error) { + groupInfo, err := m.Group.GetGroupInfo(ctx, groupID) if err != nil { return false, false, err } if groupInfo.Status == constant.GroupStatusMuted { - groupMemberInfo, err := check.NewGroupChecker().GetGroupMemberInfo(ctx, groupID, userID) + groupMemberInfo, err := m.Group.GetGroupMemberInfo(ctx, groupID, userID) if err != nil { return false, false, err } @@ -86,24 +84,10 @@ func groupIsMuted(ctx context.Context, groupID string, userID string) (bool, boo return false, false, nil } -func GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) { - return localcache.NewGroupMemberIDsLocalCache().GetGroupMemberIDs(ctx, groupID) +func (m *msgServer) GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) { + return m.GroupLocalCache.GetGroupMemberIDs(ctx, groupID) } -//func GetGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) { -// return check.NewGroupChecker().GetGroupInfo(ctx, groupID) -// -// -//} - -//func GetGroupMemberInfo(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) { -// check.NewGroupChecker().GetGroupMemberInfo -//} - -//func (m *msgServer)GetSuperGroupMsg(ctx context.Context, groupID string, seq uint32) (*sdkws.MsgData, error) { -// return m.MsgInterface.GetSuperGroupMsg(ctx, groupID, seq) -//} - func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgReq) ([]string, error) { switch data.MsgData.SessionType { case constant.SingleChatType: @@ -113,7 +97,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin { return nil, nil } - black, err := IsBlocked(data.MsgData.SendID, data.MsgData.RecvID) + black, err := m.black.IsBlocked(ctx, data.MsgData.SendID, data.MsgData.RecvID) if err != nil { return nil, err } @@ -121,7 +105,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe return nil, constant.ErrBlockedByPeer.Wrap() } if *config.Config.MessageVerify.FriendVerify { - friend, err := IsFriend(data.MsgData.SendID, data.MsgData.RecvID) + friend, err := m.friend.IsFriend(ctx, data.MsgData.SendID, data.MsgData.RecvID) if err != nil { return nil, err } @@ -135,7 +119,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { return nil, nil } - userIDList, err := GetGroupMemberIDs(ctx, data.MsgData.GroupID) + userIDList, err := m.GetGroupMemberIDs(ctx, data.MsgData.GroupID) if err != nil { return nil, err } @@ -148,7 +132,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe if !utils.IsContain(data.MsgData.SendID, userIDList) { return nil, constant.ErrNotInGroupYet.Wrap() } - isMute, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) + isMute, err := m.userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { return nil, err } @@ -156,7 +140,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe return nil, constant.ErrMutedInGroup.Wrap() } - isMute, isAdmin, err := groupIsMuted(ctx, data.MsgData.GroupID, data.MsgData.SendID) + isMute, isAdmin, err := m.groupIsMuted(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { return nil, err } @@ -169,7 +153,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe } return userIDList, nil case constant.SuperGroupChatType: - groupInfo, err := check.NewGroupChecker().GetGroupInfo(ctx, data.MsgData.GroupID) + groupInfo, err := m.Group.GetGroupInfo(ctx, data.MsgData.GroupID) if err != nil { return nil, err } @@ -199,7 +183,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe return nil, nil } - userIDList, err := GetGroupMemberIDs(ctx, data.MsgData.GroupID) + userIDList, err := m.GetGroupMemberIDs(ctx, data.MsgData.GroupID) if err != nil { return nil, err } @@ -213,7 +197,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe return nil, constant.ErrNotInGroupYet.Wrap() } } - isMute, err := userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) + isMute, err := m.userIsMuteAndIsAdminInGroup(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { return nil, err } @@ -221,7 +205,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe return nil, constant.ErrMutedInGroup.Wrap() } - isMute, isAdmin, err := groupIsMuted(ctx, data.MsgData.GroupID, data.MsgData.SendID) + isMute, isAdmin, err := m.groupIsMuted(ctx, data.MsgData.GroupID, data.MsgData.SendID) if err != nil { return nil, err } @@ -289,27 +273,8 @@ func GetMsgID(sendID string) string { return utils.Md5(t + "-" + sendID + "-" + strconv.Itoa(rand.Int())) } -func GetUserGlobalMsgRecvOpt(userID string) (int32, error) { - -} - -// possibleBlackUserID是否被userID拉黑,也就是是否在userID的黑名单中 -func IsBlocked(possibleBlackUserID, userID string) (bool, error) { - -} - -// possibleFriendUserID是否在userID的好友中 -func IsFriend(possibleFriendUserID, userID string) (bool, error) { - -} - -// 没找到不返回错误 -func GetSingleConversationRecvMsgOpt(userID, conversationID string) (int32, error) { - -} - -func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *msg.SendMsgReq) (bool, error) { - opt, err := GetUserGlobalMsgRecvOpt(userID) +func (m *msgServer) modifyMessageByUserMessageReceiveOpt(ctx context.Context, userID, sourceID string, sessionType int, pb *msg.SendMsgReq) (bool, error) { + opt, err := m.User.GetUserGlobalMsgRecvOpt(ctx, userID) if err != nil { return false, err } @@ -325,7 +290,7 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i return true, nil } conversationID := utils.GetConversationIDBySessionType(sourceID, sessionType) - singleOpt, err := GetSingleConversationRecvMsgOpt(userID, conversationID) + singleOpt, err := m.Conversation.GetSingleConversationRecvMsgOpt(ctx, userID, conversationID) if err != nil { return false, err } @@ -334,7 +299,7 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i return true, nil case constant.NotReceiveMessage: if utils.IsContainInt(int(pb.MsgData.ContentType), ExcludeContentType) { - return true + return true, nil } return false, nil case constant.ReceiveNotNotifyMessage: @@ -378,7 +343,7 @@ func (m *msgServer) sendMsgToGroupOptimization(ctx context.Context, list []strin options[k] = v } groupPB.MsgData.Options = options - isSend, err := modifyMessageByUserMessageReceiveOpt(v, groupPB.MsgData.GroupID, constant.GroupChatType, groupPB) + isSend, err := m.modifyMessageByUserMessageReceiveOpt(ctx, v, groupPB.MsgData.GroupID, constant.GroupChatType, groupPB) if err != nil { wg.Done() return err diff --git a/internal/rpc/msg/send_pull.go b/internal/rpc/msg/send_pull.go index 4493f9768..904e4f402 100644 --- a/internal/rpc/msg/send_pull.go +++ b/internal/rpc/msg/send_pull.go @@ -15,7 +15,7 @@ import ( func (m *msgServer) sendMsgSuperGroupChat(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, err error) { promePkg.PromeInc(promePkg.WorkSuperGroupChatMsgRecvSuccessCounter) // callback - if err = callbackBeforeSendGroupMsg(req); err != nil { + if err = CallbackBeforeSendGroupMsg(ctx, req); err != nil { return nil, err } @@ -29,7 +29,7 @@ func (m *msgServer) sendMsgSuperGroupChat(ctx context.Context, req *msg.SendMsgR return nil, err } // callback - if err = callbackAfterSendGroupMsg(req); err != nil { + if err = CallbackAfterSendGroupMsg(ctx, req); err != nil { return nil, err } @@ -60,7 +60,7 @@ func (m *msgServer) sendMsgNotification(ctx context.Context, req *msg.SendMsgReq func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, err error) { promePkg.PromeInc(promePkg.SingleChatMsgRecvSuccessCounter) - if err = callbackBeforeSendSingleMsg(req); err != nil { + if err = CallbackBeforeSendSingleMsg(ctx, req); err != nil { return nil, err } _, err = m.messageVerification(ctx, req) @@ -84,7 +84,7 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *msg.SendMsgReq) return nil, constant.ErrInternalServer.Wrap("insert to mq") } } - err = callbackAfterSendSingleMsg(req) + err = CallbackAfterSendSingleMsg(ctx, req) if err != nil { return nil, err } @@ -98,7 +98,7 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *msg.SendMsgReq) func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, err error) { // callback promePkg.PromeInc(promePkg.GroupChatMsgRecvSuccessCounter) - err = callbackBeforeSendGroupMsg(req) + err = CallbackBeforeSendGroupMsg(ctx, req) if err != nil { return nil, err } @@ -163,7 +163,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) ( wg.Wait() // callback - err = callbackAfterSendGroupMsg(req) + err = CallbackAfterSendGroupMsg(ctx, req) if err != nil { return nil, err } @@ -234,7 +234,7 @@ func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg return nil, constant.ErrMessageHasReadDisable.Wrap() } m.encapsulateMsgData(req.MsgData) - if err := callbackMsgModify(req); err != nil { + if err := CallbackMsgModify(ctx, req); err != nil { return nil, err } switch req.MsgData.SessionType { diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 28d5c14a2..1700d4e72 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -3,6 +3,7 @@ package msg import ( "Open_IM/internal/common/check" "Open_IM/pkg/common/db/controller" + "Open_IM/pkg/common/db/localcache" "Open_IM/pkg/common/db/relation" tablerelation "Open_IM/pkg/common/db/table/relation" discoveryRegistry "Open_IM/pkg/discoveryregistry" @@ -19,6 +20,9 @@ type msgServer struct { Group *check.GroupChecker User *check.UserCheck Conversation *check.ConversationChecker + friend *check.FriendChecker + *localcache.GroupLocalCache + black *check.BlackChecker } type deleteMsg struct { @@ -41,7 +45,10 @@ func Start(client *openKeeper.ZkClient, server *grpc.Server) error { User: check.NewUserCheck(client), Group: check.NewGroupChecker(client), //MsgInterface: controller.MsgInterface(), - RegisterCenter: client, + RegisterCenter: client, + GroupLocalCache: localcache.NewGroupMemberIDsLocalCache(client), + black: check.NewBlackChecker(client), + friend: check.NewFriendChecker(client), } s.initPrometheus() msg.RegisterMsgServer(server, s) diff --git a/pkg/proto/user/user.proto b/pkg/proto/user/user.proto index 3fb70a6a2..085cdafb7 100644 --- a/pkg/proto/user/user.proto +++ b/pkg/proto/user/user.proto @@ -128,7 +128,13 @@ message userRegisterResp { } +message getGlobalRecvMessageOptReq{ + string userID = 1; +} +message getGlobalRecvMessageOptResp{ + int32 globalRecvMsgOpt = 1; +} service user { //获取指定的用户信息 全字段 @@ -137,8 +143,10 @@ service user { rpc updateUserInfo(updateUserInfoReq) returns(updateUserInfoResp); //设置用户消息接收选项 rpc setGlobalRecvMessageOpt(setGlobalRecvMessageOptReq) returns(setGlobalRecvMessageOptResp); + //获取用户消息接收选项 没找到不返回错误 + rpc getGlobalRecvMessageOpt(getGlobalRecvMessageOptReq) returns(getGlobalRecvMessageOptResp); //检查userID是否存在 - rpc accountCheck(accountCheckReq)returns(accountCheckResp); + rpc accountCheck(accountCheckReq) returns (accountCheckResp); //翻页(或指定userID,昵称)拉取用户信息 全字段 rpc getPaginationUsers(getPaginationUsersReq) returns (getPaginationUsersResp); //用户注册 From ed466387e40e7a2247a1252ee76e6f5ff558bfa1 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Wed, 15 Feb 2023 15:50:52 +0800 Subject: [PATCH 48/48] callback --- internal/msggateway/callback.go | 162 ++++++++++---- internal/push/logic/callback.go | 280 ++++++++++++++++-------- internal/rpc/friend/callback.go | 43 +--- internal/rpc/friend/friend.go | 2 +- internal/rpc/group/callback.go | 6 +- internal/rpc/msg/callback.go | 10 +- internal/rpc/msg/extend_msg_callback.go | 131 ++++++----- pkg/callbackstruct/common.go | 6 +- pkg/callbackstruct/friend.go | 2 +- pkg/callbackstruct/message.go | 6 +- pkg/callbackstruct/msg_gateway.go | 8 +- pkg/common/http/http_client.go | 6 +- 12 files changed, 395 insertions(+), 267 deletions(-) diff --git a/internal/msggateway/callback.go b/internal/msggateway/callback.go index 6c709514b..f284835a8 100644 --- a/internal/msggateway/callback.go +++ b/internal/msggateway/callback.go @@ -1,89 +1,155 @@ package msggateway import ( - cbApi "Open_IM/pkg/callback_struct" + cbapi "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" - http2 "net/http" + "Open_IM/pkg/common/tracelog" + "context" "time" ) -func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID string) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +func url() string { + return config.Config.Callback.CallbackUrl +} + +func CallbackUserOnline(ctx context.Context, userID string, platformID int, isAppBackground bool, connID string) error { if !config.Config.Callback.CallbackUserOnline.Enable { - return callbackResp + return nil } - callbackUserOnlineReq := cbApi.CallbackUserOnlineReq{ - Token: token, - UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ - UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ + req := cbapi.CallbackUserOnlineReq{ + UserStatusCallbackReq: cbapi.UserStatusCallbackReq{ + UserStatusBaseCallback: cbapi.UserStatusBaseCallback{ CallbackCommand: constant.CallbackUserOnlineCommand, - OperationID: operationID, - PlatformID: int32(platformID), + OperationID: tracelog.GetOperationID(ctx), + PlatformID: platformID, Platform: constant.PlatformIDToName(platformID), }, UserID: userID, }, - Seq: int(time.Now().UnixNano() / 1e6), + Seq: time.Now().UnixMilli(), IsAppBackground: isAppBackground, ConnID: connID, } - callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp} - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return callbackResp + resp := cbapi.CommonCallbackResp{} + return http.CallBackPostReturn(url(), &req, &resp, config.Config.Callback.CallbackUserOnline) } -func callbackUserOffline(operationID, userID string, platformID int, connID string) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +func CallbackUserOffline(ctx context.Context, userID string, platformID int, connID string) error { if !config.Config.Callback.CallbackUserOffline.Enable { - return callbackResp + return nil } - callbackOfflineReq := cbApi.CallbackUserOfflineReq{ - UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ - UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ + req := &cbapi.CallbackUserOfflineReq{ + UserStatusCallbackReq: cbapi.UserStatusCallbackReq{ + UserStatusBaseCallback: cbapi.UserStatusBaseCallback{ CallbackCommand: constant.CallbackUserOfflineCommand, - OperationID: operationID, - PlatformID: int32(platformID), + OperationID: tracelog.GetOperationID(ctx), + PlatformID: platformID, Platform: constant.PlatformIDToName(platformID), }, UserID: userID, }, - Seq: int(time.Now().UnixNano() / 1e6), + Seq: time.Now().UnixMilli(), ConnID: connID, } - callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp} - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return callbackResp + resp := &cbapi.CallbackUserOfflineResp{} + return http.CallBackPostReturn(url(), req, resp, config.Config.Callback.CallbackUserOffline) } -func callbackUserKickOff(operationID string, userID string, platformID int) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +func CallbackUserKickOff(ctx context.Context, userID string, platformID int) error { if !config.Config.Callback.CallbackUserKickOff.Enable { - return callbackResp + return nil } - callbackUserKickOffReq := cbApi.CallbackUserKickOffReq{ - UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ - UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ + req := &cbapi.CallbackUserKickOffReq{ + UserStatusCallbackReq: cbapi.UserStatusCallbackReq{ + UserStatusBaseCallback: cbapi.UserStatusBaseCallback{ CallbackCommand: constant.CallbackUserKickOffCommand, - OperationID: operationID, - PlatformID: int32(platformID), + OperationID: tracelog.GetOperationID(ctx), + PlatformID: platformID, Platform: constant.PlatformIDToName(platformID), }, UserID: userID, }, - Seq: int(time.Now().UnixNano() / 1e6), - } - callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: &callbackResp} - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserKickOffCommand, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() + Seq: time.Now().UnixMilli(), } - return callbackResp + resp := &cbapi.CommonCallbackResp{} + return http.CallBackPostReturn(url(), req, resp, config.Config.Callback.CallbackUserOffline) } + +//func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID string) cbApi.CommonCallbackResp { +// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +// if !config.Config.Callback.CallbackUserOnline.Enable { +// return callbackResp +// } +// callbackUserOnlineReq := cbApi.CallbackUserOnlineReq{ +// Token: token, +// UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ +// UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ +// CallbackCommand: constant.CallbackUserOnlineCommand, +// OperationID: operationID, +// PlatformID: int32(platformID), +// Platform: constant.PlatformIDToName(platformID), +// }, +// UserID: userID, +// }, +// Seq: int(time.Now().UnixNano() / 1e6), +// IsAppBackground: isAppBackground, +// ConnID: connID, +// } +// callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp} +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// } +// return callbackResp +//} +//func callbackUserOffline(operationID, userID string, platformID int, connID string) cbApi.CommonCallbackResp { +// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +// if !config.Config.Callback.CallbackUserOffline.Enable { +// return callbackResp +// } +// callbackOfflineReq := cbApi.CallbackUserOfflineReq{ +// UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ +// UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ +// CallbackCommand: constant.CallbackUserOfflineCommand, +// OperationID: operationID, +// PlatformID: int32(platformID), +// Platform: constant.PlatformIDToName(platformID), +// }, +// UserID: userID, +// }, +// Seq: int(time.Now().UnixNano() / 1e6), +// ConnID: connID, +// } +// callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp} +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// } +// return callbackResp +//} +//func callbackUserKickOff(operationID string, userID string, platformID int) cbApi.CommonCallbackResp { +// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +// if !config.Config.Callback.CallbackUserKickOff.Enable { +// return callbackResp +// } +// callbackUserKickOffReq := cbApi.CallbackUserKickOffReq{ +// UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ +// UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ +// CallbackCommand: constant.CallbackUserKickOffCommand, +// OperationID: operationID, +// PlatformID: int32(platformID), +// Platform: constant.PlatformIDToName(platformID), +// }, +// UserID: userID, +// }, +// Seq: int(time.Now().UnixNano() / 1e6), +// } +// callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: &callbackResp} +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserKickOffCommand, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// } +// return callbackResp +//} diff --git a/internal/push/logic/callback.go b/internal/push/logic/callback.go index 6dcc1cbc3..68f99ea5b 100644 --- a/internal/push/logic/callback.go +++ b/internal/push/logic/callback.go @@ -1,28 +1,30 @@ package logic import ( - cbApi "Open_IM/pkg/callback_struct" - "Open_IM/pkg/common/callback" + cbapi "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" - "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" common "Open_IM/pkg/proto/sdkws" "Open_IM/pkg/utils" - http2 "net/http" + "context" ) -func callbackOfflinePush(operationID string, userIDList []string, msg *common.MsgData, offlinePushUserIDList *[]string) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +func url() string { + return config.Config.Callback.CallbackUrl +} + +func CallbackOfflinePush(ctx context.Context, userIDList []string, msg *common.MsgData, offlinePushUserIDList *[]string) error { if !config.Config.Callback.CallbackOfflinePush.Enable { - return callbackResp + return nil } - req := cbApi.CallbackBeforePushReq{ - UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{ - UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ + req := &cbapi.CallbackBeforePushReq{ + UserStatusBatchCallbackReq: cbapi.UserStatusBatchCallbackReq{ + UserStatusBaseCallback: cbapi.UserStatusBaseCallback{ CallbackCommand: constant.CallbackOfflinePushCommand, - OperationID: operationID, - PlatformID: msg.SenderPlatformID, + OperationID: tracelog.GetOperationID(ctx), + PlatformID: int(msg.SenderPlatformID), Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)), }, UserIDList: userIDList, @@ -34,120 +36,214 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *common.Ms ContentType: msg.ContentType, SessionType: msg.SessionType, AtUserIDList: msg.AtUserIDList, - Content: callback.GetContent(msg), + Content: utils.GetContent(msg), + } + resp := &cbapi.CallbackBeforePushResp{} + err := http.CallBackPostReturn(url(), req, resp, config.Config.Callback.CallbackOfflinePush) + if err != nil { + return err } - resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp} - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOfflinePushCommand, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - if !*config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue { - callbackResp.ActionCode = constant.ActionForbidden - return callbackResp - } else { - callbackResp.ActionCode = constant.ActionAllow - return callbackResp - } + if len(resp.UserIDList) != 0 { + *offlinePushUserIDList = resp.UserIDList } - if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow { - if len(resp.UserIDList) != 0 { - *offlinePushUserIDList = resp.UserIDList - } - if resp.OfflinePushInfo != nil { - msg.OfflinePushInfo = resp.OfflinePushInfo - } + if resp.OfflinePushInfo != nil { + msg.OfflinePushInfo = resp.OfflinePushInfo } - log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList) - return callbackResp + return nil } -func callbackOnlinePush(operationID string, userIDList []string, msg *common.MsgData) cbApi.CommonCallbackResp { - callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} - if !config.Config.Callback.CallbackOnlinePush.Enable || utils.IsContain(msg.SendID, userIDList) { - return callbackResp +func CallbackOnlinePush(operationID string, userIDList []string, msg *common.MsgData) error { + if !config.Config.Callback.CallbackOnlinePush.Enable || utils.Contain(msg.SendID, userIDList...) { + return nil } - req := cbApi.CallbackBeforePushReq{ - UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{ - UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ + req := cbapi.CallbackBeforePushReq{ + UserStatusBatchCallbackReq: cbapi.UserStatusBatchCallbackReq{ + UserStatusBaseCallback: cbapi.UserStatusBaseCallback{ CallbackCommand: constant.CallbackOnlinePushCommand, OperationID: operationID, - PlatformID: msg.SenderPlatformID, + PlatformID: int(msg.SenderPlatformID), Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)), }, UserIDList: userIDList, }, - //OfflinePushInfo: msg.OfflinePushInfo, ClientMsgID: msg.ClientMsgID, SendID: msg.SendID, GroupID: msg.GroupID, ContentType: msg.ContentType, SessionType: msg.SessionType, AtUserIDList: msg.AtUserIDList, - Content: callback.GetContent(msg), + Content: utils.GetContent(msg), } - resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp} - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOnlinePushCommand, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - if !config.Config.Callback.CallbackOnlinePush.CallbackFailedContinue { - callbackResp.ActionCode = constant.ActionForbidden - return callbackResp - } else { - callbackResp.ActionCode = constant.ActionAllow - return callbackResp - } - } - if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow { - //if resp.OfflinePushInfo != nil { - // msg.OfflinePushInfo = resp.OfflinePushInfo - //} - } - return callbackResp + resp := &cbapi.CallbackBeforePushResp{} + return http.CallBackPostReturn(url(), req, resp, config.Config.Callback.CallbackOnlinePush) } -func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg *common.MsgData, pushToUserList *[]string) cbApi.CommonCallbackResp { - log.Debug(operationID, utils.GetSelfFuncName(), groupID, msg.String(), pushToUserList) - callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +func CallbackBeforeSuperGroupOnlinePush(ctx context.Context, groupID string, msg *common.MsgData, pushToUserList *[]string) error { if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable { - return callbackResp + return nil } - req := cbApi.CallbackBeforeSuperGroupOnlinePushReq{ - UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ + req := cbapi.CallbackBeforeSuperGroupOnlinePushReq{ + UserStatusBaseCallback: cbapi.UserStatusBaseCallback{ CallbackCommand: constant.CallbackSuperGroupOnlinePushCommand, - OperationID: operationID, - PlatformID: msg.SenderPlatformID, + OperationID: tracelog.GetOperationID(ctx), + PlatformID: int(msg.SenderPlatformID), Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)), }, - //OfflinePushInfo: msg.OfflinePushInfo, ClientMsgID: msg.ClientMsgID, SendID: msg.SendID, GroupID: groupID, ContentType: msg.ContentType, SessionType: msg.SessionType, AtUserIDList: msg.AtUserIDList, - Content: callback.GetContent(msg), + Content: utils.GetContent(msg), Seq: msg.Seq, } - resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp} - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackSuperGroupOnlinePushCommand, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackFailedContinue { - callbackResp.ActionCode = constant.ActionForbidden - return callbackResp - } else { - callbackResp.ActionCode = constant.ActionAllow - return callbackResp - } + resp := &cbapi.CallbackBeforeSuperGroupOnlinePushResp{} + if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush); err != nil { + return err } - if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow { - if len(resp.UserIDList) != 0 { - *pushToUserList = resp.UserIDList - } - //if resp.OfflinePushInfo != nil { - // msg.OfflinePushInfo = resp.OfflinePushInfo - //} + if len(resp.UserIDList) != 0 { + *pushToUserList = resp.UserIDList } - log.NewDebug(operationID, utils.GetSelfFuncName(), pushToUserList, resp.UserIDList) - return callbackResp - + return nil } + +//func callbackOfflinePush(operationID string, userIDList []string, msg *common.MsgData, offlinePushUserIDList *[]string) cbApi.CommonCallbackResp { +// callbackResp := cbapi.CommonCallbackResp{OperationID: operationID} +// if !config.Config.Callback.CallbackOfflinePush.Enable { +// return callbackResp +// } +// req := cbApi.CallbackBeforePushReq{ +// UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{ +// UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ +// CallbackCommand: constant.CallbackOfflinePushCommand, +// OperationID: operationID, +// PlatformID: msg.SenderPlatformID, +// Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)), +// }, +// UserIDList: userIDList, +// }, +// OfflinePushInfo: msg.OfflinePushInfo, +// ClientMsgID: msg.ClientMsgID, +// SendID: msg.SendID, +// GroupID: msg.GroupID, +// ContentType: msg.ContentType, +// SessionType: msg.SessionType, +// AtUserIDList: msg.AtUserIDList, +// Content: callback.GetContent(msg), +// } +// resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp} +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOfflinePushCommand, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// if !*config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue { +// callbackResp.ActionCode = constant.ActionForbidden +// return callbackResp +// } else { +// callbackResp.ActionCode = constant.ActionAllow +// return callbackResp +// } +// } +// if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow { +// if len(resp.UserIDList) != 0 { +// *offlinePushUserIDList = resp.UserIDList +// } +// if resp.OfflinePushInfo != nil { +// msg.OfflinePushInfo = resp.OfflinePushInfo +// } +// } +// log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList) +// return callbackResp +//} +// +//func callbackOnlinePush(operationID string, userIDList []string, msg *common.MsgData) cbApi.CommonCallbackResp { +// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +// if !config.Config.Callback.CallbackOnlinePush.Enable || utils.IsContain(msg.SendID, userIDList) { +// return callbackResp +// } +// req := cbApi.CallbackBeforePushReq{ +// UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{ +// UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ +// CallbackCommand: constant.CallbackOnlinePushCommand, +// OperationID: operationID, +// PlatformID: msg.SenderPlatformID, +// Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)), +// }, +// UserIDList: userIDList, +// }, +// //OfflinePushInfo: msg.OfflinePushInfo, +// ClientMsgID: msg.ClientMsgID, +// SendID: msg.SendID, +// GroupID: msg.GroupID, +// ContentType: msg.ContentType, +// SessionType: msg.SessionType, +// AtUserIDList: msg.AtUserIDList, +// Content: callback.GetContent(msg), +// } +// resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp} +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOnlinePushCommand, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// if !config.Config.Callback.CallbackOnlinePush.CallbackFailedContinue { +// callbackResp.ActionCode = constant.ActionForbidden +// return callbackResp +// } else { +// callbackResp.ActionCode = constant.ActionAllow +// return callbackResp +// } +// } +// if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow { +// //if resp.OfflinePushInfo != nil { +// // msg.OfflinePushInfo = resp.OfflinePushInfo +// //} +// } +// return callbackResp +//} +// +//func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg *common.MsgData, pushToUserList *[]string) cbApi.CommonCallbackResp { +// log.Debug(operationID, utils.GetSelfFuncName(), groupID, msg.String(), pushToUserList) +// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} +// if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.Enable { +// return callbackResp +// } +// req := cbApi.CallbackBeforeSuperGroupOnlinePushReq{ +// UserStatusBaseCallback: cbApi.UserStatusBaseCallback{ +// CallbackCommand: constant.CallbackSuperGroupOnlinePushCommand, +// OperationID: operationID, +// PlatformID: msg.SenderPlatformID, +// Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)), +// }, +// //OfflinePushInfo: msg.OfflinePushInfo, +// ClientMsgID: msg.ClientMsgID, +// SendID: msg.SendID, +// GroupID: groupID, +// ContentType: msg.ContentType, +// SessionType: msg.SessionType, +// AtUserIDList: msg.AtUserIDList, +// Content: callback.GetContent(msg), +// Seq: msg.Seq, +// } +// resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp} +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackSuperGroupOnlinePushCommand, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackFailedContinue { +// callbackResp.ActionCode = constant.ActionForbidden +// return callbackResp +// } else { +// callbackResp.ActionCode = constant.ActionAllow +// return callbackResp +// } +// } +// if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow { +// if len(resp.UserIDList) != 0 { +// *pushToUserList = resp.UserIDList +// } +// //if resp.OfflinePushInfo != nil { +// // msg.OfflinePushInfo = resp.OfflinePushInfo +// //} +// } +// log.NewDebug(operationID, utils.GetSelfFuncName(), pushToUserList, resp.UserIDList) +// return callbackResp +// +//} diff --git a/internal/rpc/friend/callback.go b/internal/rpc/friend/callback.go index a894b1ddb..14df737a1 100644 --- a/internal/rpc/friend/callback.go +++ b/internal/rpc/friend/callback.go @@ -5,55 +5,22 @@ import ( "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" - "Open_IM/pkg/common/log" "Open_IM/pkg/common/tracelog" pbfriend "Open_IM/pkg/proto/friend" "context" - - //"Open_IM/pkg/proto/msg" - "Open_IM/pkg/utils" - http2 "net/http" ) -func callbackBeforeAddFriendV1(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error { - resp := callbackBeforeAddFriend(ctx, req) - if resp.ErrCode != 0 { - return (&constant.ErrInfo{ - ErrCode: resp.ErrCode, - ErrMsg: resp.ErrMsg, - }).Wrap() - } - return nil -} - -func callbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) cbapi.CommonCallbackResp { - callbackResp := cbapi.CommonCallbackResp{OperationID: tracelog.GetOperationID(ctx)} +func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error { if !config.Config.Callback.CallbackBeforeAddFriend.Enable { - return callbackResp + return nil } - - commonCallbackReq := &cbapi.CallbackBeforeAddFriendReq{ + cbReq := &cbapi.CallbackBeforeAddFriendReq{ CallbackCommand: constant.CallbackBeforeAddFriendCommand, FromUserID: req.FromUserID, ToUserID: req.ToUserID, ReqMsg: req.ReqMsg, OperationID: tracelog.GetOperationID(ctx), } - resp := &cbapi.CallbackBeforeAddFriendResp{ - CommonCallbackResp: &callbackResp, - } - //utils.CopyStructFields(req, msg.MsgData) - defer log.NewDebug(tracelog.GetOperationID(ctx), utils.GetSelfFuncName(), commonCallbackReq, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeAddFriendCommand, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - if !*config.Config.Callback.CallbackBeforeAddFriend.CallbackFailedContinue { - callbackResp.ActionCode = constant.ActionForbidden - return callbackResp - } else { - callbackResp.ActionCode = constant.ActionAllow - return callbackResp - } - } - return callbackResp + resp := &cbapi.CallbackBeforeAddFriendResp{} + return http.CallBackPostReturn(config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend) } diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 734e1d7ed..b0ad94ece 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -50,7 +50,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply if err := tokenverify.CheckAccessV3(ctx, req.FromUserID); err != nil { return nil, err } - if err := callbackBeforeAddFriendV1(ctx, req); err != nil { + if err := CallbackBeforeAddFriend(ctx, req); err != nil { return nil, err } if req.ToUserID == req.FromUserID { diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index 47fe90da4..1ffe44193 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -44,7 +44,7 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) ( }) } resp := &callbackstruct.CallbackBeforeCreateGroupResp{} - err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeCreateGroup) + err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeCreateGroup) if err != nil { return err } @@ -79,7 +79,7 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, groupMember *relation.Gr GroupEx: groupEx, } resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{} - err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeMemberJoinGroup) + err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeMemberJoinGroup) if err != nil { return err } @@ -119,7 +119,7 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe callbackReq.Ex = &req.Ex.Value } resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{} - err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo) + err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo) if err != nil { return err } diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index 96f97137e..f8660e7e1 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -46,7 +46,7 @@ func CallbackBeforeSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) er RecvID: msg.MsgData.RecvID, } resp := &cbapi.CallbackBeforeSendSingleMsgResp{} - return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg) + return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg) } func CallbackAfterSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) error { @@ -58,7 +58,7 @@ func CallbackAfterSendSingleMsg(ctx context.Context, msg *pbChat.SendMsgReq) err RecvID: msg.MsgData.RecvID, } resp := &cbapi.CallbackAfterSendSingleMsgResp{} - return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendSingleMsg) + return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendSingleMsg) } func CallbackBeforeSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) error { @@ -70,7 +70,7 @@ func CallbackBeforeSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) err GroupID: msg.MsgData.GroupID, } resp := &cbapi.CallbackBeforeSendGroupMsgResp{} - return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendSingleMsg) + return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendSingleMsg) } func CallbackAfterSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) error { @@ -82,7 +82,7 @@ func CallbackAfterSendGroupMsg(ctx context.Context, msg *pbChat.SendMsgReq) erro GroupID: msg.MsgData.GroupID, } resp := &cbapi.CallbackAfterSendGroupMsgResp{} - return http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg) + return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg) } func CallbackMsgModify(ctx context.Context, msg *pbChat.SendMsgReq) error { @@ -93,7 +93,7 @@ func CallbackMsgModify(ctx context.Context, msg *pbChat.SendMsgReq) error { CommonCallbackReq: toCommonCallback(ctx, msg, constant.CallbackMsgModifyCommand), } resp := &cbapi.CallbackMsgModifyCommandResp{} - if err := http.CallBackPostReturnV2(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg); err != nil { + if err := http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg); err != nil { return err } if resp.Content != nil { diff --git a/internal/rpc/msg/extend_msg_callback.go b/internal/rpc/msg/extend_msg_callback.go index 949e30c3f..f9876ee1d 100644 --- a/internal/rpc/msg/extend_msg_callback.go +++ b/internal/rpc/msg/extend_msg_callback.go @@ -1,21 +1,23 @@ package msg import ( - cb "Open_IM/pkg/callbackstruct" + cbapi "Open_IM/pkg/callbackstruct" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" "Open_IM/pkg/common/log" + "Open_IM/pkg/common/tracelog" "Open_IM/pkg/proto/msg" "Open_IM/pkg/utils" - http2 "net/http" + "context" ) -func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensionsReq) *cb.CallbackBeforeSetMessageReactionExtResp { - callbackResp := cb.CommonCallbackResp{OperationID: setReq.OperationID} - log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) - req := cb.CallbackBeforeSetMessageReactionExtReq{ - OperationID: setReq.OperationID, +func CallbackSetMessageReactionExtensions(ctx context.Context, setReq *msg.SetMessageReactionExtensionsReq) error { + if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable { + return nil + } + req := &cbapi.CallbackBeforeSetMessageReactionExtReq{ + OperationID: tracelog.GetOperationID(ctx), CallbackCommand: constant.CallbackBeforeSetMessageReactionExtensionCommand, SourceID: setReq.SourceID, OpUserID: setReq.OpUserID, @@ -26,20 +28,15 @@ func callbackSetMessageReactionExtensions(setReq *msg.SetMessageReactionExtensio IsExternalExtensions: setReq.IsExternalExtensions, MsgFirstModifyTime: setReq.MsgFirstModifyTime, } - resp := &cb.CallbackBeforeSetMessageReactionExtResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetMessageReactionExtensionCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return resp - + resp := &cbapi.CallbackBeforeSetMessageReactionExtResp{} + return http.CallBackPostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg) } -func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReactionExtensionsReq) *cb.CallbackDeleteMessageReactionExtResp { - callbackResp := cb.CommonCallbackResp{OperationID: setReq.OperationID} - log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) - req := cbApi.CallbackDeleteMessageReactionExtReq{ +func CallbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReactionExtensionsReq) error { + if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable { + return nil + } + req := &cbapi.CallbackDeleteMessageReactionExtReq{ OperationID: setReq.OperationID, CallbackCommand: constant.CallbackBeforeDeleteMessageReactionExtensionsCommand, SourceID: setReq.SourceID, @@ -50,55 +47,53 @@ func callbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessageListReacti IsExternalExtensions: setReq.IsExternalExtensions, MsgFirstModifyTime: setReq.MsgFirstModifyTime, } - resp := &cbApi.CallbackDeleteMessageReactionExtResp{CommonCallbackResp: &callbackResp} + resp := &cbapi.CallbackDeleteMessageReactionExtResp{} defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeDeleteMessageReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return resp + return http.CallBackPostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg) } -func callbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) *cb.CallbackGetMessageListReactionExtResp { - callbackResp := cb.CommonCallbackResp{OperationID: getReq.OperationID} - log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), getReq.String()) - req := cbApi.CallbackGetMessageListReactionExtReq{ - OperationID: getReq.OperationID, - CallbackCommand: constant.CallbackGetMessageListReactionExtensionsCommand, - SourceID: getReq.SourceID, - OpUserID: getReq.OpUserID, - SessionType: getReq.SessionType, - TypeKeyList: getReq.TypeKeyList, - MessageKeyList: getReq.MessageReactionKeyList, - } - resp := &cbApi.CallbackGetMessageListReactionExtResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), req, *resp) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackGetMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return resp -} -func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensionsReq) *cb.CallbackAddMessageReactionExtResp { - callbackResp := cb.CommonCallbackResp{OperationID: setReq.OperationID} - log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) - req := cbApi.CallbackAddMessageReactionExtReq{ - OperationID: setReq.OperationID, - CallbackCommand: constant.CallbackAddMessageListReactionExtensionsCommand, - SourceID: setReq.SourceID, - OpUserID: setReq.OpUserID, - SessionType: setReq.SessionType, - ReactionExtensionList: setReq.ReactionExtensionList, - ClientMsgID: setReq.ClientMsgID, - IsReact: setReq.IsReact, - IsExternalExtensions: setReq.IsExternalExtensions, - MsgFirstModifyTime: setReq.MsgFirstModifyTime, - } - resp := &cb.CallbackAddMessageReactionExtResp{CommonCallbackResp: &callbackResp} - defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp, *resp.CommonCallbackResp, resp.IsReact, resp.MsgFirstModifyTime) - if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAddMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { - callbackResp.ErrCode = http2.StatusInternalServerError - callbackResp.ErrMsg = err.Error() - } - return resp -} +//func CallbackGetMessageListReactionExtensions(getReq *msg.GetMessageListReactionExtensionsReq) error { +// if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable { +// return nil +// } +// req := cbapi.CallbackGetMessageListReactionExtReq{ +// OperationID: getReq.OperationID, +// CallbackCommand: constant.CallbackGetMessageListReactionExtensionsCommand, +// SourceID: getReq.SourceID, +// OpUserID: getReq.OpUserID, +// SessionType: getReq.SessionType, +// TypeKeyList: getReq.TypeKeyList, +// MessageKeyList: getReq.MessageReactionKeyList, +// } +// resp := &cbApi.CallbackGetMessageListReactionExtResp{CommonCallbackResp: &callbackResp} +// defer log.NewDebug(getReq.OperationID, utils.GetSelfFuncName(), req, *resp) +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackGetMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// } +// return resp +//} +//func callbackAddMessageReactionExtensions(setReq *msg.AddMessageReactionExtensionsReq) *cb.CallbackAddMessageReactionExtResp { +// callbackResp := cbapi.CommonCallbackResp{OperationID: setReq.OperationID} +// log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), setReq.String()) +// req := cbapi.CallbackAddMessageReactionExtReq{ +// OperationID: setReq.OperationID, +// CallbackCommand: constant.CallbackAddMessageListReactionExtensionsCommand, +// SourceID: setReq.SourceID, +// OpUserID: setReq.OpUserID, +// SessionType: setReq.SessionType, +// ReactionExtensionList: setReq.ReactionExtensionList, +// ClientMsgID: setReq.ClientMsgID, +// IsReact: setReq.IsReact, +// IsExternalExtensions: setReq.IsExternalExtensions, +// MsgFirstModifyTime: setReq.MsgFirstModifyTime, +// } +// resp := &cbapi.CallbackAddMessageReactionExtResp{CommonCallbackResp: &callbackResp} +// defer log.NewDebug(setReq.OperationID, utils.GetSelfFuncName(), req, *resp, *resp.CommonCallbackResp, resp.IsReact, resp.MsgFirstModifyTime) +// if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAddMessageListReactionExtensionsCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { +// callbackResp.ErrCode = http2.StatusInternalServerError +// callbackResp.ErrMsg = err.Error() +// } +// return resp +// +//} diff --git a/pkg/callbackstruct/common.go b/pkg/callbackstruct/common.go index 098dc8135..d7d590bd1 100644 --- a/pkg/callbackstruct/common.go +++ b/pkg/callbackstruct/common.go @@ -56,10 +56,14 @@ func (c CommonCallbackResp) Parse() error { type UserStatusBaseCallback struct { CallbackCommand string `json:"callbackCommand"` OperationID string `json:"operationID"` - PlatformID int32 `json:"platformID"` + PlatformID int `json:"platformID"` Platform string `json:"platform"` } +func (c UserStatusBaseCallback) GetCallbackCommand() string { + return c.CallbackCommand +} + type UserStatusCallbackReq struct { UserStatusBaseCallback UserID string `json:"userID"` diff --git a/pkg/callbackstruct/friend.go b/pkg/callbackstruct/friend.go index 9967707f3..ebb661a18 100644 --- a/pkg/callbackstruct/friend.go +++ b/pkg/callbackstruct/friend.go @@ -1,7 +1,7 @@ package callbackstruct type CallbackBeforeAddFriendReq struct { - CallbackCommand string `json:"callbackCommand"` + CallbackCommand `json:"callbackCommand"` FromUserID string `json:"fromUserID" ` ToUserID string `json:"toUserID"` ReqMsg string `json:"reqMsg"` diff --git a/pkg/callbackstruct/message.go b/pkg/callbackstruct/message.go index 39276cdb1..ce8d72629 100644 --- a/pkg/callbackstruct/message.go +++ b/pkg/callbackstruct/message.go @@ -67,8 +67,8 @@ type CallbackMsgModifyCommandResp struct { Ex *string `json:"ex"` } type CallbackBeforeSetMessageReactionExtReq struct { - OperationID string `json:"operationID"` - CallbackCommand string `json:"callbackCommand"` + OperationID string `json:"operationID"` + CallbackCommand `json:"callbackCommand"` SourceID string `json:"sourceID"` OpUserID string `json:"opUserID"` SessionType int32 `json:"sessionType"` @@ -84,8 +84,8 @@ type CallbackBeforeSetMessageReactionExtResp struct { MsgFirstModifyTime int64 `json:"msgFirstModifyTime"` } type CallbackDeleteMessageReactionExtReq struct { + CallbackCommand `json:"callbackCommand"` OperationID string `json:"operationID"` - CallbackCommand string `json:"callbackCommand"` SourceID string `json:"sourceID"` OpUserID string `json:"opUserID"` SessionType int32 `json:"sessionType"` diff --git a/pkg/callbackstruct/msg_gateway.go b/pkg/callbackstruct/msg_gateway.go index 34bb14e69..48605e791 100644 --- a/pkg/callbackstruct/msg_gateway.go +++ b/pkg/callbackstruct/msg_gateway.go @@ -2,8 +2,8 @@ package callbackstruct type CallbackUserOnlineReq struct { UserStatusCallbackReq - Token string `json:"token"` - Seq int `json:"seq"` + //Token string `json:"token"` + Seq int64 `json:"seq"` IsAppBackground bool `json:"isAppBackground"` ConnID string `json:"connID"` } @@ -14,7 +14,7 @@ type CallbackUserOnlineResp struct { type CallbackUserOfflineReq struct { UserStatusCallbackReq - Seq int `json:"seq"` + Seq int64 `json:"seq"` ConnID string `json:"connID"` } @@ -24,7 +24,7 @@ type CallbackUserOfflineResp struct { type CallbackUserKickOffReq struct { UserStatusCallbackReq - Seq int `json:"seq"` + Seq int64 `json:"seq"` } type CallbackUserKickOffResp struct { diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index 7c8395d61..16e93a328 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -59,7 +59,7 @@ func Post(url string, data interface{}, timeOutSecond int) (content []byte, err return result, nil } -func CallBackPostReturn(url, callbackCommand string, input interface{}, output cbapi.CallbackResp, callbackConfig config.CallBackConfig) error { +func callBackPostReturn(url, callbackCommand string, input interface{}, output cbapi.CallbackResp, callbackConfig config.CallBackConfig) error { v := urlLib.Values{} v.Set("callbackCommand", callbackCommand) url = url + "?" + v.Encode() @@ -79,6 +79,6 @@ func CallBackPostReturn(url, callbackCommand string, input interface{}, output c return output.Parse() } -func CallBackPostReturnV2(url string, req cbapi.CallbackReq, resp cbapi.CallbackResp, callbackConfig config.CallBackConfig) error { - return CallBackPostReturn(url, req.GetCallbackCommand(), req, resp, callbackConfig) +func CallBackPostReturn(url string, req cbapi.CallbackReq, resp cbapi.CallbackResp, callbackConfig config.CallBackConfig) error { + return callBackPostReturn(url, req.GetCallbackCommand(), req, resp, callbackConfig) }