mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
# Conflicts: # go.mod # pkg/common/db/controller/user.go
This commit is contained in:
commit
ac284b696a
@ -7,7 +7,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/controller"
|
"Open_IM/pkg/common/db/controller"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/middleware"
|
"Open_IM/pkg/common/middleware"
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
@ -63,16 +63,16 @@ func NewFriendServer(port int) *friendServer {
|
|||||||
//mysql init
|
//mysql init
|
||||||
var mysql relation.Mysql
|
var mysql relation.Mysql
|
||||||
var model relation.FriendGorm
|
var model relation.FriendGorm
|
||||||
err = mysql.InitConn().AutoMigrateModel(&relation2.FriendModel{})
|
err = mysql.InitConn().AutoMigrateModel(&relationTb.FriendModel{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("db init err:" + err.Error())
|
panic("db init err:" + err.Error())
|
||||||
}
|
}
|
||||||
err = mysql.InitConn().AutoMigrateModel(&relation2.FriendRequestModel{})
|
err = mysql.InitConn().AutoMigrateModel(&relationTb.FriendRequestModel{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("db init err:" + err.Error())
|
panic("db init err:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mysql.InitConn().AutoMigrateModel(&relation2.BlackModel{})
|
err = mysql.InitConn().AutoMigrateModel(&relationTb.BlackModel{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("db init err:" + err.Error())
|
panic("db init err:" + err.Error())
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res
|
|||||||
if err := check.Access(ctx, req.ToUserID); err != nil {
|
if err := check.Access(ctx, req.ToUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
friendRequest := relation2.FriendRequestModel{FromUserID: req.FromUserID, ToUserID: req.ToUserID, HandleMsg: req.HandleMsg, HandleResult: req.HandleResult}
|
friendRequest := relationTb.FriendRequestModel{FromUserID: req.FromUserID, ToUserID: req.ToUserID, HandleMsg: req.HandleMsg, HandleResult: req.HandleResult}
|
||||||
if req.HandleResult == constant.FriendResponseAgree {
|
if req.HandleResult == constant.FriendResponseAgree {
|
||||||
err := s.AgreeFriendRequest(ctx, &friendRequest)
|
err := s.AgreeFriendRequest(ctx, &friendRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/cache"
|
"Open_IM/pkg/common/db/cache"
|
||||||
"Open_IM/pkg/common/db/controller"
|
"Open_IM/pkg/common/db/controller"
|
||||||
"Open_IM/pkg/common/db/relation"
|
relation_conn "Open_IM/pkg/common/db/relation"
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
"Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/db/unrelation"
|
"Open_IM/pkg/common/db/unrelation"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/middleware"
|
"Open_IM/pkg/common/middleware"
|
||||||
@ -38,7 +38,7 @@ type groupServer struct {
|
|||||||
rpcRegisterName string
|
rpcRegisterName string
|
||||||
etcdSchema string
|
etcdSchema string
|
||||||
etcdAddr []string
|
etcdAddr []string
|
||||||
controller.GroupInterface
|
GroupInterface controller.GroupInterface
|
||||||
|
|
||||||
etcdConn *getcdv3.EtcdConn
|
etcdConn *getcdv3.EtcdConn
|
||||||
//userRpc pbUser.UserClient
|
//userRpc pbUser.UserClient
|
||||||
@ -71,9 +71,9 @@ func NewGroupServer(port int) *groupServer {
|
|||||||
//g.conversationRpc = pbConversation.NewConversationClient(conn)
|
//g.conversationRpc = pbConversation.NewConversationClient(conn)
|
||||||
|
|
||||||
//mysql init
|
//mysql init
|
||||||
var mysql relation.Mysql
|
var mysql relation_conn.Mysql
|
||||||
var mongo unrelation.Mongo
|
var mongo unrelation.Mongo
|
||||||
var groupModel relation2.GroupModel
|
var groupModel relation.GroupModel
|
||||||
var redis cache.RedisClient
|
var redis cache.RedisClient
|
||||||
err = mysql.InitConn().AutoMigrateModel(&groupModel)
|
err = mysql.InitConn().AutoMigrateModel(&groupModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -98,7 +98,7 @@ func NewGroupServer(port int) *groupServer {
|
|||||||
}
|
}
|
||||||
var registerCenter discoveryRegistry.SvcDiscoveryRegistry = zkClient
|
var registerCenter discoveryRegistry.SvcDiscoveryRegistry = zkClient
|
||||||
conns, err := registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName)
|
conns, err := registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName)
|
||||||
g.GroupInterface = controller.NewGroupController(groupModel.DB, redis.GetClient(), mongo.GetClient())
|
g.GroupInterface = controller.NewGroupInterface(controller.NewGroupDatabase(mysql.GormConn(), redis.GetClient(), mongo.GetClient()))
|
||||||
return &g
|
return &g
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
if err := callbackBeforeCreateGroup(ctx, req); err != nil {
|
if err := callbackBeforeCreateGroup(ctx, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var groupMembers []*relation2.GroupMemberModel
|
var groupMembers []*relation.GroupMemberModel
|
||||||
group := PbToDBGroupInfo(req.GroupInfo)
|
group := PbToDBGroupInfo(req.GroupInfo)
|
||||||
group.GroupID = genGroupID(ctx, req.GroupInfo.GroupID)
|
group.GroupID = genGroupID(ctx, req.GroupInfo.GroupID)
|
||||||
joinGroup := func(userID string, roleLevel int32) error {
|
joinGroup := func(userID string, roleLevel int32) error {
|
||||||
@ -235,7 +235,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := s.GroupInterface.CreateGroup(ctx, []*relation2.GroupModel{group}, groupMembers); err != nil {
|
if err := s.GroupInterface.CreateGroup(ctx, []*relation.GroupModel{group}, groupMembers); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupInfo = DbToPbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
|
resp.GroupInfo = DbToPbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs)))
|
||||||
@ -265,7 +265,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
|||||||
if len(members) == 0 {
|
if len(members) == 0 {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupIDs := utils.Slice(members, func(e *relation2.GroupMemberModel) string {
|
groupIDs := utils.Slice(members, func(e *relation.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
|
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
|
||||||
@ -280,12 +280,12 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relation2.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relation2.GroupModel) string {
|
resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relation.GroupModel) string {
|
||||||
return group.GroupID
|
return group.GroupID
|
||||||
}), func(group *relation2.GroupModel) *open_im_sdk.GroupInfo {
|
}), func(group *relation.GroupModel) *open_im_sdk.GroupInfo {
|
||||||
return DbToPbGroupInfo(group, ownerMap[group.GroupID].UserID, uint32(groupMemberNum[group.GroupID]))
|
return DbToPbGroupInfo(group, ownerMap[group.GroupID].UserID, uint32(groupMemberNum[group.GroupID]))
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -310,7 +310,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
memberMap := utils.SliceToMap(members, func(e *relation2.GroupMemberModel) string {
|
memberMap := utils.SliceToMap(members, func(e *relation.GroupMemberModel) string {
|
||||||
return e.UserID
|
return e.UserID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(req.InvitedUserIDs, utils.Keys(memberMap)); len(ids) > 0 {
|
if ids := utils.Single(req.InvitedUserIDs, utils.Keys(memberMap)); len(ids) > 0 {
|
||||||
@ -331,9 +331,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
return nil, constant.ErrNoPermission.Wrap("not in group")
|
return nil, constant.ErrNoPermission.Wrap("not in group")
|
||||||
}
|
}
|
||||||
if !(member.RoleLevel == constant.GroupOwner || member.RoleLevel == constant.GroupAdmin) {
|
if !(member.RoleLevel == constant.GroupOwner || member.RoleLevel == constant.GroupAdmin) {
|
||||||
var requests []*relation2.GroupRequestModel
|
var requests []*relation.GroupRequestModel
|
||||||
for _, userID := range req.InvitedUserIDs {
|
for _, userID := range req.InvitedUserIDs {
|
||||||
requests = append(requests, &relation2.GroupRequestModel{
|
requests = append(requests, &relation.GroupRequestModel{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
JoinSource: constant.JoinByInvitation,
|
JoinSource: constant.JoinByInvitation,
|
||||||
@ -364,7 +364,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
opUserID := tracelog.GetOpUserID(ctx)
|
opUserID := tracelog.GetOpUserID(ctx)
|
||||||
var groupMembers []*relation2.GroupMemberModel
|
var groupMembers []*relation.GroupMemberModel
|
||||||
for _, userID := range req.InvitedUserIDs {
|
for _, userID := range req.InvitedUserIDs {
|
||||||
member := PbToDbGroupMember(userMap[userID])
|
member := PbToDbGroupMember(userMap[userID])
|
||||||
member.GroupID = req.GroupID
|
member.GroupID = req.GroupID
|
||||||
@ -398,7 +398,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relation2.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
||||||
return DbToPbGroupMembersCMSResp(e)
|
return DbToPbGroupMembersCMSResp(e)
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -411,7 +411,7 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Total = total
|
resp.Total = total
|
||||||
resp.Members = utils.Slice(members, func(e *relation2.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
||||||
return DbToPbGroupMembersCMSResp(e)
|
return DbToPbGroupMembersCMSResp(e)
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -447,7 +447,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
memberMap := make(map[string]*relation2.GroupMemberModel)
|
memberMap := make(map[string]*relation.GroupMemberModel)
|
||||||
for i, member := range members {
|
for i, member := range members {
|
||||||
memberMap[member.UserID] = members[i]
|
memberMap[member.UserID] = members[i]
|
||||||
}
|
}
|
||||||
@ -496,7 +496,7 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relation2.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
||||||
return DbToPbGroupMembersCMSResp(e)
|
return DbToPbGroupMembersCMSResp(e)
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -533,7 +533,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupMap := utils.SliceToMap(groups, func(e *relation2.GroupModel) string {
|
groupMap := utils.SliceToMap(groups, func(e *relation.GroupModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 {
|
if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 {
|
||||||
@ -547,10 +547,10 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relation2.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.GroupRequests = utils.Slice(groupRequests, func(e *relation2.GroupRequestModel) *open_im_sdk.GroupRequest {
|
resp.GroupRequests = utils.Slice(groupRequests, func(e *relation.GroupRequestModel) *open_im_sdk.GroupRequest {
|
||||||
return DbToPbGroupRequest(e, userMap[e.UserID], DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID])))
|
return DbToPbGroupRequest(e, userMap[e.UserID], DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID])))
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -573,10 +573,10 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relation2.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.GroupInfos = utils.Slice(groups, func(e *relation2.GroupModel) *open_im_sdk.GroupInfo {
|
resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *open_im_sdk.GroupInfo {
|
||||||
return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID]))
|
return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID]))
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -618,9 +618,9 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var member *relation2.GroupMemberModel
|
var member *relation.GroupMemberModel
|
||||||
if req.HandleResult == constant.GroupResponseAgree {
|
if req.HandleResult == constant.GroupResponseAgree {
|
||||||
member = &relation2.GroupMemberModel{
|
member = &relation.GroupMemberModel{
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
UserID: user.UserID,
|
UserID: user.UserID,
|
||||||
Nickname: user.Nickname,
|
Nickname: user.Nickname,
|
||||||
@ -664,7 +664,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
if group.GroupType == constant.SuperGroup {
|
if group.GroupType == constant.SuperGroup {
|
||||||
return nil, constant.ErrGroupTypeNotSupport.Wrap()
|
return nil, constant.ErrGroupTypeNotSupport.Wrap()
|
||||||
}
|
}
|
||||||
user, err := relation.GetUserByUserID(tracelog.GetOpUserID(ctx))
|
user, err := relation_conn.GetUserByUserID(tracelog.GetOpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -677,20 +677,20 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
if err := CallbackBeforeMemberJoinGroup(ctx, tracelog.GetOperationID(ctx), groupMember, group.Ex); err != nil {
|
if err := CallbackBeforeMemberJoinGroup(ctx, tracelog.GetOperationID(ctx), groupMember, group.Ex); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.GroupInterface.CreateGroup(ctx, nil, []*relation2.GroupMemberModel{groupMember}); err != nil {
|
if err := s.GroupInterface.CreateGroup(ctx, nil, []*relation.GroupMemberModel{groupMember}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx))
|
chat.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx))
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupRequest := relation2.GroupRequestModel{
|
groupRequest := relation.GroupRequestModel{
|
||||||
UserID: tracelog.GetOpUserID(ctx),
|
UserID: tracelog.GetOpUserID(ctx),
|
||||||
ReqMsg: req.ReqMessage,
|
ReqMsg: req.ReqMessage,
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
JoinSource: req.JoinSource,
|
JoinSource: req.JoinSource,
|
||||||
ReqTime: time.Now(),
|
ReqTime: time.Now(),
|
||||||
}
|
}
|
||||||
if err := s.GroupInterface.CreateGroupRequest(ctx, []*relation2.GroupRequestModel{&groupRequest}); err != nil {
|
if err := s.GroupInterface.CreateGroupRequest(ctx, []*relation.GroupRequestModel{&groupRequest}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.JoinGroupApplicationNotification(ctx, req)
|
chat.JoinGroupApplicationNotification(ctx, req)
|
||||||
@ -770,7 +770,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
memberMap := utils.SliceToMap(members, func(e *relation2.GroupMemberModel) string { return e.UserID })
|
memberMap := utils.SliceToMap(members, func(e *relation.GroupMemberModel) string { return e.UserID })
|
||||||
if ids := utils.Single([]string{req.OldOwnerUserID, req.NewOwnerUserID}, utils.Keys(memberMap)); len(ids) > 0 {
|
if ids := utils.Single([]string{req.OldOwnerUserID, req.NewOwnerUserID}, utils.Keys(memberMap)); len(ids) > 0 {
|
||||||
return nil, constant.ErrArgs.Wrap("user not in group " + strings.Join(ids, ","))
|
return nil, constant.ErrArgs.Wrap("user not in group " + strings.Join(ids, ","))
|
||||||
}
|
}
|
||||||
@ -804,26 +804,26 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans
|
|||||||
func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
||||||
resp := &pbGroup.GetGroupsResp{}
|
resp := &pbGroup.GetGroupsResp{}
|
||||||
var (
|
var (
|
||||||
groups []*relation2.GroupModel
|
groups []*relation.GroupModel
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if req.GroupID != "" {
|
if req.GroupID != "" {
|
||||||
groups, err = s.GroupInterface.FindGroup(ctx, []string{req.GroupID})
|
groups, err = s.GroupInterface.FindGroup(ctx, []string{req.GroupID})
|
||||||
resp.GroupNum = int32(len(groups))
|
resp.Total = uint32(len(groups))
|
||||||
} else {
|
} else {
|
||||||
resp.GroupNum, groups, err = s.GroupInterface.SearchGroup(ctx, req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
resp.Total, groups, err = s.GroupInterface.SearchGroup(ctx, req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupIDs := utils.Slice(groups, func(e *relation2.GroupModel) string {
|
groupIDs := utils.Slice(groups, func(e *relation.GroupModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
ownerMembers, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
ownerMembers, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relation2.GroupMemberModel) string {
|
ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relation.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(ownerMemberMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(ownerMemberMap)); len(ids) > 0 {
|
||||||
@ -833,7 +833,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Groups = utils.Slice(groups, func(group *relation2.GroupModel) *pbGroup.CMSGroup {
|
resp.Groups = utils.Slice(groups, func(group *relation.GroupModel) *pbGroup.CMSGroup {
|
||||||
member := ownerMemberMap[group.GroupID]
|
member := ownerMemberMap[group.GroupID]
|
||||||
return DbToPbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID]))
|
return DbToPbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID]))
|
||||||
})
|
})
|
||||||
@ -846,8 +846,8 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.MemberNums = total
|
resp.Total = total
|
||||||
resp.Members = utils.Slice(members, func(e *relation2.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
||||||
return DbToPbGroupMembersCMSResp(e)
|
return DbToPbGroupMembersCMSResp(e)
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -867,14 +867,14 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
|||||||
if len(requests) == 0 {
|
if len(requests) == 0 {
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupIDs := utils.Distinct(utils.Slice(requests, func(e *relation2.GroupRequestModel) string {
|
groupIDs := utils.Distinct(utils.Slice(requests, func(e *relation.GroupRequestModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
}))
|
}))
|
||||||
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
|
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
groupMap := utils.SliceToMap(groups, func(e *relation2.GroupModel) string {
|
groupMap := utils.SliceToMap(groups, func(e *relation.GroupModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 {
|
||||||
@ -884,7 +884,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ownerMap := utils.SliceToMap(owners, func(e *relation2.GroupMemberModel) string {
|
ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string {
|
||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 {
|
||||||
@ -894,7 +894,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupRequests = utils.Slice(requests, func(e *relation2.GroupRequestModel) *open_im_sdk.GroupRequest {
|
resp.GroupRequests = utils.Slice(requests, func(e *relation.GroupRequestModel) *open_im_sdk.GroupRequest {
|
||||||
return DbToPbGroupRequest(e, user, DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
|
return DbToPbGroupRequest(e, user, DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -1058,7 +1058,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupAbstractInfos = utils.Slice(groups, func(e *relation2.GroupModel) *pbGroup.GroupAbstractInfo {
|
resp.GroupAbstractInfos = utils.Slice(groups, func(e *relation.GroupModel) *pbGroup.GroupAbstractInfo {
|
||||||
userIDs := groupUserMap[e.GroupID]
|
userIDs := groupUserMap[e.GroupID]
|
||||||
utils.Sort(userIDs, true)
|
utils.Sort(userIDs, true)
|
||||||
bi := big.NewInt(0)
|
bi := big.NewInt(0)
|
||||||
@ -1077,7 +1077,7 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.Members = utils.Slice(members, func(e *relation2.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
|
||||||
return DbToPbGroupMembersCMSResp(e)
|
return DbToPbGroupMembersCMSResp(e)
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/controller"
|
"Open_IM/pkg/common/db/controller"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
promePkg "Open_IM/pkg/common/prometheus"
|
promePkg "Open_IM/pkg/common/prometheus"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
@ -195,7 +195,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = s.Update(ctx, []*relation2.UserModel{user})
|
err = s.Update(ctx, []*relationTb.UserModel{user})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
23
pkg/common/db/cache/black.go
vendored
23
pkg/common/db/cache/black.go
vendored
@ -1,8 +1,6 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/relation"
|
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
@ -17,25 +15,30 @@ const (
|
|||||||
blackExpireTime = time.Second * 60 * 60 * 12
|
blackExpireTime = time.Second * 60 * 60 * 12
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlackCache struct {
|
type BlackCache interface {
|
||||||
blackDB *relation2.BlackModel
|
//get blackIDs from cache
|
||||||
|
GetBlackIDs(ctx context.Context, userID string, fn func(ctx context.Context, userID string) ([]string, error)) (blackIDs []string, err error)
|
||||||
|
//del user's blackIDs cache, exec when a user's black list changed
|
||||||
|
DelBlackIDs(ctx context.Context, userID string) (err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type BlackCacheRedis struct {
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlackCache(rdb redis.UniversalClient, blackDB *relation.BlackGorm, options rockscache.Options) *BlackCache {
|
func NewBlackCacheRedis(rdb redis.UniversalClient, blackDB BlackCache, options rockscache.Options) *BlackCacheRedis {
|
||||||
return &BlackCache{
|
return &BlackCacheRedis{
|
||||||
blackDB: blackDB,
|
|
||||||
expireTime: blackExpireTime,
|
expireTime: blackExpireTime,
|
||||||
rcClient: rockscache.NewClient(rdb, options),
|
rcClient: rockscache.NewClient(rdb, options),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlackCache) getBlackIDsKey(ownerUserID string) string {
|
func (b *BlackCacheRedis) getBlackIDsKey(ownerUserID string) string {
|
||||||
return blackIDsKey + ownerUserID
|
return blackIDsKey + ownerUserID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlackCache) GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error) {
|
func (b *BlackCacheRedis) GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error) {
|
||||||
getBlackIDList := func() (string, error) {
|
getBlackIDList := func() (string, error) {
|
||||||
blackIDs, err := b.blackDB.GetBlackIDs(ctx, userID)
|
blackIDs, err := b.blackDB.GetBlackIDs(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -58,7 +61,7 @@ func (b *BlackCache) GetBlackIDs(ctx context.Context, userID string) (blackIDs [
|
|||||||
return blackIDs, utils.Wrap(err, "")
|
return blackIDs, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlackCache) DelBlackIDListFromCache(ctx context.Context, userID string) (err error) {
|
func (b *BlackCacheRedis) DelBlackIDs(ctx context.Context, userID string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
|
||||||
}()
|
}()
|
||||||
|
83
pkg/common/db/cache/conversation.go
vendored
83
pkg/common/db/cache/conversation.go
vendored
@ -2,7 +2,7 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
@ -13,18 +13,39 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBFun func() (string, error)
|
const (
|
||||||
|
conversationKey = "CONVERSATION:"
|
||||||
|
conversationIDsKey = "CONVERSATION_IDS:"
|
||||||
|
recvMsgOptKey = "RECV_MSG_OPT:"
|
||||||
|
superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
|
||||||
|
conversationExpireTime = time.Second * 60 * 60 * 12
|
||||||
|
)
|
||||||
|
|
||||||
type ConversationCache interface {
|
type ConversationCache interface {
|
||||||
GetUserConversationIDListFromCache(userID string, fn DBFun) ([]string, error)
|
// get user's conversationIDs from cache
|
||||||
DelUserConversationIDListFromCache(userID string) error
|
GetUserConversationIDs(ctx context.Context, userID string, fn func(ctx context.Context, userID string) ([]string, error)) ([]string, error)
|
||||||
GetConversationFromCache(ownerUserID, conversationID string, fn DBFun) (*table.ConversationModel, error)
|
// del user's conversationIDs from cache, call when a user add or reduce a conversation
|
||||||
GetConversationsFromCache(ownerUserID string, conversationIDList []string, fn DBFun) ([]*table.ConversationModel, error)
|
DelUserConversationIDs(ctx context.Context, userID string) error
|
||||||
GetUserAllConversationList(ownerUserID string, fn DBFun) ([]*table.ConversationModel, error)
|
// get one conversation from cache
|
||||||
DelConversationFromCache(ownerUserID, conversationID string) error
|
GetConversation(ctx context.Context, ownerUserID, conversationID string, fn func(ctx context.Context, ownerUserID, conversationID string) (*relationTb.ConversationModel, error)) (*relationTb.ConversationModel, error)
|
||||||
|
// get one conversation from cache
|
||||||
GetUserConversationIDs(ctx context.Context, ownerUserID string, f func(ctx context.Context, userID string) ([]string, error)) ([]string, error)
|
GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string, fn func(ctx context.Context, ownerUserID, conversationIDs []string) ([]*relationTb.ConversationModel, error)) ([]*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)
|
||||||
|
// del one conversation from cache, call when one user's conversation Info changed
|
||||||
|
DelConversation(ctx context.Context, ownerUserID, 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
|
||||||
|
DelUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) error
|
||||||
|
// get one super group recv msg but do not notification userID list
|
||||||
|
GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string, fn func(ctx context.Context, groupID string) (userIDs []string, err error)) (userIDs []string, err error)
|
||||||
|
// del one super group recv msg but do not notification userID list, call it when this list changed
|
||||||
|
DelSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) error
|
||||||
|
//GetSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) (hash uint32, err error)
|
||||||
|
//DelSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConversationRedis struct {
|
type ConversationRedis struct {
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
@ -33,27 +54,27 @@ func NewConversationRedis(rcClient *rockscache.Client) *ConversationRedis {
|
|||||||
return &ConversationRedis{rcClient: rcClient}
|
return &ConversationRedis{rcClient: rcClient}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConversationCache(rdb redis.UniversalClient, conversationDB *relation.ConversationGorm, options rockscache.Options) *ConversationCache {
|
func NewNewConversationRedis(rdb redis.UniversalClient, conversationDB *relation.ConversationGorm, options rockscache.Options) *ConversationRedis {
|
||||||
return &ConversationCache{conversationDB: conversationDB, expireTime: conversationExpireTime, rcClient: rockscache.NewClient(rdb, options)}
|
return &ConversationRedis{conversationDB: conversationDB, expireTime: conversationExpireTime, rcClient: rockscache.NewClient(rdb, options)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) getConversationKey(ownerUserID, conversationID string) string {
|
func (c *ConversationRedis) getConversationKey(ownerUserID, conversationID string) string {
|
||||||
return conversationKey + ownerUserID + ":" + conversationID
|
return conversationKey + ownerUserID + ":" + conversationID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) getConversationIDsKey(ownerUserID string) string {
|
func (c *ConversationRedis) getConversationIDsKey(ownerUserID string) string {
|
||||||
return conversationIDsKey + ownerUserID
|
return conversationIDsKey + ownerUserID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) getRecvMsgOptKey(ownerUserID, conversationID string) string {
|
func (c *ConversationRedis) getRecvMsgOptKey(ownerUserID, conversationID string) string {
|
||||||
return recvMsgOptKey + ownerUserID + ":" + conversationID
|
return recvMsgOptKey + ownerUserID + ":" + conversationID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) getSuperGroupRecvNotNotifyUserIDsKey(groupID string) string {
|
func (c *ConversationRedis) getSuperGroupRecvNotNotifyUserIDsKey(groupID string) string {
|
||||||
return superGroupRecvMsgNotNotifyUserIDsKey + groupID
|
return superGroupRecvMsgNotNotifyUserIDsKey + groupID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetUserConversationIDs(ctx context.Context, ownerUserID string, f func(ctx context.Context, userID string) ([]string, error)) (conversationIDs []string, err error) {
|
func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, ownerUserID string, f func(userID string) ([]string, error)) (conversationIDs []string, err error) {
|
||||||
//getConversationIDs := func() (string, error) {
|
//getConversationIDs := func() (string, error) {
|
||||||
// conversationIDs, err := relation.GetConversationIDsByUserID(ownerUserID)
|
// conversationIDs, err := relation.GetConversationIDsByUserID(ownerUserID)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
@ -79,7 +100,7 @@ func (c *ConversationCache) GetUserConversationIDs(ctx context.Context, ownerUse
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetUserConversationIDs1(ctx context.Context, ownerUserID string) (conversationIDs []string, err error) {
|
func (c *ConversationRedis) GetUserConversationIDs1(ctx context.Context, ownerUserID string) (conversationIDs []string, err error) {
|
||||||
//getConversationIDs := func() (string, error) {
|
//getConversationIDs := func() (string, error) {
|
||||||
// conversationIDs, err := relation.GetConversationIDsByUserID(ownerUserID)
|
// conversationIDs, err := relation.GetConversationIDsByUserID(ownerUserID)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
@ -149,14 +170,14 @@ func GetCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
|
|||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) DelUserConversationIDs(ctx context.Context, ownerUserID string) (err error) {
|
func (c *ConversationRedis) DelUserConversationIDs(ctx context.Context, ownerUserID string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationIDsKey(ownerUserID)), "DelUserConversationIDs err")
|
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationIDsKey(ownerUserID)), "DelUserConversationIDs err")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetConversation(ctx context.Context, ownerUserID, conversationID string) (conversation *relation2.ConversationModel, err error) {
|
func (c *ConversationRedis) GetConversation(ctx context.Context, ownerUserID, conversationID string) (conversation *relationTb.Conversation, err error) {
|
||||||
getConversation := func() (string, error) {
|
getConversation := func() (string, error) {
|
||||||
conversation, err := relation.GetConversation(ownerUserID, conversationID)
|
conversation, err := relation.GetConversation(ownerUserID, conversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -175,19 +196,19 @@ func (c *ConversationCache) GetConversation(ctx context.Context, ownerUserID, co
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
conversation = &relation2.ConversationModel{}
|
conversation = &relationTb.ConversationModel{}
|
||||||
err = json.Unmarshal([]byte(conversationStr), &conversation)
|
err = json.Unmarshal([]byte(conversationStr), &conversation)
|
||||||
return conversation, utils.Wrap(err, "Unmarshal failed")
|
return conversation, utils.Wrap(err, "Unmarshal failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) DelConversation(ctx context.Context, ownerUserID, conversationID string) (err error) {
|
func (c *ConversationRedis) DelConversation(ctx context.Context, ownerUserID, conversationID string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID)
|
||||||
}()
|
}()
|
||||||
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationKey(ownerUserID, conversationID)), "DelConversation err")
|
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationKey(ownerUserID, conversationID)), "DelConversation err")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []relation2.ConversationModel, err error) {
|
func (c *ConversationRedis) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []relationTb.ConversationModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs, "conversations", conversations)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs, "conversations", conversations)
|
||||||
}()
|
}()
|
||||||
@ -201,7 +222,7 @@ func (c *ConversationCache) GetConversations(ctx context.Context, ownerUserID st
|
|||||||
return conversations, nil
|
return conversations, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetUserAllConversations(ctx context.Context, ownerUserID string) (conversations []relation2.ConversationModel, err error) {
|
func (c *ConversationRedis) GetUserAllConversations(ctx context.Context, ownerUserID string) (conversations []relationTb.ConversationModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversations", conversations)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversations", conversations)
|
||||||
}()
|
}()
|
||||||
@ -209,7 +230,7 @@ func (c *ConversationCache) GetUserAllConversations(ctx context.Context, ownerUs
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var conversationIDs []relation2.ConversationModel
|
var conversationIDs []relationTb.ConversationModel
|
||||||
for _, conversationID := range IDs {
|
for _, conversationID := range IDs {
|
||||||
conversation, err := c.GetConversation(ctx, ownerUserID, conversationID)
|
conversation, err := c.GetConversation(ctx, ownerUserID, conversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -220,7 +241,7 @@ func (c *ConversationCache) GetUserAllConversations(ctx context.Context, ownerUs
|
|||||||
return conversationIDs, nil
|
return conversationIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error) {
|
func (c *ConversationRedis) GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error) {
|
||||||
getConversation := func() (string, error) {
|
getConversation := func() (string, error) {
|
||||||
conversation, err := relation.GetConversation(ownerUserID, conversationID)
|
conversation, err := relation.GetConversation(ownerUserID, conversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -238,22 +259,22 @@ func (c *ConversationCache) GetUserRecvMsgOpt(ctx context.Context, ownerUserID,
|
|||||||
return strconv.Atoi(optStr)
|
return strconv.Atoi(optStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) DelUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) error {
|
func (c *ConversationRedis) DelUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) error {
|
||||||
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationKey(ownerUserID, conversationID)), "DelUserRecvMsgOpt failed")
|
return utils.Wrap(c.rcClient.TagAsDeleted(c.getConversationKey(ownerUserID, conversationID)), "DelUserRecvMsgOpt failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (userIDs []string, err error) {
|
func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (userIDs []string, err error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) DelSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (err error) {
|
func (c *ConversationRedis) DelSuperGroupRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) GetSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) (hash uint32, err error) {
|
func (c *ConversationRedis) GetSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) (hash uint32, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) {
|
func (c *ConversationRedis) DelSuperGroupRecvMsgNotNotifyUserIDsHash(ctx context.Context, groupID string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
37
pkg/common/db/cache/friend.go
vendored
37
pkg/common/db/cache/friend.go
vendored
@ -2,7 +2,7 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
@ -19,33 +19,42 @@ const (
|
|||||||
friendKey = "FRIEND_INFO:"
|
friendKey = "FRIEND_INFO:"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FriendCache struct {
|
type FriendCache interface {
|
||||||
|
GetFriendIDs(ctx context.Context, ownerUserID string, fn func(ctx context.Context, ownerUserID string) (friendIDs []string, err error)) (friendIDs []string, err error)
|
||||||
|
// call when friendID List changed
|
||||||
|
DelFriendIDs(ctx context.Context, ownerUserID string) (err error)
|
||||||
|
GetFriend(ctx context.Context, ownerUserID, friendUserID string, fn func(ctx context.Context, ownerUserID, friendUserID string) (friend *relationTb.FriendModel, err error)) (friend *relationTb.FriendModel, err error)
|
||||||
|
// del friend when friend info changed or remove it
|
||||||
|
DelFriend(ctx context.Context, ownerUserID, friendUserID string) (err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type FriendCacheRedis struct {
|
||||||
friendDB *relation.FriendGorm
|
friendDB *relation.FriendGorm
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFriendCache(rdb redis.UniversalClient, friendDB *relation.FriendGorm, options rockscache.Options) *FriendCache {
|
func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB *relation.FriendGorm, options rockscache.Options) *FriendCacheRedis {
|
||||||
return &FriendCache{
|
return &FriendCacheRedis{
|
||||||
friendDB: friendDB,
|
friendDB: friendDB,
|
||||||
expireTime: friendExpireTime,
|
expireTime: friendExpireTime,
|
||||||
rcClient: rockscache.NewClient(rdb, options),
|
rcClient: rockscache.NewClient(rdb, options),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) getFriendIDsKey(ownerUserID string) string {
|
func (f *FriendCacheRedis) getFriendIDsKey(ownerUserID string) string {
|
||||||
return friendIDsKey + ownerUserID
|
return friendIDsKey + ownerUserID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) getTwoWayFriendsIDsKey(ownerUserID string) string {
|
func (f *FriendCacheRedis) getTwoWayFriendsIDsKey(ownerUserID string) string {
|
||||||
return TwoWayFriendsIDsKey + ownerUserID
|
return TwoWayFriendsIDsKey + ownerUserID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) getFriendKey(ownerUserID, friendUserID string) string {
|
func (f *FriendCacheRedis) getFriendKey(ownerUserID, friendUserID string) string {
|
||||||
return friendKey + ownerUserID + "-" + friendUserID
|
return friendKey + ownerUserID + "-" + friendUserID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) {
|
func (f *FriendCacheRedis) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) {
|
||||||
getFriendIDs := func() (string, error) {
|
getFriendIDs := func() (string, error) {
|
||||||
friendIDs, err := f.friendDB.GetFriendIDs(ctx, ownerUserID)
|
friendIDs, err := f.friendDB.GetFriendIDs(ctx, ownerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -68,14 +77,14 @@ func (f *FriendCache) GetFriendIDs(ctx context.Context, ownerUserID string) (fri
|
|||||||
return friendIDs, utils.Wrap(err, "")
|
return friendIDs, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) DelFriendIDs(ctx context.Context, ownerUserID string) (err error) {
|
func (f *FriendCacheRedis) DelFriendIDs(ctx context.Context, ownerUserID string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
||||||
}()
|
}()
|
||||||
return f.rcClient.TagAsDeleted(f.getFriendIDsKey(ownerUserID))
|
return f.rcClient.TagAsDeleted(f.getFriendIDsKey(ownerUserID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) GetTwoWayFriendIDs(ctx context.Context, ownerUserID string) (twoWayFriendIDs []string, err error) {
|
func (f *FriendCacheRedis) GetTwoWayFriendIDs(ctx context.Context, ownerUserID string) (twoWayFriendIDs []string, err error) {
|
||||||
friendIDs, err := f.GetFriendIDs(ctx, ownerUserID)
|
friendIDs, err := f.GetFriendIDs(ctx, ownerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -92,14 +101,14 @@ func (f *FriendCache) GetTwoWayFriendIDs(ctx context.Context, ownerUserID string
|
|||||||
return twoWayFriendIDs, nil
|
return twoWayFriendIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) DelTwoWayFriendIDs(ctx context.Context, ownerUserID string) (err error) {
|
func (f *FriendCacheRedis) DelTwoWayFriendIDs(ctx context.Context, ownerUserID string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID)
|
||||||
}()
|
}()
|
||||||
return f.rcClient.TagAsDeleted(f.getTwoWayFriendsIDsKey(ownerUserID))
|
return f.rcClient.TagAsDeleted(f.getTwoWayFriendsIDsKey(ownerUserID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relation2.FriendModel, err error) {
|
func (f *FriendCacheRedis) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relationTb.FriendModel, err error) {
|
||||||
getFriend := func() (string, error) {
|
getFriend := func() (string, error) {
|
||||||
friend, err = f.friendDB.Take(ctx, ownerUserID, friendUserID)
|
friend, err = f.friendDB.Take(ctx, ownerUserID, friendUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -115,12 +124,12 @@ func (f *FriendCache) GetFriend(ctx context.Context, ownerUserID, friendUserID s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
friend = &relation2.FriendModel{}
|
friend = &relationTb.FriendModel{}
|
||||||
err = json.Unmarshal([]byte(friendStr), friend)
|
err = json.Unmarshal([]byte(friendStr), friend)
|
||||||
return friend, utils.Wrap(err, "")
|
return friend, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendCache) DelFriend(ctx context.Context, ownerUserID, friendUserID string) (err error) {
|
func (f *FriendCacheRedis) DelFriend(ctx context.Context, ownerUserID, friendUserID string) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID)
|
||||||
}()
|
}()
|
||||||
|
21
pkg/common/db/cache/group.go
vendored
21
pkg/common/db/cache/group.go
vendored
@ -3,7 +3,7 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/db/unrelation"
|
"Open_IM/pkg/common/db/unrelation"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -28,18 +28,25 @@ const (
|
|||||||
groupMemberNumKey = "GROUP_MEMBER_NUM_CACHE:"
|
groupMemberNumKey = "GROUP_MEMBER_NUM_CACHE:"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupCache struct {
|
type GroupCache interface {
|
||||||
group relation2.GroupModelInterface
|
GetGroupsInfo(ctx context.Context, groupIDs []string, fn func(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)) (groups []*relationTb.GroupModel, err error)
|
||||||
groupMember relation2.GroupMemberModelInterface
|
DelGroupsInfo(ctx context.Context, groupID string) (err error)
|
||||||
groupRequest relation2.GroupRequestModelInterface
|
GetGroupInfo(ctx context.Context, groupID string, fn func(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)) (group *relationTb.GroupModel, err error)
|
||||||
|
DelGroupInfo(ctx context.Context, groupID string) (err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupCacheRedis struct {
|
||||||
|
group *relation.GroupGorm
|
||||||
|
groupMember *relation.GroupMemberGorm
|
||||||
|
groupRequest *relation.GroupRequestGorm
|
||||||
mongoDB *unrelation.SuperGroupMongoDriver
|
mongoDB *unrelation.SuperGroupMongoDriver
|
||||||
expireTime time.Duration
|
expireTime time.Duration
|
||||||
redisClient *RedisClient
|
redisClient *RedisClient
|
||||||
rcClient *rockscache.Client
|
rcClient *rockscache.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupCache(rdb redis.UniversalClient, groupDB relation2.GroupModelInterface, groupMemberDB relation2.GroupMemberModelInterface, groupRequestDB relation2.GroupRequestModelInterface, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCache {
|
func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB *relation.GroupGorm, groupMemberDB *relation.GroupMemberGorm, groupRequestDB *relation.GroupRequestGorm, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCacheRedis {
|
||||||
return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
|
return &GroupCacheRedis{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
|
||||||
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
|
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
|
||||||
mongoDB: mongoClient,
|
mongoDB: mongoClient,
|
||||||
}
|
}
|
||||||
|
10
pkg/common/db/cache/user.go
vendored
10
pkg/common/db/cache/user.go
vendored
@ -2,7 +2,7 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
relation2 "Open_IM/pkg/common/db/table/relation"
|
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||||
"Open_IM/pkg/common/tracelog"
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
@ -44,7 +44,7 @@ func (u *UserCache) getUserGlobalRecvMsgOptKey(userID string) string {
|
|||||||
return userGlobalRecvMsgOptKey + userID
|
return userGlobalRecvMsgOptKey + userID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserCache) GetUserInfo(ctx context.Context, userID string) (userInfo *relation2.UserModel, err error) {
|
func (u *UserCache) GetUserInfo(ctx context.Context, userID string) (userInfo *relationTb.UserModel, err error) {
|
||||||
getUserInfo := func() (string, error) {
|
getUserInfo := func() (string, error) {
|
||||||
userInfo, err := u.userDB.Take(ctx, userID)
|
userInfo, err := u.userDB.Take(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -63,13 +63,13 @@ func (u *UserCache) GetUserInfo(ctx context.Context, userID string) (userInfo *r
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
userInfo = &relation2.UserModel{}
|
userInfo = &relationTb.UserModel{}
|
||||||
err = json.Unmarshal([]byte(userInfoStr), userInfo)
|
err = json.Unmarshal([]byte(userInfoStr), userInfo)
|
||||||
return userInfo, utils.Wrap(err, "")
|
return userInfo, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserCache) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relation2.UserModel, error) {
|
func (u *UserCache) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relationTb.UserModel, error) {
|
||||||
var users []*relation2.UserModel
|
var users []*relationTb.UserModel
|
||||||
for _, userID := range userIDs {
|
for _, userID := range userIDs {
|
||||||
user, err := GetUserInfoFromCache(ctx, userID)
|
user, err := GetUserInfoFromCache(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,7 +3,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db/cache"
|
"Open_IM/pkg/common/db/cache"
|
||||||
"Open_IM/pkg/common/db/relation"
|
"Open_IM/pkg/common/db/relation"
|
||||||
"Open_IM/pkg/common/db/table"
|
relationTb "Open_IM/pkg/common/db/table/relation"
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,15 +13,15 @@ type ConversationInterface interface {
|
|||||||
//UpdateUserConversationFiled 更新用户该会话的属性信息
|
//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 创建一批新的会话
|
||||||
CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error
|
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
|
||||||
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
||||||
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error
|
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error
|
||||||
//FindConversations 根据会话ID获取某个用户的多个会话
|
//FindConversations 根据会话ID获取某个用户的多个会话
|
||||||
FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error)
|
FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error)
|
||||||
//GetUserAllConversation 获取一个用户在服务器上所有的会话
|
//GetUserAllConversation 获取一个用户在服务器上所有的会话
|
||||||
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error)
|
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error)
|
||||||
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
||||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error
|
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
||||||
}
|
}
|
||||||
type ConversationController struct {
|
type ConversationController struct {
|
||||||
database ConversationDataBaseInterface
|
database ConversationDataBaseInterface
|
||||||
@ -39,22 +39,22 @@ func (c ConversationController) UpdateUsersConversationFiled(ctx context.Context
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationController) CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error {
|
func (c ConversationController) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationController) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error {
|
func (c ConversationController) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationController) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error) {
|
func (c ConversationController) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationController) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error) {
|
func (c ConversationController) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
func (c ConversationController) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error {
|
func (c ConversationController) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,15 +66,15 @@ type ConversationDataBaseInterface interface {
|
|||||||
//UpdateUserConversationFiled 更新用户该会话的属性信息
|
//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 创建一批新的会话
|
||||||
CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error
|
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
|
||||||
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
||||||
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error
|
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error
|
||||||
//FindConversations 根据会话ID获取某个用户的多个会话
|
//FindConversations 根据会话ID获取某个用户的多个会话
|
||||||
FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error)
|
FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error)
|
||||||
//GetUserAllConversation 获取一个用户在服务器上所有的会话
|
//GetUserAllConversation 获取一个用户在服务器上所有的会话
|
||||||
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error)
|
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error)
|
||||||
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
||||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error
|
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
||||||
}
|
}
|
||||||
type ConversationDataBase struct {
|
type ConversationDataBase struct {
|
||||||
db relation.Conversation
|
db relation.Conversation
|
||||||
@ -89,23 +89,23 @@ func (c ConversationDataBase) UpdateUsersConversationFiled(ctx context.Context,
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationDataBase) CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error {
|
func (c ConversationDataBase) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationDataBase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error {
|
func (c ConversationDataBase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *relationTb.ConversationModel) error {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationDataBase) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error) {
|
func (c ConversationDataBase) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*relationTb.ConversationModel, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationDataBase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error) {
|
func (c ConversationDataBase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConversationDataBase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error {
|
func (c ConversationDataBase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,15 +23,15 @@ type GroupInterface interface {
|
|||||||
CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error
|
CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error
|
||||||
TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error)
|
TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error)
|
||||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error)
|
FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error)
|
||||||
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error)
|
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error)
|
||||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||||
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
||||||
// GroupMember
|
// GroupMember
|
||||||
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error)
|
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error)
|
||||||
TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error)
|
TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error)
|
||||||
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error)
|
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error)
|
||||||
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error)
|
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error)
|
||||||
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error)
|
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error)
|
||||||
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error
|
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error
|
||||||
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
||||||
@ -41,7 +41,7 @@ type GroupInterface interface {
|
|||||||
// GroupRequest
|
// GroupRequest
|
||||||
CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error
|
CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error
|
||||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error)
|
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error)
|
||||||
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error)
|
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error)
|
||||||
// SuperGroup
|
// SuperGroup
|
||||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error)
|
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error)
|
||||||
FindJoinSuperGroup(ctx context.Context, userID string) (superGroup *unrelation2.UserToSuperGroupModel, err error)
|
FindJoinSuperGroup(ctx context.Context, userID string) (superGroup *unrelation2.UserToSuperGroupModel, err error)
|
||||||
@ -53,6 +53,10 @@ type GroupInterface interface {
|
|||||||
|
|
||||||
var _ GroupInterface = (*GroupController)(nil)
|
var _ GroupInterface = (*GroupController)(nil)
|
||||||
|
|
||||||
|
func NewGroupInterface(database GroupDataBaseInterface) GroupInterface {
|
||||||
|
return &GroupController{database: database}
|
||||||
|
}
|
||||||
|
|
||||||
type GroupController struct {
|
type GroupController struct {
|
||||||
database GroupDataBaseInterface
|
database GroupDataBaseInterface
|
||||||
}
|
}
|
||||||
@ -69,7 +73,7 @@ func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (gro
|
|||||||
return g.database.FindGroup(ctx, groupIDs)
|
return g.database.FindGroup(ctx, groupIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupController) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) {
|
func (g *GroupController) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error) {
|
||||||
return g.database.SearchGroup(ctx, keyword, pageNumber, showNumber)
|
return g.database.SearchGroup(ctx, keyword, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,11 +97,11 @@ func (g *GroupController) FindGroupMember(ctx context.Context, groupIDs []string
|
|||||||
return g.database.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
return g.database.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupController) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) {
|
func (g *GroupController) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error) {
|
||||||
return g.database.PageGroupMember(ctx, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
return g.database.PageGroupMember(ctx, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupController) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) {
|
func (g *GroupController) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error) {
|
||||||
return g.database.SearchGroupMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
return g.database.SearchGroupMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +137,7 @@ func (g *GroupController) TakeGroupRequest(ctx context.Context, groupID string,
|
|||||||
return g.database.TakeGroupRequest(ctx, groupID, userID)
|
return g.database.TakeGroupRequest(ctx, groupID, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupController) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) {
|
func (g *GroupController) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error) {
|
||||||
return g.database.PageGroupRequestUser(ctx, userID, pageNumber, showNumber)
|
return g.database.PageGroupRequestUser(ctx, userID, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,15 +172,15 @@ type GroupDataBaseInterface interface {
|
|||||||
CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error
|
CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error
|
||||||
TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error)
|
TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error)
|
||||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error)
|
FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error)
|
||||||
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error)
|
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error)
|
||||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||||
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
||||||
// GroupMember
|
// GroupMember
|
||||||
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error)
|
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error)
|
||||||
TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error)
|
TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error)
|
||||||
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error)
|
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error)
|
||||||
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error)
|
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error)
|
||||||
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error)
|
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error)
|
||||||
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error
|
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error
|
||||||
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error)
|
||||||
@ -186,7 +190,7 @@ type GroupDataBaseInterface interface {
|
|||||||
// GroupRequest
|
// GroupRequest
|
||||||
CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error
|
CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error
|
||||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error)
|
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error)
|
||||||
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error)
|
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error)
|
||||||
// SuperGroup
|
// SuperGroup
|
||||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error)
|
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error)
|
||||||
FindJoinSuperGroup(ctx context.Context, userID string) (*unrelation2.UserToSuperGroupModel, error)
|
FindJoinSuperGroup(ctx context.Context, userID string) (*unrelation2.UserToSuperGroupModel, error)
|
||||||
@ -196,7 +200,7 @@ type GroupDataBaseInterface interface {
|
|||||||
CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupDataBaseInterface {
|
func NewGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupDataBaseInterface {
|
||||||
groupDB := relation.NewGroupDB(db)
|
groupDB := relation.NewGroupDB(db)
|
||||||
groupMemberDB := relation.NewGroupMemberDB(db)
|
groupMemberDB := relation.NewGroupMemberDB(db)
|
||||||
groupRequestDB := relation.NewGroupRequest(db)
|
groupRequestDB := relation.NewGroupRequest(db)
|
||||||
@ -256,7 +260,7 @@ func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (group
|
|||||||
return g.groupDB.Find(ctx, groupIDs)
|
return g.groupDB.Find(ctx, groupIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) {
|
func (g *GroupDataBase) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error) {
|
||||||
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
|
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,11 +289,11 @@ func (g *GroupDataBase) FindGroupMember(ctx context.Context, groupIDs []string,
|
|||||||
return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels)
|
return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) {
|
func (g *GroupDataBase) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error) {
|
||||||
return g.groupMemberDB.SearchMember(ctx, "", groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
return g.groupMemberDB.SearchMember(ctx, "", groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) {
|
func (g *GroupDataBase) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relation2.GroupMemberModel, error) {
|
||||||
return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +353,7 @@ func (g *GroupDataBase) TakeGroupRequest(ctx context.Context, groupID string, us
|
|||||||
return g.groupRequestDB.Take(ctx, groupID, userID)
|
return g.groupRequestDB.Take(ctx, groupID, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) {
|
func (g *GroupDataBase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error) {
|
||||||
return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber)
|
return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package localcache
|
package localcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
discoveryRegistry "Open_IM/pkg/discovery_registry"
|
||||||
"context"
|
"context"
|
||||||
"github.com/OpenIMSDK/openKeeper"
|
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,16 +13,17 @@ type ConversationLocalCacheInterface interface {
|
|||||||
type ConversationLocalCache struct {
|
type ConversationLocalCache struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
SuperGroupRecvMsgNotNotifyUserIDs map[string][]string
|
SuperGroupRecvMsgNotNotifyUserIDs map[string][]string
|
||||||
zkClient *openKeeper.ZkClient
|
client discoveryRegistry.SvcDiscoveryRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConversationLocalCache(zkClient *openKeeper.ZkClient) ConversationLocalCache {
|
func NewConversationLocalCache(client discoveryRegistry.SvcDiscoveryRegistry) ConversationLocalCache {
|
||||||
return ConversationLocalCache{
|
return ConversationLocalCache{
|
||||||
SuperGroupRecvMsgNotNotifyUserIDs: make(map[string][]string, 0),
|
SuperGroupRecvMsgNotNotifyUserIDs: make(map[string][]string, 0),
|
||||||
zkClient: zkClient,
|
client: client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *ConversationLocalCache) GetRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) []string {
|
func (g *ConversationLocalCache) GetRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) []string {
|
||||||
|
g.client.GetConn()
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,9 @@ package localcache
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
discoveryRegistry "Open_IM/pkg/discovery_registry"
|
||||||
"Open_IM/pkg/proto/group"
|
"Open_IM/pkg/proto/group"
|
||||||
"context"
|
"context"
|
||||||
"github.com/OpenIMSDK/openKeeper"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,9 +14,9 @@ type GroupLocalCacheInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GroupLocalCache struct {
|
type GroupLocalCache struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
cache map[string]GroupMemberIDsHash
|
cache map[string]GroupMemberIDsHash
|
||||||
zkClient *openKeeper.ZkClient
|
client discoveryRegistry.SvcDiscoveryRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupMemberIDsHash struct {
|
type GroupMemberIDsHash struct {
|
||||||
@ -25,17 +24,17 @@ type GroupMemberIDsHash struct {
|
|||||||
userIDs []string
|
userIDs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupMemberIDsLocalCache(zkClient *openKeeper.ZkClient) GroupLocalCache {
|
func NewGroupMemberIDsLocalCache(client discoveryRegistry.SvcDiscoveryRegistry) GroupLocalCache {
|
||||||
return GroupLocalCache{
|
return GroupLocalCache{
|
||||||
cache: make(map[string]GroupMemberIDsHash, 0),
|
cache: make(map[string]GroupMemberIDsHash, 0),
|
||||||
zkClient: zkClient,
|
client: client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupLocalCache) GetGroupMemberIDs(ctx context.Context, groupID string) ([]string, error) {
|
func (g *GroupLocalCache) GetGroupMemberIDs(ctx context.Context, groupID string) ([]string, error) {
|
||||||
g.lock.Lock()
|
g.lock.Lock()
|
||||||
defer g.lock.Unlock()
|
defer g.lock.Unlock()
|
||||||
conn, err := g.zkClient.GetConn(config.Config.RpcRegisterName.OpenImGroupName, nil)
|
conn, err := g.client.GetConn(config.Config.RpcRegisterName.OpenImGroupName, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ func (g *GroupMemberGorm) TakeOwner(ctx context.Context, groupID string, tx ...a
|
|||||||
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "")
|
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupMemberGorm) SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...any) (total int32, groupList []*relation.GroupMemberModel, err error) {
|
func (g *GroupMemberGorm) SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...any) (total uint32, groupList []*relation.GroupMemberModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "groupIDs", groupIDs, "userIDs", userIDs, "roleLevels", roleLevels, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "groupIDs", groupIDs, "userIDs", userIDs, "roleLevels", roleLevels, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList)
|
||||||
}()
|
}()
|
||||||
|
@ -61,7 +61,7 @@ func (g *GroupGorm) Take(ctx context.Context, groupID string, tx ...any) (group
|
|||||||
return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "")
|
return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32, tx ...any) (total int32, groups []*relation.GroupModel, err error) {
|
func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32, tx ...any) (total uint32, groups []*relation.GroupModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups)
|
||||||
}()
|
}()
|
||||||
|
@ -77,7 +77,7 @@ func (g *GroupRequestGorm) Take(ctx context.Context, groupID string, userID stri
|
|||||||
return groupRequest, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error, utils.GetSelfFuncName())
|
return groupRequest, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error, utils.GetSelfFuncName())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupRequestGorm) Page(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...any) (total int32, groups []*relation.GroupRequestModel, err error) {
|
func (g *GroupRequestGorm) Page(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...any) (total uint32, groups []*relation.GroupRequestModel, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups)
|
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups)
|
||||||
}()
|
}()
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (int32, []*E, error) {
|
func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (uint32, []*E, error) {
|
||||||
var count int64
|
var count int64
|
||||||
if err := db.Model(new(E)).Count(&count).Error; err != nil {
|
if err := db.Model(new(E)).Count(&count).Error; err != nil {
|
||||||
return 0, nil, utils.Wrap(err, "")
|
return 0, nil, utils.Wrap(err, "")
|
||||||
@ -14,10 +14,10 @@ func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (int32, []*E, er
|
|||||||
if err := db.Limit(int(showNumber)).Offset(int(pageNumber * showNumber)).Find(&es).Error; err != nil {
|
if err := db.Limit(int(showNumber)).Offset(int(pageNumber * showNumber)).Find(&es).Error; err != nil {
|
||||||
return 0, nil, utils.Wrap(err, "")
|
return 0, nil, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
return int32(count), es, nil
|
return uint32(count), es, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func gormSearch[E any](db *gorm.DB, fields []string, value string, pageNumber, showNumber int32) (int32, []*E, error) {
|
func gormSearch[E any](db *gorm.DB, fields []string, value string, pageNumber, showNumber int32) (uint32, []*E, error) {
|
||||||
if len(fields) > 0 && value != "" {
|
if len(fields) > 0 && value != "" {
|
||||||
value = "%" + value + "%"
|
value = "%" + value + "%"
|
||||||
if len(fields) == 1 {
|
if len(fields) == 1 {
|
||||||
|
@ -38,5 +38,5 @@ type GroupModelInterface interface {
|
|||||||
UpdateStatus(ctx context.Context, groupID string, status int32, tx ...any) (err error)
|
UpdateStatus(ctx context.Context, groupID string, status int32, tx ...any) (err error)
|
||||||
Find(ctx context.Context, groupIDs []string, tx ...any) (groups []*GroupModel, err error)
|
Find(ctx context.Context, groupIDs []string, tx ...any) (groups []*GroupModel, err error)
|
||||||
Take(ctx context.Context, groupID string, tx ...any) (group *GroupModel, err error)
|
Take(ctx context.Context, groupID string, tx ...any) (group *GroupModel, err error)
|
||||||
Search(ctx context.Context, keyword string, pageNumber, showNumber int32, tx ...any) (total int32, groups []*GroupModel, err error)
|
Search(ctx context.Context, keyword string, pageNumber, showNumber int32, tx ...any) (total uint32, groups []*GroupModel, err error)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ type GroupMemberModelInterface interface {
|
|||||||
//FindGroupUser(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...any) (groupList []*GroupMemberModel, err error)
|
//FindGroupUser(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...any) (groupList []*GroupMemberModel, err error)
|
||||||
Take(ctx context.Context, groupID string, userID string, tx ...any) (groupMember *GroupMemberModel, err error)
|
Take(ctx context.Context, groupID string, userID string, tx ...any) (groupMember *GroupMemberModel, err error)
|
||||||
TakeOwner(ctx context.Context, groupID string, tx ...any) (groupMember *GroupMemberModel, err error)
|
TakeOwner(ctx context.Context, groupID string, tx ...any) (groupMember *GroupMemberModel, err error)
|
||||||
SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...any) (total int32, groupList []*GroupMemberModel, err error)
|
SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...any) (total uint32, groupList []*GroupMemberModel, err error)
|
||||||
MapGroupMemberNum(ctx context.Context, groupIDs []string, tx ...any) (count map[string]uint32, err error)
|
MapGroupMemberNum(ctx context.Context, groupIDs []string, tx ...any) (count map[string]uint32, err error)
|
||||||
FindJoinUserID(ctx context.Context, groupIDs []string, tx ...any) (groupUsers map[string][]string, err error)
|
FindJoinUserID(ctx context.Context, groupIDs []string, tx ...any) (groupUsers map[string][]string, err error)
|
||||||
}
|
}
|
||||||
|
@ -35,5 +35,5 @@ type GroupRequestModelInterface interface {
|
|||||||
//Update(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (err error)
|
//Update(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (err error)
|
||||||
//Find(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (resultGroupRequests []*GroupRequestModel, err error)
|
//Find(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (resultGroupRequests []*GroupRequestModel, err error)
|
||||||
Take(ctx context.Context, groupID string, userID string, tx ...any) (groupRequest *GroupRequestModel, err error)
|
Take(ctx context.Context, groupID string, userID string, tx ...any) (groupRequest *GroupRequestModel, err error)
|
||||||
Page(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...any) (total int32, groups []*GroupRequestModel, err error)
|
Page(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...any) (total uint32, groups []*GroupRequestModel, err error)
|
||||||
}
|
}
|
||||||
|
@ -136,3 +136,17 @@ func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...strin
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MongoTransaction(ctx context.Context, mgo *mongo.Client, fn func(ctx mongo.SessionContext) error) error {
|
||||||
|
sess, err := mgo.StartSession()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sCtx := mongo.NewSessionContext(ctx, sess)
|
||||||
|
defer sess.EndSession(sCtx)
|
||||||
|
if err := fn(sCtx); err != nil {
|
||||||
|
_ = sess.AbortTransaction(sCtx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return utils.Wrap(sess.CommitTransaction(sCtx), "")
|
||||||
|
}
|
@ -57,40 +57,6 @@ type GroupMember_x struct {
|
|||||||
|
|
||||||
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
|
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
|
||||||
|
|
||||||
func (d *db.DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
|
|
||||||
return 1, nil
|
|
||||||
//var i, NB uint32
|
|
||||||
//var seqUid string
|
|
||||||
//session := d.mgoSession.Clone()
|
|
||||||
//if session == nil {
|
|
||||||
// return MinSeq, errors.New("session == nil")
|
|
||||||
//}
|
|
||||||
//defer session.Close()
|
|
||||||
//c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
|
||||||
//MaxSeq, err := d.GetUserMaxSeq(uid)
|
|
||||||
//if err != nil && err != redis.ErrNil {
|
|
||||||
// return MinSeq, err
|
|
||||||
//}
|
|
||||||
//NB = uint32(MaxSeq / singleGocMsgNum)
|
|
||||||
//for i = 0; i <= NB; i++ {
|
|
||||||
// seqUid = indexGen(uid, i)
|
|
||||||
// n, err := c.Find(bson.M{"uid": seqUid}).Count()
|
|
||||||
// if err == nil && n != 0 {
|
|
||||||
// if i == 0 {
|
|
||||||
// MinSeq = 1
|
|
||||||
// } else {
|
|
||||||
// MinSeq = uint32(i * singleGocMsgNum)
|
|
||||||
// }
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//return MinSeq, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
|
|
||||||
return 1, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteMsgByLogic
|
// deleteMsgByLogic
|
||||||
func (d *db.DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID string) (totalUnexistSeqList []uint32, err error) {
|
func (d *db.DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID string) (totalUnexistSeqList []uint32, err error) {
|
||||||
log.Debug(operationID, utils.GetSelfFuncName(), "args ", userID, seqList)
|
log.Debug(operationID, utils.GetSelfFuncName(), "args ", userID, seqList)
|
||||||
@ -657,24 +623,6 @@ func (d *db.DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgData
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *db.DataBases) DelUserChat(uid string) error {
|
|
||||||
return nil
|
|
||||||
//session := d.mgoSession.Clone()
|
|
||||||
//if session == nil {
|
|
||||||
// return errors.New("session == nil")
|
|
||||||
//}
|
|
||||||
//defer session.Close()
|
|
||||||
//
|
|
||||||
//c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
|
||||||
//
|
|
||||||
//delTime := time.Now().Unix() - int64(config.Config.Mongo.DBRetainChatRecords)*24*3600
|
|
||||||
//if err := c.Update(bson.M{"uid": uid}, bson.M{"$pull": bson.M{"msg": bson.M{"sendtime": bson.M{"$lte": delTime}}}}); err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) DelUserChatMongo2(uid string) error {
|
func (d *db.DataBases) DelUserChatMongo2(uid string) error {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
||||||
@ -687,19 +635,6 @@ func (d *db.DataBases) DelUserChatMongo2(uid string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *db.DataBases) MgoUserCount() (int, error) {
|
|
||||||
return 0, nil
|
|
||||||
//session := d.mgoSession.Clone()
|
|
||||||
//if session == nil {
|
|
||||||
// return 0, errors.New("session == nil")
|
|
||||||
//}
|
|
||||||
//defer session.Close()
|
|
||||||
//
|
|
||||||
//c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
|
||||||
//
|
|
||||||
//return c.Find(nil).Count()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) MgoSkipUID(count int) (string, error) {
|
func (d *db.DataBases) MgoSkipUID(count int) (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
//session := d.mgoSession.Clone()
|
//session := d.mgoSession.Clone()
|
||||||
@ -715,249 +650,6 @@ func (d *db.DataBases) MgoSkipUID(count int) (string, error) {
|
|||||||
//return sChat.UID, nil
|
//return sChat.UID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *db.DataBases) GetGroupMember(groupID string) []string {
|
|
||||||
return nil
|
|
||||||
//groupInfo := GroupMember_x{}
|
|
||||||
//groupInfo.GroupID = groupID
|
|
||||||
//groupInfo.UIDList = make([]string, 0)
|
|
||||||
//
|
|
||||||
//session := d.mgoSession.Clone()
|
|
||||||
//if session == nil {
|
|
||||||
// return groupInfo.UIDList
|
|
||||||
//}
|
|
||||||
//defer session.Close()
|
|
||||||
//
|
|
||||||
//c := session.DB(config.Config.Mongo.DBDatabase).C(cGroup)
|
|
||||||
//
|
|
||||||
//if err := c.Find(bson.M{"groupid": groupInfo.GroupID}).One(&groupInfo); err != nil {
|
|
||||||
// return groupInfo.UIDList
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//return groupInfo.UIDList
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) AddGroupMember(groupID, uid string) error {
|
|
||||||
return nil
|
|
||||||
//session := d.mgoSession.Clone()
|
|
||||||
//if session == nil {
|
|
||||||
// return errors.New("session == nil")
|
|
||||||
//}
|
|
||||||
//defer session.Close()
|
|
||||||
//
|
|
||||||
//c := session.DB(config.Config.Mongo.DBDatabase).C(cGroup)
|
|
||||||
//
|
|
||||||
//n, err := c.Find(bson.M{"groupid": groupID}).Count()
|
|
||||||
//if err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//if n == 0 {
|
|
||||||
// groupInfo := GroupMember_x{}
|
|
||||||
// groupInfo.GroupID = groupID
|
|
||||||
// groupInfo.UIDList = append(groupInfo.UIDList, uid)
|
|
||||||
// err = c.Insert(&groupInfo)
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
//} else {
|
|
||||||
// err = c.Update(bson.M{"groupid": groupID}, bson.M{"$addToSet": bson.M{"uidlist": uid}})
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) DelGroupMember(groupID, uid string) error {
|
|
||||||
return nil
|
|
||||||
//session := d.mgoSession.Clone()
|
|
||||||
//if session == nil {
|
|
||||||
// return errors.New("session == nil")
|
|
||||||
//}
|
|
||||||
//defer session.Close()
|
|
||||||
//
|
|
||||||
//c := session.DB(config.Config.Mongo.DBDatabase).C(cGroup)
|
|
||||||
//
|
|
||||||
//if err := c.Update(bson.M{"groupid": groupID}, bson.M{"$pull": bson.M{"uidlist": uid}}); err != nil {
|
|
||||||
// return err
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//type SuperGroup struct {
|
|
||||||
// GroupID string `bson:"group_id" json:"groupID"`
|
|
||||||
// MemberIDList []string `bson:"member_id_list" json:"memberIDList"`
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//type UserToSuperGroup struct {
|
|
||||||
// UserID string `bson:"user_id" json:"userID"`
|
|
||||||
// GroupIDList []string `bson:"group_id_list" json:"groupIDList"`
|
|
||||||
//}
|
|
||||||
|
|
||||||
func (d *db.DataBases) CreateSuperGroup(groupID string, initMemberIDList []string, memberNumCount int) error {
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
||||||
session, err := d.mongoClient.StartSession()
|
|
||||||
if err != nil {
|
|
||||||
return utils.Wrap(err, "start session failed")
|
|
||||||
}
|
|
||||||
defer session.EndSession(ctx)
|
|
||||||
sCtx := mongo.NewSessionContext(ctx, session)
|
|
||||||
superGroup := SuperGroup{
|
|
||||||
GroupID: groupID,
|
|
||||||
MemberIDList: initMemberIDList,
|
|
||||||
}
|
|
||||||
_, err = c.InsertOne(sCtx, superGroup)
|
|
||||||
if err != nil {
|
|
||||||
_ = session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
var users []UserToSuperGroup
|
|
||||||
for _, v := range initMemberIDList {
|
|
||||||
users = append(users, UserToSuperGroup{
|
|
||||||
UserID: v,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
upsert := true
|
|
||||||
opts := &options.UpdateOptions{
|
|
||||||
Upsert: &upsert,
|
|
||||||
}
|
|
||||||
c = d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
|
||||||
//_, err = c.UpdateMany(sCtx, bson.M{"user_id": bson.M{"$in": initMemberIDList}}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
|
||||||
//if err != nil {
|
|
||||||
// session.AbortTransaction(ctx)
|
|
||||||
// return utils.Wrap(err, "transaction failed")
|
|
||||||
//}
|
|
||||||
for _, userID := range initMemberIDList {
|
|
||||||
_, err = c.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
|
||||||
if err != nil {
|
|
||||||
_ = session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) GetSuperGroup(groupID string) (SuperGroup, error) {
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
||||||
superGroup := SuperGroup{}
|
|
||||||
err := c.FindOne(ctx, bson.M{"group_id": groupID}).Decode(&superGroup)
|
|
||||||
return superGroup, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) AddUserToSuperGroup(groupID string, userIDList []string) error {
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
||||||
session, err := d.mongoClient.StartSession()
|
|
||||||
if err != nil {
|
|
||||||
return utils.Wrap(err, "start session failed")
|
|
||||||
}
|
|
||||||
defer session.EndSession(ctx)
|
|
||||||
sCtx := mongo.NewSessionContext(ctx, session)
|
|
||||||
if err != nil {
|
|
||||||
return utils.Wrap(err, "start transaction failed")
|
|
||||||
}
|
|
||||||
_, err = c.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDList}}})
|
|
||||||
if err != nil {
|
|
||||||
_ = session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
c = d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
|
||||||
var users []UserToSuperGroup
|
|
||||||
for _, v := range userIDList {
|
|
||||||
users = append(users, UserToSuperGroup{
|
|
||||||
UserID: v,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
upsert := true
|
|
||||||
opts := &options.UpdateOptions{
|
|
||||||
Upsert: &upsert,
|
|
||||||
}
|
|
||||||
for _, userID := range userIDList {
|
|
||||||
_, err = c.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts)
|
|
||||||
if err != nil {
|
|
||||||
_ = session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ = session.CommitTransaction(ctx)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) RemoverUserFromSuperGroup(groupID string, userIDList []string) error {
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
||||||
session, err := d.mongoClient.StartSession()
|
|
||||||
if err != nil {
|
|
||||||
return utils.Wrap(err, "start session failed")
|
|
||||||
}
|
|
||||||
defer session.EndSession(ctx)
|
|
||||||
sCtx := mongo.NewSessionContext(ctx, session)
|
|
||||||
_, err = c.UpdateOne(ctx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDList}}})
|
|
||||||
if err != nil {
|
|
||||||
_ = session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
err = d.RemoveGroupFromUser(ctx, sCtx, groupID, userIDList)
|
|
||||||
if err != nil {
|
|
||||||
_ = session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
_ = session.CommitTransaction(ctx)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) GetSuperGroupByUserID(userID string) (UserToSuperGroup, error) {
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
|
||||||
var user UserToSuperGroup
|
|
||||||
_ = c.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user)
|
|
||||||
return user, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) DeleteSuperGroup(groupID string) error {
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
||||||
session, err := d.mongoClient.StartSession()
|
|
||||||
if err != nil {
|
|
||||||
return utils.Wrap(err, "start session failed")
|
|
||||||
}
|
|
||||||
defer session.EndSession(ctx)
|
|
||||||
sCtx := mongo.NewSessionContext(ctx, session)
|
|
||||||
superGroup := &SuperGroup{}
|
|
||||||
result := c.FindOneAndDelete(sCtx, bson.M{"group_id": groupID})
|
|
||||||
err = result.Decode(superGroup)
|
|
||||||
if err != nil {
|
|
||||||
session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
if err = d.RemoveGroupFromUser(ctx, sCtx, groupID, superGroup.MemberIDList); err != nil {
|
|
||||||
session.AbortTransaction(ctx)
|
|
||||||
return utils.Wrap(err, "transaction failed")
|
|
||||||
}
|
|
||||||
session.CommitTransaction(ctx)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *db.DataBases) RemoveGroupFromUser(ctx, sCtx context.Context, groupID string, userIDList []string) error {
|
|
||||||
var users []UserToSuperGroup
|
|
||||||
for _, v := range userIDList {
|
|
||||||
users = append(users, UserToSuperGroup{
|
|
||||||
UserID: v,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
|
||||||
_, err := c.UpdateOne(sCtx, bson.M{"user_id": bson.M{"$in": userIDList}}, bson.M{"$pull": bson.M{"group_id_list": groupID}})
|
|
||||||
if err != nil {
|
|
||||||
return utils.Wrap(err, "UpdateOne transaction failed")
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateTagID(tagName, userID string) string {
|
func generateTagID(tagName, userID string) string {
|
||||||
return utils.Md5(tagName + userID + strconv.Itoa(rand.Int()) + time.Now().String())
|
return utils.Md5(tagName + userID + strconv.Itoa(rand.Int()) + time.Now().String())
|
||||||
}
|
}
|
||||||
|
@ -1,54 +1,44 @@
|
|||||||
package discoveryRegistry
|
package discoveryRegistry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"github.com/OpenIMSDK/getcdv3"
|
|
||||||
clientv3 "go.etcd.io/etcd/client/v3"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"time"
|
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SvcDiscoveryRegistry interface {
|
type SvcDiscoveryRegistry interface {
|
||||||
Register(serviceName, host string, port int, opts ...grpc.DialOption) error
|
Register(serviceName, host string, port int, opts ...grpc.DialOption) error
|
||||||
UnRegister() error
|
UnRegister() error
|
||||||
GetConns(serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error)
|
GetConns(serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error)
|
||||||
GetConn(serviceName string, strategy func(slice []*grpc.ClientConn) int, opts ...grpc.DialOption) (*grpc.ClientConn, error)
|
GetConn(serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
|
||||||
//RegisterConf(conf []byte) error
|
//RegisterConf(conf []byte) error
|
||||||
//LoadConf() ([]byte, error)
|
//LoadConf() ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerConf(key, conf string) {
|
//func registerConf(key, conf string) {
|
||||||
etcdAddr := strings.Join(config.Config.Etcd.EtcdAddr, ",")
|
// etcdAddr := strings.Join(config.Config.Etcd.EtcdAddr, ",")
|
||||||
cli, err := clientv3.New(clientv3.Config{
|
// cli, err := clientv3.New(clientv3.Config{
|
||||||
Endpoints: strings.Split(etcdAddr, ","), DialTimeout: 5 * time.Second})
|
// Endpoints: strings.Split(etcdAddr, ","), DialTimeout: 5 * time.Second})
|
||||||
|
//
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
panic(err.Error())
|
// panic(err.Error())
|
||||||
}
|
// }
|
||||||
//lease
|
// //lease
|
||||||
if _, err := cli.Put(context.Background(), key, conf); err != nil {
|
// if _, err := cli.Put(context.Background(), key, conf); err != nil {
|
||||||
fmt.Println("panic, params: ")
|
// fmt.Println("panic, params: ")
|
||||||
panic(err.Error())
|
// panic(err.Error())
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
func RegisterConf() {
|
//func RegisterConf() {
|
||||||
bytes, err := yaml.Marshal(config.Config)
|
// bytes, err := yaml.Marshal(config.Config)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
panic(err.Error())
|
// panic(err.Error())
|
||||||
}
|
// }
|
||||||
secretMD5 := utils.Md5(config.Config.Etcd.Secret)
|
// secretMD5 := utils.Md5(config.Config.Etcd.Secret)
|
||||||
confBytes, err := utils.AesEncrypt(bytes, []byte(secretMD5[0:16]))
|
// confBytes, err := utils.AesEncrypt(bytes, []byte(secretMD5[0:16]))
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
panic(err.Error())
|
// panic(err.Error())
|
||||||
}
|
// }
|
||||||
fmt.Println("start register", secretMD5, getcdv3.GetPrefix(config.Config.Etcd.EtcdSchema, config.ConfName))
|
// fmt.Println("start register", secretMD5, getcdv3.GetPrefix(config.Config.Etcd.EtcdSchema, config.ConfName))
|
||||||
registerConf(getcdv3.GetPrefix(config.Config.Etcd.EtcdSchema, config.ConfName), string(confBytes))
|
// registerConf(getcdv3.GetPrefix(config.Config.Etcd.EtcdSchema, config.ConfName), string(confBytes))
|
||||||
fmt.Println("etcd register conf ok")
|
// fmt.Println("etcd register conf ok")
|
||||||
}
|
//}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -37,17 +37,17 @@ message GetGroupApplicationListReq {
|
|||||||
string fromUserID = 2; //owner or admin
|
string fromUserID = 2; //owner or admin
|
||||||
}
|
}
|
||||||
message GetGroupApplicationListResp {
|
message GetGroupApplicationListResp {
|
||||||
int32 total = 1;
|
uint32 total = 1;
|
||||||
repeated server_api_params.GroupRequest groupRequests = 2;
|
repeated server_api_params.GroupRequest groupRequests = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetUserReqApplicationListReq{
|
message GetUserReqApplicationListReq{
|
||||||
string userID = 1;
|
server_api_params.RequestPagination pagination = 1;
|
||||||
server_api_params.RequestPagination pagination = 2;
|
string userID = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetUserReqApplicationListResp{
|
message GetUserReqApplicationListResp{
|
||||||
int32 total = 1;
|
uint32 total = 1;
|
||||||
repeated server_api_params.GroupRequest groupRequests = 2;
|
repeated server_api_params.GroupRequest groupRequests = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,15 +90,14 @@ message QuitGroupResp{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
message GetGroupMemberListReq {
|
message GetGroupMemberListReq {
|
||||||
string groupID = 1;
|
server_api_params.RequestPagination pagination = 1;
|
||||||
int32 filter = 2;
|
string groupID = 2;
|
||||||
server_api_params.RequestPagination pagination = 4;
|
int32 filter = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupMemberListResp {
|
message GetGroupMemberListResp {
|
||||||
int32 total = 1;
|
uint32 total = 1;
|
||||||
repeated server_api_params.GroupMemberFullInfo members = 2;
|
repeated server_api_params.GroupMemberFullInfo members = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,11 +123,11 @@ message KickGroupMemberResp {
|
|||||||
|
|
||||||
|
|
||||||
message GetJoinedGroupListReq {
|
message GetJoinedGroupListReq {
|
||||||
string fromUserID = 1;
|
server_api_params.RequestPagination pagination = 1;
|
||||||
server_api_params.RequestPagination pagination = 2;
|
string fromUserID = 2;
|
||||||
}
|
}
|
||||||
message GetJoinedGroupListResp{
|
message GetJoinedGroupListResp{
|
||||||
int32 total = 1;
|
uint32 total = 1;
|
||||||
repeated server_api_params.GroupInfo groups = 2;
|
repeated server_api_params.GroupInfo groups = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,17 +143,17 @@ message InviteUserToGroupResp {
|
|||||||
|
|
||||||
|
|
||||||
message GetGroupAllMemberReq {
|
message GetGroupAllMemberReq {
|
||||||
string groupID = 1;
|
server_api_params.RequestPagination pagination = 1;
|
||||||
server_api_params.RequestPagination pagination = 2;
|
string groupID = 2;
|
||||||
}
|
}
|
||||||
message GetGroupAllMemberResp {
|
message GetGroupAllMemberResp {
|
||||||
repeated server_api_params.GroupMemberFullInfo members = 1;
|
repeated server_api_params.GroupMemberFullInfo members = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CMSGroup {
|
message CMSGroup {
|
||||||
server_api_params.GroupInfo groupInfo = 1;
|
server_api_params.GroupInfo groupInfo = 1;
|
||||||
string groupOwnerUserName = 2;
|
string groupOwnerUserName = 2;
|
||||||
string groupOwnerUserID = 3;
|
string groupOwnerUserID = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,23 +164,23 @@ message GetGroupsReq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupsResp {
|
message GetGroupsResp {
|
||||||
repeated CMSGroup groups = 1;
|
uint32 total = 1;
|
||||||
int32 GroupNum = 2;
|
repeated CMSGroup groups = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupMemberReq {
|
message GetGroupMemberReq {
|
||||||
string groupID = 1;
|
string groupID = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupMembersCMSReq {
|
message GetGroupMembersCMSReq {
|
||||||
string groupID = 1;
|
server_api_params.RequestPagination pagination = 1;
|
||||||
string userName = 2;
|
string groupID = 2;
|
||||||
server_api_params.RequestPagination pagination = 3;
|
string userName = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupMembersCMSResp {
|
message GetGroupMembersCMSResp {
|
||||||
repeated server_api_params.GroupMemberFullInfo members = 1;
|
uint32 total = 1;
|
||||||
int32 memberNums = 2;
|
repeated server_api_params.GroupMemberFullInfo members = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message DismissGroupReq{
|
message DismissGroupReq{
|
||||||
@ -240,13 +239,11 @@ message SetGroupMemberNicknameResp{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetJoinedSuperGroupListReq {
|
message GetJoinedSuperGroupListReq {
|
||||||
server_api_params.RequestPagination pagination = 1;
|
string userID = 1;
|
||||||
string userID = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetJoinedSuperGroupListResp {
|
message GetJoinedSuperGroupListResp {
|
||||||
int32 total = 1;
|
repeated server_api_params.GroupInfo groups = 1;
|
||||||
repeated server_api_params.GroupInfo groups = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetSuperGroupsInfoReq {
|
message GetSuperGroupsInfoReq {
|
||||||
@ -271,12 +268,12 @@ message SetGroupMemberInfoResp{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetGroupAbstractInfoReq{
|
message GetGroupAbstractInfoReq{
|
||||||
repeated string groupIDs = 1;
|
repeated string groupIDs = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GroupAbstractInfo{
|
message GroupAbstractInfo{
|
||||||
string groupID = 1;
|
string groupID = 1;
|
||||||
int32 groupMemberNumber = 2;
|
uint32 groupMemberNumber = 2;
|
||||||
uint64 groupMemberListHash = 3;
|
uint64 groupMemberListHash = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user