diff --git a/internal/logic/app/group_app.go b/internal/logic/app/group_app.go index e9c85ab..46bb534 100644 --- a/internal/logic/app/group_app.go +++ b/internal/logic/app/group_app.go @@ -28,7 +28,7 @@ func (*groupApp) CreateGroup(ctx context.Context, userId int64, in *pb.CreateGro return 0, err } in.MemberIds = append(in.MemberIds, userId) - err = group.PushAddMember(ctx, userId, in.MemberIds) + err = group.PushAddMember(ctx, userId, in.MemberIds, false) return group.Id, nil } @@ -99,7 +99,7 @@ func (*groupApp) AddMembers(ctx context.Context, userId, groupId int64, userIds return nil, err } - err = group.PushAddMember(ctx, userId, addedIds) + err = group.PushAddMember(ctx, userId, addedIds, true) if err != nil { return nil, err } diff --git a/internal/logic/domain/group/model/group.go b/internal/logic/domain/group/model/group.go index 00aef8d..6dc429e 100644 --- a/internal/logic/domain/group/model/group.go +++ b/internal/logic/domain/group/model/group.go @@ -402,7 +402,7 @@ func (g *Group) AddMembers(ctx context.Context, userIds []int64) ([]int64, []int return existIds, addedIds, nil } -func (g *Group) PushAddMember(ctx context.Context, optUserId int64, addedIds []int64) error { +func (g *Group) PushAddMember(ctx context.Context, optUserId int64, addedIds []int64, isFilterGroupLeader bool) error { var addIdMap = make(map[int64]int32, len(addedIds)) for i := range addedIds { addIdMap[addedIds[i]] = 0 @@ -415,6 +415,9 @@ func (g *Group) PushAddMember(ctx context.Context, optUserId int64, addedIds []i } var members []*pb.GroupMember for k, _ := range addIdMap { + if isFilterGroupLeader && k == optUserId { + continue + } member, ok := usersResp.Users[k] if !ok { continue