From 920323caf851c030b81dde3b4b32b336c45e5f2f Mon Sep 17 00:00:00 2001 From: InfiniteStash <117855276+InfiniteStash@users.noreply.github.com> Date: Thu, 29 Feb 2024 21:27:22 +0100 Subject: [PATCH] Fix nil error when favoriting non-existent performer (#766) --- pkg/api/resolver_mutation_performer.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/api/resolver_mutation_performer.go b/pkg/api/resolver_mutation_performer.go index f76730307..e23c2a498 100644 --- a/pkg/api/resolver_mutation_performer.go +++ b/pkg/api/resolver_mutation_performer.go @@ -215,16 +215,19 @@ 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) } - return jqb.DestroyPerformerFavorite(models.PerformerFavorite{PerformerID: id, UserID: user.ID}) + return jqb.DestroyPerformerFavorite(performerFavorite) }) return err == nil, err }