From 64bfcf2f7cccb5bdedeb7c1a1efc4ea85ec434f7 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 19 Oct 2023 12:10:06 +0100 Subject: [PATCH] allow name without extra splits --- README.md | 11 ++--------- views_api.py | 14 ++++---------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3a6f1e4..c24ee49 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,8 @@ The TipJar extension allows you to integrate Bitcoin Lightning (and on-chain) ti

How to set it up

1. Simply create a new Tip Jar with the desired details (onchain and webhook optional): -![image](https://user-images.githubusercontent.com/28876473/134996842-ec2f2783-2eef-4671-8eaf-023713865512.png) + ![image](https://user-images.githubusercontent.com/28876473/134996842-ec2f2783-2eef-4671-8eaf-023713865512.png) 1. Share the URL you get from this little button: -![image](https://user-images.githubusercontent.com/28876473/134996973-f8ed4632-ea2f-4b62-83f1-1e4c6b6c91fa.png) - -

A note on webhooks

- -The `description` field of the message POSTed to your webhook will be in the following format: - * `{length of the name}|{name}{message}` - -You can split along the first `|`. This will give you the index at which to split between the name of the tipper and the message of the tipper. + ![image](https://user-images.githubusercontent.com/28876473/134996973-f8ed4632-ea2f-4b62-83f1-1e4c6b6c91fa.png)

And that's it already! Let the sats flow!

diff --git a/views_api.py b/views_api.py index 302a265..9bb65e1 100644 --- a/views_api.py +++ b/views_api.py @@ -65,13 +65,12 @@ async def api_create_tip(data: createTips): if not name: name = "Anonymous" - # Ensure that description string can be split reliably - description = f"{len(name)}|{name}{message}" charge_id = await create_charge( data={ "amount": sats, "webhook": tipjar.webhook or "", - "description": description, + "name": name, + "description": message, "onchainwallet": tipjar.onchain or "", "lnbitswallet": tipjar.wallet, "completelink": "/tipjar/" + str(tipjar_id), @@ -136,7 +135,6 @@ async def api_update_tip( ) if tip.wallet != wallet.wallet.id: - raise HTTPException( status_code=HTTPStatus.FORBIDDEN, detail="Not your tip." ) @@ -178,9 +176,7 @@ async def api_update_tipjar( @tipjar_ext.delete("/api/v1/tips/{tip_id}") -async def api_delete_tip( - tip_id: str, wallet: WalletTypeInfo = Depends(get_key_type) -): +async def api_delete_tip(tip_id: str, wallet: WalletTypeInfo = Depends(get_key_type)): """Delete the tip with the given tip_id""" tip = await get_tip(tip_id) if not tip: @@ -200,8 +196,7 @@ async def api_delete_tip( @tipjar_ext.delete("/api/v1/tipjars/{tipjar_id}") async def api_delete_tipjar( - tipjar_id: int, - wallet: WalletTypeInfo = Depends(get_key_type) + tipjar_id: int, wallet: WalletTypeInfo = Depends(get_key_type) ): """Delete the tipjar with the given tipjar_id""" tipjar = await get_tipjar(tipjar_id) @@ -210,7 +205,6 @@ async def api_delete_tipjar( status_code=HTTPStatus.NOT_FOUND, detail="No tipjar with this ID!" ) if tipjar.wallet != wallet.wallet.id: - raise HTTPException( status_code=HTTPStatus.FORBIDDEN, detail="Not authorized to delete this tipjar!",