Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
woutslakhorst committed Jun 24, 2024
1 parent 7098474 commit 195fcdf
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions vdr/didweb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,20 @@ type Manager struct {
}

func (m Manager) Deactivate(ctx context.Context, subjectDID did.DID) error {
tx := m.db.Begin()
defer tx.Rollback()

didStore := sql.NewDIDManager(tx)
documentStore := sql.NewDIDDocumentManager(tx)
sqlDocument, err := documentStore.Latest(subjectDID)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resolver.ErrNotFound
var err error
var sqlDocument *sql.DIDDocument
err = m.db.Transaction(func(tx *gorm.DB) error {
didStore := sql.NewDIDManager(tx)
documentStore := sql.NewDIDDocumentManager(tx)
sqlDocument, err = documentStore.Latest(subjectDID)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resolver.ErrNotFound
}
return err
}
return err
}
err = didStore.Delete(subjectDID)
if err != nil {
return err
}
err = tx.Commit().Error
return didStore.Delete(subjectDID)
})
if err != nil {
return err
}
Expand Down

0 comments on commit 195fcdf

Please sign in to comment.