|
|
@ -6,15 +6,15 @@ import (
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/db"
|
|
|
|
"Open_IM/pkg/common/db"
|
|
|
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
|
|
|
imdb "Open_IM/pkg/common/db/mysql"
|
|
|
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
|
|
|
|
|
|
|
"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"
|
|
|
|
"Open_IM/pkg/common/token_verify"
|
|
|
|
"Open_IM/pkg/common/token_verify"
|
|
|
|
"Open_IM/pkg/common/tools"
|
|
|
|
"Open_IM/pkg/common/tools"
|
|
|
|
"Open_IM/pkg/common/trace_log"
|
|
|
|
"Open_IM/pkg/common/trace_log"
|
|
|
|
cp "Open_IM/pkg/common/utils"
|
|
|
|
|
|
|
|
|
|
|
|
cp "Open_IM/internal/utils"
|
|
|
|
"Open_IM/pkg/getcdv3"
|
|
|
|
"Open_IM/pkg/getcdv3"
|
|
|
|
pbCache "Open_IM/pkg/proto/cache"
|
|
|
|
pbCache "Open_IM/pkg/proto/cache"
|
|
|
|
pbConversation "Open_IM/pkg/proto/conversation"
|
|
|
|
pbConversation "Open_IM/pkg/proto/conversation"
|
|
|
@ -131,39 +131,26 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|
|
|
for _, adminUserID := range req.AdminUserIDs {
|
|
|
|
for _, adminUserID := range req.AdminUserIDs {
|
|
|
|
userIDs = append(userIDs, adminUserID)
|
|
|
|
userIDs = append(userIDs, adminUserID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if utils.IsRepeatID(userIDs) {
|
|
|
|
if utils.IsDuplicateID(userIDs) {
|
|
|
|
return nil, constant.ErrArgs.Wrap("group member is repeated")
|
|
|
|
return nil, constant.ErrArgs.Wrap("group member is repeated")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
users, err := getUsersInfo(ctx, userIDs)
|
|
|
|
users, err := getUsersInfo(ctx, userIDs)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
userMap := make(map[string]*open_im_sdk.UserInfo)
|
|
|
|
userMap := make(map[string]*open_im_sdk.UserInfo)
|
|
|
|
for i, user := range users {
|
|
|
|
for i, user := range users {
|
|
|
|
userMap[user.UserID] = users[i]
|
|
|
|
userMap[user.UserID] = users[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := callbackBeforeCreateGroup(ctx, req); err != nil {
|
|
|
|
if err := callbackBeforeCreateGroup(ctx, req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
groupId := genGroupID(ctx, req.GroupInfo.GroupID)
|
|
|
|
groupInfo, err := (&cp.PBGroup{req.GroupInfo}).Convert()
|
|
|
|
|
|
|
|
groupInfo.GroupID = genGroupID(ctx, req.GroupInfo.GroupID)
|
|
|
|
groupInfo := imdb.Group{}
|
|
|
|
|
|
|
|
utils.CopyStructFields(&groupInfo, req.GroupInfo)
|
|
|
|
|
|
|
|
groupInfo.CreatorUserID = tools.OpUserID(ctx)
|
|
|
|
|
|
|
|
groupInfo.GroupID = groupId
|
|
|
|
|
|
|
|
groupInfo.CreateTime = time.Now()
|
|
|
|
|
|
|
|
if groupInfo.NotificationUpdateTime.Unix() < 0 {
|
|
|
|
|
|
|
|
groupInfo.NotificationUpdateTime = utils.UnixSecondToTime(0)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if req.GroupInfo.GroupType != constant.SuperGroup {
|
|
|
|
if req.GroupInfo.GroupType != constant.SuperGroup {
|
|
|
|
|
|
|
|
|
|
|
|
var groupMembers []*imdb.GroupMember
|
|
|
|
var groupMembers []*imdb.GroupMember
|
|
|
|
joinGroup := func(userID string, roleLevel int32) error {
|
|
|
|
joinGroup := func(userID string, roleLevel int32) error {
|
|
|
|
groupMember := &imdb.GroupMember{GroupID: groupId, RoleLevel: roleLevel, OperatorUserID: tools.OpUserID(ctx), JoinSource: constant.JoinByInvitation, InviterUserID: tools.OpUserID(ctx)}
|
|
|
|
groupMember := &imdb.GroupMember{GroupID: groupInfo.GroupID, RoleLevel: roleLevel, OperatorUserID: tools.OpUserID(ctx), JoinSource: constant.JoinByInvitation, InviterUserID: tools.OpUserID(ctx)}
|
|
|
|
user := userMap[userID]
|
|
|
|
user := userMap[userID]
|
|
|
|
utils.CopyStructFields(&groupMember, user)
|
|
|
|
utils.CopyStructFields(&groupMember, user)
|
|
|
|
if err := CallbackBeforeMemberJoinGroup(ctx, tools.OperationID(ctx), groupMember, groupInfo.Ex); err != nil {
|
|
|
|
if err := CallbackBeforeMemberJoinGroup(ctx, tools.OperationID(ctx), groupMember, groupInfo.Ex); err != nil {
|
|
|
|