(ctx context.Context, orgID string)
| 127 | } |
| 128 | |
| 129 | func (s *sqlDatabase) DeleteOrganization(ctx context.Context, orgID string) (err error) { |
| 130 | org, err := s.getOrgByID(ctx, s.conn, orgID, "Endpoint", "Credentials", "Credentials.Endpoint", "GiteaCredentials", "GiteaCredentials.Endpoint") |
| 131 | if err != nil { |
| 132 | return fmt.Errorf("error fetching org: %w", err) |
| 133 | } |
| 134 | |
| 135 | defer func(org Organization) { |
| 136 | if err == nil { |
| 137 | asParam, innerErr := s.sqlToCommonOrganization(org, true) |
| 138 | if innerErr == nil { |
| 139 | s.sendNotify(common.OrganizationEntityType, common.DeleteOperation, asParam) |
| 140 | } else { |
| 141 | slog.With(slog.Any("error", innerErr)).ErrorContext(ctx, "error sending delete notification", "org", orgID) |
| 142 | } |
| 143 | } |
| 144 | }(org) |
| 145 | |
| 146 | q := s.conn.Unscoped().Delete(&org) |
| 147 | if q.Error != nil && !errors.Is(q.Error, gorm.ErrRecordNotFound) { |
| 148 | return fmt.Errorf("error deleting org: %w", q.Error) |
| 149 | } |
| 150 | |
| 151 | return nil |
| 152 | } |
| 153 | |
| 154 | func (s *sqlDatabase) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (paramOrg params.Organization, err error) { |
| 155 | var rowsAffected int64 |
nothing calls this directly
no test coverage detected