fix: return "message" instead of "error" so it is handled better at the client.
This commit is contained in:
parent
eaec3480e6
commit
d4e30356c7
3 changed files with 15 additions and 7 deletions
|
|
@ -565,7 +565,12 @@ new Vue({
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
dismissAuthMsg()
|
dismissAuthMsg()
|
||||||
LNbits.utils.notifyApiError(err)
|
this.$q.notify({
|
||||||
|
message: `Authentication failed. ${this.parse.lnurlauth.domain} says:`,
|
||||||
|
caption: err.response.data.message,
|
||||||
|
type: 'warning',
|
||||||
|
timeout: 5000
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteWallet: function (walletId, user) {
|
deleteWallet: function (walletId, user) {
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@ async def api_lnurlscan(code: str):
|
||||||
try:
|
try:
|
||||||
url = lnurl.Lnurl(code)
|
url = lnurl.Lnurl(code)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return jsonify({"error": "invalid lnurl"}), HTTPStatus.BAD_REQUEST
|
return jsonify({"message": "invalid lnurl"}), HTTPStatus.BAD_REQUEST
|
||||||
|
|
||||||
domain = urlparse(url.url).netloc
|
domain = urlparse(url.url).netloc
|
||||||
|
|
||||||
|
|
@ -315,19 +315,22 @@ async def api_lnurlscan(code: str):
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
r = await client.get(url.url, timeout=40)
|
r = await client.get(url.url, timeout=40)
|
||||||
if r.is_error:
|
if r.is_error:
|
||||||
return jsonify({"domain": domain, "error": "failed to get parameters"}), HTTPStatus.SERVICE_UNAVAILABLE
|
return (
|
||||||
|
jsonify({"domain": domain, "message": "failed to get parameters"}),
|
||||||
|
HTTPStatus.SERVICE_UNAVAILABLE,
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
jdata = json.loads(r.text)
|
jdata = json.loads(r.text)
|
||||||
data: lnurl.LnurlResponseModel = lnurl.LnurlResponse.from_dict(jdata)
|
data: lnurl.LnurlResponseModel = lnurl.LnurlResponse.from_dict(jdata)
|
||||||
except (json.decoder.JSONDecodeError, lnurl.exceptions.LnurlResponseException):
|
except (json.decoder.JSONDecodeError, lnurl.exceptions.LnurlResponseException):
|
||||||
return (
|
return (
|
||||||
jsonify({"domain": domain, "error": f"got invalid response '{r.text[:200]}'"}),
|
jsonify({"domain": domain, "message": f"got invalid response '{r.text[:200]}'"}),
|
||||||
HTTPStatus.SERVICE_UNAVAILABLE,
|
HTTPStatus.SERVICE_UNAVAILABLE,
|
||||||
)
|
)
|
||||||
|
|
||||||
if type(data) is lnurl.LnurlChannelResponse:
|
if type(data) is lnurl.LnurlChannelResponse:
|
||||||
return jsonify({"domain": domain, "kind": "channel", "error": "unsupported"}), HTTPStatus.BAD_REQUEST
|
return jsonify({"domain": domain, "kind": "channel", "message": "unsupported"}), HTTPStatus.BAD_REQUEST
|
||||||
|
|
||||||
params.update(**data.dict())
|
params.update(**data.dict())
|
||||||
|
|
||||||
|
|
@ -368,4 +371,4 @@ async def api_perform_lnurlauth():
|
||||||
await perform_lnurlauth(g.data["callback"])
|
await perform_lnurlauth(g.data["callback"])
|
||||||
return "", HTTPStatus.OK
|
return "", HTTPStatus.OK
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return jsonify({"error": str(exc)}), HTTPStatus.SERVICE_UNAVAILABLE
|
return jsonify({"message": str(exc)}), HTTPStatus.SERVICE_UNAVAILABLE
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ async def api_usermanager_users_delete(user_id):
|
||||||
async def api_usermanager_activate_extension():
|
async def api_usermanager_activate_extension():
|
||||||
user = get_user(g.data["userid"])
|
user = get_user(g.data["userid"])
|
||||||
if not user:
|
if not user:
|
||||||
return jsonify({"error": "no such user"}), HTTPStatus.NO_CONTENT
|
return jsonify({"message": "no such user"}), HTTPStatus.NOT_FOUND
|
||||||
update_user_extension(user_id=g.data["userid"], extension=g.data["extension"], active=g.data["active"])
|
update_user_extension(user_id=g.data["userid"], extension=g.data["extension"], active=g.data["active"])
|
||||||
return jsonify({"extension": "updated"}), HTTPStatus.CREATED
|
return jsonify({"extension": "updated"}), HTTPStatus.CREATED
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue