From 3f52c03b1dfb294e1ace79d359da72296f8f8e99 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 17 Jan 2023 16:25:18 +0800 Subject: [PATCH] Error code standardization --- internal/rpc/group/group.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index a232ca147..a8c2d90df 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -5,7 +5,7 @@ import ( chat "Open_IM/internal/rpc/msg" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db" + "Open_IM/pkg/common/db/model" imdb "Open_IM/pkg/common/db/mysql" "Open_IM/pkg/common/log" "Open_IM/pkg/common/middleware" @@ -159,17 +159,22 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR groupMembers = append(groupMembers, groupMember) return nil } - if req.OwnerUserID == "" { - if err := joinGroup(req.OwnerUserID, constant.GroupOwner); err != nil { - return nil, err - } - } - for _, info := range req.InitMemberList { - if err := joinGroup(info.UserID, info.RoleLevel); err != nil { - return nil, err - } + + if err := joinGroup(req.OwnerUserID, constant.GroupOwner); err != nil { + return nil, err } + for _, info := range req.InitMemberList { + if err := joinGroup(info, constant.GroupOrdinaryUsers); err != nil { + return nil, err + } + } + for _, info := range req.AdminUserIDs { + if err := joinGroup(info, constant.GroupAdmin); err != nil { + return nil, err + } + } + if err := model. if err := (*imdb.GroupMember)(nil).Create(ctx, groupMembers); err != nil { return nil, err }