fixed create_service from sending html and showing correctly on create

This commit is contained in:
Tiago vasconcelos 2021-08-02 10:25:06 +01:00
parent 32764d1bad
commit 91f082eb69
2 changed files with 12 additions and 6 deletions

View File

@ -447,6 +447,7 @@
LNbits.api LNbits.api
.request('POST', '/streamalerts/api/v1/services', wallet.inkey, data) .request('POST', '/streamalerts/api/v1/services', wallet.inkey, data)
.then(function (response) { .then(function (response) {
console.log(response)
self.services.push(mapStreamAlerts(response.data)) self.services.push(mapStreamAlerts(response.data))
self.serviceDialog.show = false self.serviceDialog.show = false
self.serviceDialog.data = {} self.serviceDialog.data = {}

View File

@ -39,12 +39,17 @@ from ..satspay.crud import create_charge, get_charge
) )
async def api_create_service(): async def api_create_service():
"""Create a service, which holds data about how/where to post donations""" """Create a service, which holds data about how/where to post donations"""
service = await create_service(**g.data) try:
wallet = await get_wallet(service.wallet) service = await create_service(**g.data)
user = wallet.user except Exception as e:
redirect_url = request.scheme + "://" + request.headers["Host"] return jsonify({"message": str(e)}), HTTPStatus.INTERNAL_SERVER_ERROR
redirect_url += f"/streamalerts/?usr={user}&created={str(service.id)}" # wallet = await get_wallet(service.wallet)
return redirect(redirect_url) # user = wallet.user
# redirect_url = request.scheme + "://" + request.headers["Host"]
# redirect_url += f"/streamalerts/?usr={user}&created={str(service.id)}"
# return redirect(redirect_url)
return jsonify(service._asdict()), HTTPStatus.CREATED
@streamalerts_ext.route("/api/v1/getaccess/<service_id>", methods=["GET"]) @streamalerts_ext.route("/api/v1/getaccess/<service_id>", methods=["GET"])