Skip to content

Commit

Permalink
added api call return incase websocket fails
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Oct 23, 2024
1 parent f03c576 commit d51e8b1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions handlers/bounty.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
}

h.m.Unlock()

w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(msg)
return
} else if v2KeysendRes.Status == db.PaymentPending {
// Send payment status
Expand All @@ -715,6 +718,9 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
}

h.m.Unlock()

w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(msg)
return
} else {
// Send payment status
Expand All @@ -737,7 +743,11 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
if err == nil {
socket.Conn.WriteJSON(msg)
}

h.m.Unlock()

w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(msg)
return
}
} else { // Send Payment error
Expand All @@ -751,6 +761,9 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request
}

h.m.Unlock()

w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(msg)
return
}
} else { // Process v1 payment
Expand Down

0 comments on commit d51e8b1

Please sign in to comment.