mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-02 15:56:46 +08:00
1
This commit is contained in:
parent
399e1520d6
commit
cf4499e958
@ -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 = int32(len(resp.GroupList))
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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())
|
||||
|
@ -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:"-"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user