Skip to content

Commit

Permalink
Merge pull request #251 from getAlby/fix/consistent-http-status-keysend
Browse files Browse the repository at this point in the history
respond with 500 if no payment sent
  • Loading branch information
kiwiidb committed Dec 23, 2022
2 parents 5e78990 + 3bcd458 commit 0564bc0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers_v2/keysend.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (controller *KeySendController) MultiKeySend(c echo.Context) error {
result := &MultiKeySendResponseBody{
Keysends: []KeySendResult{},
}
singleSuccesfulPayment := false
for _, keysend := range reqBody.Keysends {
keysend := keysend
res, err := controller.SingleKeySend(c, &keysend, userID)
Expand All @@ -125,8 +126,13 @@ func (controller *KeySendController) MultiKeySend(c echo.Context) error {
result.Keysends = append(result.Keysends, KeySendResult{
Keysend: res,
})
singleSuccesfulPayment = true
}
return c.JSON(http.StatusOK, result)
status := http.StatusOK
if !singleSuccesfulPayment {
status = http.StatusInternalServerError
}
return c.JSON(status, result)
}

func (controller *KeySendController) SingleKeySend(c echo.Context, reqBody *KeySendRequestBody, userID int64) (result *KeySendResponseBody, resp *responses.ErrorResponse) {
Expand Down

0 comments on commit 0564bc0

Please sign in to comment.