Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate vote triggered cross-repo #12

Open
7db9a opened this issue Aug 3, 2023 · 0 comments
Open

Duplicate vote triggered cross-repo #12

7db9a opened this issue Aug 3, 2023 · 0 comments

Comments

@7db9a
Copy link
Member

7db9a commented Aug 3, 2023

After voting on a pull request in "repo A" with the same repo name, github issue/pull number, commit oid, and default hash as "repo B", I was unable to vote on the "duplicate" pull requests on "repo B".

This duplicateVote triggered when looking at turbosrc-engine logs:

    const duplicateVote = await Vote.findOne({
      where: { defaultHash: defaultHash, contributor_id: contributor_id },
    });

    if (duplicateVote) {
      console.log("duplicate");
      return 403;
    } else {
      let tokens = await getVotePowerAmount(
        /*owner:*/ "",
        /*repo:*/ repo_id,
        /*defaultHash:*/ defaultHash,
        /*contributor_id:*/ contributor_id,
        /*side:*/ ""
      );

      // Should also check if tokens.status === 404
      if (tokens.amount < 1) {
        return 403;
      }

      let vote = await Vote.create({
        contributor_id: contributor_id,
        defaultHash: defaultHash,
        votePower: tokens.amount,
        side: side,
      });

      await vote.setPullrequest(pullRequest.id);

      if (side === "yes") {
        let newTotal = pullRequest.yesTokenAmount + tokens.amount;
        await pullRequest.update({
          yesTokenAmount: newTotal,
          where: { id: pullRequest.id },
        });
      }
      if (side === "no") {
        let newTotal = pullRequest.noTokenAmount + tokens.amount;
        await pullRequest.update({
          noTokenAmount: newTotal,
          where: { id: pullRequest.id },
        });
      }

      return 201;
    }
  } catch (error) {
    console.log(error);
    return 500;
  }```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant