Skip to content

Commit

Permalink
Fix nil error when favoriting non-existant performer
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash committed Feb 29, 2024
1 parent 0a05b9c commit fa50fa5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/api/resolver_mutation_performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,20 @@ func (r *mutationResolver) FavoritePerformer(ctx context.Context, id uuid.UUID,
if err != nil {
return err
}
if performer == nil {
return fmt.Errorf("performer not found")
}

if performer.Deleted {
return fmt.Errorf("performer is deleted, unable to make favorite")
}

performerFavorite := models.PerformerFavorite{PerformerID: id, UserID: user.ID}
if favorite {
pf := models.PerformerFavorite{PerformerID: id, UserID: user.ID}
err := jqb.AddPerformerFavorite(pf)
return err
return jqb.AddPerformerFavorite(performerFavorite)
} else {

Check failure on line 229 in pkg/api/resolver_mutation_performer.go

View workflow job for this annotation

GitHub Actions / lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
return jqb.DestroyPerformerFavorite(performerFavorite)
}
return jqb.DestroyPerformerFavorite(models.PerformerFavorite{PerformerID: id, UserID: user.ID})
})
return err == nil, err
}

0 comments on commit fa50fa5

Please sign in to comment.