diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index a088e7788..48154c8e0 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -18,7 +18,6 @@ import ( cp "Open_IM/internal/utils" "Open_IM/pkg/getcdv3" - pbCache "Open_IM/pkg/proto/cache" pbConversation "Open_IM/pkg/proto/conversation" pbGroup "Open_IM/pkg/proto/group" open_im_sdk "Open_IM/pkg/proto/sdk_ws" @@ -226,47 +225,41 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJoinedGroupListReq) (*pbGroup.GetJoinedGroupListResp, error) { resp := &pbGroup.GetJoinedGroupListResp{} - if err := token_verify.CheckAccessV3(ctx, req.FromUserID); err != nil { return nil, err } - joinedGroupList, err := rocksCache.GetJoinedGroupIDListFromCache(ctx, req.FromUserID) + groups, err := s.GroupInterface.GetJoinedGroupList(ctx, req.FromUserID) if err != nil { return nil, err } - for _, groupID := range joinedGroupList { + if len(groups) == 0 { + return resp, nil + } + var groupIDs []string + for _, group := range groups { + groupIDs = append(groupIDs, group.GroupID) + } + groupMemberNum, err := s.GroupInterface.GetGroupMemberNum(ctx, groupIDs) + if err != nil { + return nil, err + } + groupOwnerUserID, err := s.GroupInterface.GetGroupOwnerUserID(ctx, groupIDs) + if err != nil { + return nil, err + } + for _, group := range groups { + if group.Status == constant.GroupStatusDismissed || group.GroupType == constant.SuperGroup { + continue + } var groupNode open_im_sdk.GroupInfo - num, err := rocksCache.GetGroupMemberNumFromCache(ctx, groupID) - if err != nil { - log.NewError(tools.OperationID(ctx), utils.GetSelfFuncName(), err.Error(), groupID) - continue - } - owner, err := (*relation.GroupMember)(nil).TakeOwnerInfo(ctx, groupID) - //owner, err2 := relation.GetGroupOwnerInfoByGroupID(groupID) - if err != nil { - continue - } - group, err := rocksCache.GetGroupInfoFromCache(ctx, groupID) - if err != nil { - continue - } - if group.GroupType == constant.SuperGroup { - continue - } - if group.Status == constant.GroupStatusDismissed { - continue - } utils.CopyStructFields(&groupNode, group) - groupNode.CreateTime = uint32(group.CreateTime.Unix()) - groupNode.NotificationUpdateTime = uint32(group.NotificationUpdateTime.Unix()) - if group.NotificationUpdateTime.Unix() < 0 { - groupNode.NotificationUpdateTime = 0 - } - - groupNode.MemberCount = uint32(num) - groupNode.OwnerUserID = owner.UserID + groupNode.MemberCount = uint32(groupMemberNum[group.GroupID]) + groupNode.OwnerUserID = groupOwnerUserID[group.GroupID] + groupNode.CreateTime = group.CreateTime.UnixMilli() + groupNode.NotificationUpdateTime = group.NotificationUpdateTime.UnixMilli() resp.GroupList = append(resp.GroupList, &groupNode) } + resp.Total = uint32(len(resp.GroupList)) return resp, nil } diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index 293cbf85a..56358db17 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -17,7 +17,9 @@ type GroupInterface interface { CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error DeleteGroupByIDs(ctx context.Context, groupIDs []string) error TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) - + GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error) + GetGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) + GetGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) //mongo CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) @@ -56,10 +58,16 @@ func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, return g.database.CreateSuperGroup(ctx, groupID, initMemberIDList) } +func (g *GroupController) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error) { + return g.database.GetJoinedGroupList(ctx, userID) +} + type DataBase interface { FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) CreateGroup(ctx context.Context, groups []*relation.Group, groupMember []*relation.GroupMember) error DeleteGroupByIDs(ctx context.Context, groupIDs []string) error + GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error) + TakeGroupByID(ctx context.Context, groupID string) (group *relation.Group, err error) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error @@ -146,6 +154,11 @@ func (g *GroupDataBase) Update(ctx context.Context, groups []*relation.Group) er }) } +func (g *GroupDataBase) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation.Group, error) { + + return nil, nil +} + func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error { sess, err := g.mongoDB.MgoClient.StartSession() if err != nil { diff --git a/pkg/common/token_verify/jwt_token.go b/pkg/common/token_verify/jwt_token.go index 0b40012a8..be0b5f217 100644 --- a/pkg/common/token_verify/jwt_token.go +++ b/pkg/common/token_verify/jwt_token.go @@ -159,15 +159,15 @@ func CheckAccess(ctx context.Context, OpUserID string, OwnerUserID string) bool return false } -func CheckAccessV3(ctx context.Context, OwnerUserID string) (err error) { +func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) { opUserID := tools.OpUserID(ctx) defer func() { - trace_log.SetCtxInfo(ctx, utils.GetFuncName(1), err, "OpUserID", opUserID, "OwnerUserID", OwnerUserID) + trace_log.SetCtxInfo(ctx, utils.GetFuncName(1), err, "OpUserID", opUserID, "ownerUserID", ownerUserID) }() if utils.IsContain(opUserID, config.Config.Manager.AppManagerUid) { return nil } - if opUserID == OwnerUserID { + if opUserID == ownerUserID { return nil } return constant.ErrIdentity.Wrap(utils.GetSelfFuncName()) diff --git a/pkg/proto/sdk_ws/ws.pb.go b/pkg/proto/sdk_ws/ws.pb.go index 0ad75caa8..47151de67 100644 --- a/pkg/proto/sdk_ws/ws.pb.go +++ b/pkg/proto/sdk_ws/ws.pb.go @@ -81,7 +81,7 @@ type GroupInfo struct { Introduction string `protobuf:"bytes,4,opt,name=introduction" json:"introduction,omitempty"` FaceURL string `protobuf:"bytes,5,opt,name=faceURL" json:"faceURL,omitempty"` OwnerUserID string `protobuf:"bytes,6,opt,name=ownerUserID" json:"ownerUserID,omitempty"` - CreateTime uint32 `protobuf:"varint,7,opt,name=createTime" json:"createTime,omitempty"` + CreateTime int64 `protobuf:"varint,7,opt,name=createTime" json:"createTime,omitempty"` MemberCount uint32 `protobuf:"varint,8,opt,name=memberCount" json:"memberCount,omitempty"` Ex string `protobuf:"bytes,9,opt,name=ex" json:"ex,omitempty"` Status int32 `protobuf:"varint,10,opt,name=status" json:"status,omitempty"` @@ -90,7 +90,7 @@ type GroupInfo struct { NeedVerification int32 `protobuf:"varint,13,opt,name=needVerification" json:"needVerification,omitempty"` LookMemberInfo int32 `protobuf:"varint,14,opt,name=lookMemberInfo" json:"lookMemberInfo,omitempty"` ApplyMemberFriend int32 `protobuf:"varint,15,opt,name=applyMemberFriend" json:"applyMemberFriend,omitempty"` - NotificationUpdateTime uint32 `protobuf:"varint,16,opt,name=notificationUpdateTime" json:"notificationUpdateTime,omitempty"` + NotificationUpdateTime int64 `protobuf:"varint,16,opt,name=notificationUpdateTime" json:"notificationUpdateTime,omitempty"` NotificationUserID string `protobuf:"bytes,17,opt,name=notificationUserID" json:"notificationUserID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` diff --git a/pkg/proto/sdk_ws/ws.proto b/pkg/proto/sdk_ws/ws.proto index 422ad3b02..e86454cb1 100644 --- a/pkg/proto/sdk_ws/ws.proto +++ b/pkg/proto/sdk_ws/ws.proto @@ -13,16 +13,16 @@ message GroupInfo{ string introduction = 4; string faceURL = 5; string ownerUserID = 6; - uint32 createTime = 7; + int64 createTime = 7; uint32 memberCount = 8; string ex = 9; int32 status = 10; string creatorUserID = 11; int32 groupType = 12; int32 needVerification = 13; - int32 lookMemberInfo =14; + int32 lookMemberInfo = 14; int32 applyMemberFriend = 15; - uint32 notificationUpdateTime = 16; + int64 notificationUpdateTime = 16; string notificationUserID = 17; } @@ -33,9 +33,9 @@ message GroupInfoForSet{ string introduction = 4; string faceURL = 5; string ex = 6; - google.protobuf.Int32Value needVerification = 7; - google.protobuf.Int32Value lookMemberInfo = 8; - google.protobuf.Int32Value applyMemberFriend = 9; + google.protobuf.Int32Value needVerification = 7; + google.protobuf.Int32Value lookMemberInfo = 8; + google.protobuf.Int32Value applyMemberFriend = 9; } @@ -43,14 +43,14 @@ message GroupMemberFullInfo { string groupID = 1 ; string userID = 2 ; int32 roleLevel = 3; - int32 joinTime = 4; + int64 joinTime = 4; string nickname = 5; string faceURL = 6; int32 appMangerLevel = 7; //if >0 int32 joinSource = 8; string operatorUserID = 9; string ex = 10; - uint32 muteEndTime = 11; + int64 muteEndTime = 11; string inviterUserID = 12; } @@ -71,7 +71,7 @@ message UserInfo{ uint32 birth = 6; string email = 7; string ex = 8; - uint32 createTime = 9; + int64 createTime = 9; int32 appMangerLevel = 10; int32 globalRecvMsgOpt = 11; int64 birthday = 13; @@ -80,7 +80,7 @@ message UserInfo{ message FriendInfo{ string ownerUserID = 1; string remark = 2; - uint32 createTime = 3; + int64 createTime = 3; UserInfo friendUser = 4; int32 addSource = 5; string operatorUserID = 6; @@ -89,7 +89,7 @@ message FriendInfo{ message BlackInfo{ string ownerUserID = 1; - uint32 createTime = 2; + int64 createTime = 2; PublicUserInfo blackUserInfo = 3; int32 addSource = 4; string operatorUserID = 5; @@ -102,9 +102,9 @@ message GroupRequest{ int32 handleResult = 3; string reqMsg = 4; string handleMsg = 5; - uint32 reqTime = 6; + int64 reqTime = 6; string handleUserID = 7; - uint32 handleTime = 8; + int64 handleTime = 8; string ex = 9; int32 joinSource = 10; string inviterUserID = 11; @@ -121,13 +121,76 @@ message FriendRequest{ int32 toGender = 8; int32 handleResult = 9; string reqMsg = 10; - uint32 createTime = 11; + int64 createTime = 11; string handlerUserID = 12; string handleMsg = 13; - uint32 handleTime = 14; + int64 handleTime = 14; string ex = 15; } +///////////////////////////////////organization///////////////////////////////////// + +message Department { + string departmentID = 1; + string faceURL = 2; + string name = 3; + string parentID = 4; + int32 order = 5; + int32 departmentType = 6; + int64 createTime = 7; + uint32 subDepartmentNum = 8; + uint32 memberNum = 9; + string ex = 10; +} + + + +message OrganizationUser { + string userID = 1; + string nickname = 2; + string englishName = 3; + string faceURL = 4; + int32 gender = 5; + string mobile = 6; + string telephone = 7; + uint32 birth = 8; + string email = 9; + int64 createTime = 10; + string ex = 11; + string birthStr = 12; +} + +message DepartmentMember { + string userID = 1; + string departmentID = 2; + int32 order = 3; + string position = 4; + int32 leader = 5; + int32 status = 6; + string ex = 7; +} + + +message UserDepartmentMember { + OrganizationUser organizationUser = 1; + DepartmentMember departmentMember = 2; +} + + +message UserInDepartment { + OrganizationUser organizationUser = 1; + repeated DepartmentMember departmentMemberList = 2; +} + + + + + +///////////////////////////////////organization end////////////////////////////////// + + + + ///////////////////////////////////base end///////////////////////////////////// @@ -139,12 +202,12 @@ message PullMessageBySeqListReq{ } message seqList { - repeated uint32 seqList = 1; + repeated uint32 seqList = 1; } message MsgDataList { - repeated MsgData msgDataList = 1; + repeated MsgData msgDataList = 1; } message PullMessageBySeqListResp { @@ -157,9 +220,9 @@ message PullMessageBySeqListResp { message GetMaxAndMinSeqReq { - repeated string groupIDList = 1; - string userID = 2; - string operationID =3; + repeated string groupIDList = 1; + string userID = 2; + string operationID = 3; } message MaxAndMinSeq{ uint32 maxSeq = 1; @@ -389,7 +452,7 @@ message FriendApplicationApprovedTips{ //FromUserID accept or reject ToUserID message FriendApplicationRejectedTips{ FromToUserID fromToUserID = 1; - string handleMsg = 2; + string handleMsg = 2; } @@ -426,23 +489,23 @@ message UserInfoUpdatedTips{ //////////////////////conversation///////////////////// message ConversationUpdateTips{ - string UserID = 1; - repeated string conversationIDList = 2; - int64 updateUnreadCountTime = 3; + string UserID = 1; + repeated string conversationIDList = 2; + int64 updateUnreadCountTime = 3; } message ConversationSetPrivateTips{ - string recvID = 1; - string sendID = 2; - bool isPrivate = 3; + string recvID = 1; + string sendID = 2; + bool isPrivate = 3; } ////////////////////message/////////////////////// message DeleteMessageTips{ string opUserID = 1; - string userID =2; + string userID = 2; repeated uint32 seqList = 3; } ///cms @@ -456,24 +519,24 @@ message RequestPagination { ///////////////////signal////////////// message SignalReq { oneof payload { - SignalInviteReq invite = 1; - SignalInviteInGroupReq inviteInGroup= 2; - SignalCancelReq cancel = 3; - SignalAcceptReq accept = 4; - SignalHungUpReq hungUp = 5; - SignalRejectReq reject = 6; - SignalGetRoomByGroupIDReq getRoomByGroupID = 7; + SignalInviteReq invite = 1; + SignalInviteInGroupReq inviteInGroup = 2; + SignalCancelReq cancel = 3; + SignalAcceptReq accept = 4; + SignalHungUpReq hungUp = 5; + SignalRejectReq reject = 6; + SignalGetRoomByGroupIDReq getRoomByGroupID = 7; - SignalOnRoomParticipantConnectedReq onRoomParticipantConnectedReq = 8; - SignalOnRoomParticipantDisconnectedReq onRoomParticipantDisconnectedReq = 9; - SignalGetTokenByRoomIDReq getTokenByRoomID = 10; + SignalOnRoomParticipantConnectedReq onRoomParticipantConnectedReq = 8; + SignalOnRoomParticipantDisconnectedReq onRoomParticipantDisconnectedReq = 9; + SignalGetTokenByRoomIDReq getTokenByRoomID = 10; } } message SignalResp { oneof payload { SignalInviteReply invite = 1; - SignalInviteInGroupReply inviteInGroup= 2; + SignalInviteInGroupReply inviteInGroup = 2; SignalCancelReply cancel = 3; SignalAcceptReply accept = 4; SignalHungUpReply hungUp = 5; @@ -485,30 +548,30 @@ message SignalResp { message InvitationInfo { - string inviterUserID = 1; - repeated string inviteeUserIDList = 2; - string customData = 3; - string groupID = 4; - string roomID = 5; - int32 timeout = 6; - string mediaType = 7; - int32 platformID = 8; - int32 sessionType = 9; - int32 initiateTime = 10; - repeated string busyLineUserIDList = 11; + string inviterUserID = 1; + repeated string inviteeUserIDList = 2; + string customData = 3; + string groupID = 4; + string roomID = 5; + int32 timeout = 6; + string mediaType = 7; + int32 platformID = 8; + int32 sessionType = 9; + int32 initiateTime = 10; + repeated string busyLineUserIDList = 11; } message ParticipantMetaData{ - GroupInfo groupInfo = 1; - GroupMemberFullInfo groupMemberInfo = 2; - PublicUserInfo userInfo = 3; + GroupInfo groupInfo = 1; + GroupMemberFullInfo groupMemberInfo = 2; + PublicUserInfo userInfo = 3; } message SignalInviteReq { - string opUserID = 1; - InvitationInfo invitation = 2; - OfflinePushInfo offlinePushInfo = 3; - ParticipantMetaData participant = 4; + string opUserID = 1; + InvitationInfo invitation = 2; + OfflinePushInfo offlinePushInfo = 3; + ParticipantMetaData participant = 4; } @@ -522,7 +585,7 @@ message SignalInviteReply { message SignalInviteInGroupReq { string opUserID = 1; InvitationInfo invitation = 2; - OfflinePushInfo offlinePushInfo = 3; + OfflinePushInfo offlinePushInfo = 3; ParticipantMetaData participant = 4; } @@ -536,7 +599,7 @@ message SignalInviteInGroupReply { message SignalCancelReq { string opUserID = 1; InvitationInfo invitation = 2; - OfflinePushInfo offlinePushInfo = 3; + OfflinePushInfo offlinePushInfo = 3; ParticipantMetaData participant = 4; } @@ -547,7 +610,7 @@ message SignalCancelReply { message SignalAcceptReq { string opUserID = 1; InvitationInfo invitation = 2; - OfflinePushInfo offlinePushInfo = 3; + OfflinePushInfo offlinePushInfo = 3; ParticipantMetaData participant = 4; int32 opUserPlatformID = 5; } @@ -561,7 +624,7 @@ message SignalAcceptReply { message SignalHungUpReq { string opUserID = 1; InvitationInfo invitation = 2; - OfflinePushInfo offlinePushInfo = 3; + OfflinePushInfo offlinePushInfo = 3; } message SignalHungUpReply { @@ -572,7 +635,7 @@ message SignalHungUpReply { message SignalRejectReq { string opUserID = 1; InvitationInfo invitation = 2; - OfflinePushInfo offlinePushInfo = 3; + OfflinePushInfo offlinePushInfo = 3; ParticipantMetaData participant = 4; int32 opUserPlatformID = 5; } @@ -619,10 +682,10 @@ message SignalGetTokenByRoomIDReply { message DelMsgListReq{ - string opUserID = 1; - string userID = 2; - repeated uint32 seqList = 3; - string operationID = 4; + string opUserID = 1; + string userID = 2; + repeated uint32 seqList = 3; + string operationID = 4; } message DelMsgListResp{ @@ -664,4 +727,8 @@ message KeyValue { } +message ResponsePagination { + int32 CurrentPage = 5; + int32 ShowNumber = 6; +}