Skip to content

Commit

Permalink
Limit casting of votes to pending edits (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash authored May 21, 2022
1 parent c73060d commit 0591392
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/api/resolver_mutation_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

var ErrUnauthorizedUpdate = fmt.Errorf("Only the creator can update edits")
var ErrAlreadyUpdated = fmt.Errorf("Edits can only be updated once")
var ErrClosedEdit = fmt.Errorf("Votes can only be cast on pending edits")

func (r *mutationResolver) SceneEdit(ctx context.Context, input models.SceneEditInput) (*models.Edit, error) {
UUID, err := uuid.NewV4()
Expand Down Expand Up @@ -329,6 +330,10 @@ func (r *mutationResolver) EditVote(ctx context.Context, input models.EditVoteIn
return err
}

if voteEdit.Status != models.VoteStatusEnumPending.String() {
return ErrClosedEdit
}

if err := user.ValidateOwner(ctx, voteEdit.UserID); err == nil {
return user.ErrUnauthorized
}
Expand Down

0 comments on commit 0591392

Please sign in to comment.