DeleteGroup deletes a group.
(ctx context.Context, workspace string, id string)
| 312 | |
| 313 | // DeleteGroup deletes a group. |
| 314 | func (s *Store) DeleteGroup(ctx context.Context, workspace string, id string) error { |
| 315 | q := qb.Q().Space("DELETE FROM user_group WHERE id = ? AND workspace = ? RETURNING email", id, workspace) |
| 316 | query, args, err := q.ToSQL() |
| 317 | if err != nil { |
| 318 | return errors.Wrapf(err, "failed to build sql") |
| 319 | } |
| 320 | |
| 321 | var email sql.NullString |
| 322 | if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(&email); err != nil { |
| 323 | return err |
| 324 | } |
| 325 | |
| 326 | group := &GroupMessage{ID: id, Workspace: workspace} |
| 327 | if email.Valid { |
| 328 | group.Email = email.String |
| 329 | } |
| 330 | s.groupCache.Remove(getGroupCacheKey(workspace, group)) |
| 331 | s.removeGroupMembersCache(workspace, group) |
| 332 | return nil |
| 333 | } |
| 334 | |
| 335 | // RemoveMemberFromAllGroups removes a user from all groups in a workspace via a single SQL update. |
| 336 | // member format is "users/{email}". |
nothing calls this directly
no test coverage detected