Skip to content

Commit

Permalink
fix: processor crashes when location dont exist yet (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
42atomys authored Jul 5, 2022
1 parent bf47948 commit 7c5041f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/webhooks/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/rs/zerolog/log"

modelsutils "atomys.codes/stud42/internal/models"
"atomys.codes/stud42/internal/models/generated"
"atomys.codes/stud42/internal/models/generated/campus"
"atomys.codes/stud42/internal/models/generated/location"
"atomys.codes/stud42/internal/models/generated/user"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (p *locationProcessor) Close(loc *duoapi.Location[duoapi.LocationUser], met
SetIdentifier(loc.Host).
Where(location.DuoID(loc.ID)).
Exec(p.ctx)
if err != nil {
if err != nil && !generated.IsNotFound(err) {
return err
}

Expand All @@ -77,7 +78,7 @@ func (p *locationProcessor) Close(loc *duoapi.Location[duoapi.LocationUser], met
func (p *locationProcessor) Destroy(loc *duoapi.Location[duoapi.LocationUser], metadata *duoapi.WebhookMetadata) error {
// Delete the location in database
_, err := p.db.Location.Delete().Where(location.DuoID(loc.ID)).Exec(p.ctx)
if err != nil {
if err != nil && !generated.IsNotFound(err) {
return err
}

Expand Down

0 comments on commit 7c5041f

Please sign in to comment.