Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Check the social metric count when approving milestones

Rafi6a12c27a6a2e
diff --git a/apps/web/lib/bounty/api/approve-bounty-submission.ts b/apps/web/lib/bounty/api/approve-bounty-submission.ts
index 54f7fe2a1f..749e6701ea 100644
--- a/apps/web/lib/bounty/api/approve-bounty-submission.ts
+++ b/apps/web/lib/bounty/api/approve-bounty-submission.ts
@@ -239,6 +239,8 @@ async function approveSocialMetricsMilestones({
where: {
id: submissionId,
approvedSocialMetricThreshold: submission.approvedSocialMetricThreshold,
+ // A sync can change the count after we read it, so the status would be based on stale milestones
+ socialMetricCount: submission.socialMetricCount,
status: {
notIn: [
BountySubmissionStatus.approved,
@@ -263,7 +265,7 @@ async function approveSocialMetricsMilestones({
throw new DubApiError({
code: "bad_request",
message:
- "These milestones have already been approved or the submission is no longer awaiting review.",
+ "These milestones have already been approved, the social metrics changed, or the submission is no longer awaiting review. Refresh and try again.",
});
}