Skip to content

Commit

Permalink
added pending check for other bounty updates
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Oct 22, 2024
1 parent c6c1c8c commit 9cffbae
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ func UpdatePaymentStatus(w http.ResponseWriter, r *http.Request) {
created, _ := strconv.ParseUint(createdParam, 10, 32)

bounty, _ := db.DB.GetBountyByCreated(uint(created))
if bounty.PaymentPending {
w.WriteHeader(http.StatusBadGateway)
json.NewEncoder(w).Encode("Cannot update a bounty with a pending payment")
return
}

if bounty.ID != 0 && bounty.Created == int64(created) {
bounty.Paid = !bounty.Paid
now := time.Now()
Expand All @@ -392,8 +398,14 @@ func UpdatePaymentStatus(w http.ResponseWriter, r *http.Request) {
func UpdateCompletedStatus(w http.ResponseWriter, r *http.Request) {
createdParam := chi.URLParam(r, "created")
created, _ := strconv.ParseUint(createdParam, 10, 32)

bounty, _ := db.DB.GetBountyByCreated(uint(created))

if bounty.PaymentPending {
w.WriteHeader(http.StatusBadGateway)
json.NewEncoder(w).Encode("Cannot update a bounty with a pending payment")
return
}

if bounty.ID != 0 && bounty.Created == int64(created) {
now := time.Now()
// set bounty as completed
Expand Down

0 comments on commit 9cffbae

Please sign in to comment.