mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-30 05:48:44 +02:00
fix issue #267
This commit is contained in:
committed by
fiatjaf
parent
a32e43b2bb
commit
16f8071731
@@ -16,8 +16,14 @@ async def create_pay_link(
|
|||||||
success_text: Optional[str] = None,
|
success_text: Optional[str] = None,
|
||||||
success_url: Optional[str] = None,
|
success_url: Optional[str] = None,
|
||||||
) -> PayLink:
|
) -> PayLink:
|
||||||
result = await db.execute(
|
|
||||||
"""
|
if db.type == "POSTGRES" or db.type == "COCKROACH":
|
||||||
|
returning = "RETURNING id"
|
||||||
|
else:
|
||||||
|
returning = ""
|
||||||
|
|
||||||
|
result = await db.fetchone(
|
||||||
|
f"""
|
||||||
INSERT INTO lnurlp.pay_links (
|
INSERT INTO lnurlp.pay_links (
|
||||||
wallet,
|
wallet,
|
||||||
description,
|
description,
|
||||||
@@ -32,6 +38,7 @@ async def create_pay_link(
|
|||||||
currency
|
currency
|
||||||
)
|
)
|
||||||
VALUES (?, ?, ?, ?, 0, 0, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, 0, 0, ?, ?, ?, ?, ?)
|
||||||
|
{returning}
|
||||||
""",
|
""",
|
||||||
(
|
(
|
||||||
wallet_id,
|
wallet_id,
|
||||||
@@ -45,7 +52,11 @@ async def create_pay_link(
|
|||||||
currency,
|
currency,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
if db.type == "POSTGRES" or db.type == "COCKROACH":
|
||||||
|
link_id = result[0]
|
||||||
|
else:
|
||||||
link_id = result._result_proxy.lastrowid
|
link_id = result._result_proxy.lastrowid
|
||||||
|
|
||||||
link = await get_pay_link(link_id)
|
link = await get_pay_link(link_id)
|
||||||
assert link, "Newly created link couldn't be retrieved"
|
assert link, "Newly created link couldn't be retrieved"
|
||||||
return link
|
return link
|
||||||
@@ -68,7 +79,6 @@ async def get_pay_links(wallet_ids: Union[str, List[str]]) -> List[PayLink]:
|
|||||||
""",
|
""",
|
||||||
(*wallet_ids,),
|
(*wallet_ids,),
|
||||||
)
|
)
|
||||||
|
|
||||||
return [PayLink.from_row(row) for row in rows]
|
return [PayLink.from_row(row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user