Skip to content

Commit

Permalink
MF-263 - Unassign members before delete group (#266)
Browse files Browse the repository at this point in the history
Signed-off-by: zzokki81 <zoran.rebic@outlook.com>
  • Loading branch information
zzokki81 authored Aug 7, 2023
1 parent 9ca1965 commit a7e9d93
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions things/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,17 @@ func (ts *thingsService) RemoveGroup(ctx context.Context, token, id string) erro
return errors.ErrAuthorization
}

members, err := ts.groups.RetrieveMembers(ctx, id, PageMetadata{})
if err != nil {
return err
}

for _, member := range members.Members {
if err := ts.groups.UnassignMember(ctx, id, member.ID); err != nil {
return err
}
}

return ts.groups.Remove(ctx, id)
}

Expand Down

0 comments on commit a7e9d93

Please sign in to comment.