Merge branch 'auto-lnurlp-acct' into dev-pm
This commit is contained in:
commit
a45d7ad11d
1 changed files with 27 additions and 8 deletions
|
|
@ -198,9 +198,31 @@ async def init_admin_settings(super_user: Optional[str] = None) -> SuperSettings
|
||||||
async def _create_default_pay_link(account: Account, wallet) -> None:
|
async def _create_default_pay_link(account: Account, wallet) -> None:
|
||||||
"""Create a default pay link for new users with username (Bitcoinmat receiving address)"""
|
"""Create a default pay link for new users with username (Bitcoinmat receiving address)"""
|
||||||
try:
|
try:
|
||||||
# Import here to avoid circular imports
|
# Try dynamic import that works with extensions in different locations
|
||||||
from lnbits.extensions.lnurlp.crud import create_pay_link
|
import importlib
|
||||||
from lnbits.extensions.lnurlp.models import CreatePayLinkData
|
import sys
|
||||||
|
|
||||||
|
# First try the standard import path
|
||||||
|
try:
|
||||||
|
lnurlp_crud = importlib.import_module("lnbits.extensions.lnurlp.crud")
|
||||||
|
lnurlp_models = importlib.import_module("lnbits.extensions.lnurlp.models")
|
||||||
|
except ImportError:
|
||||||
|
# If that fails, try importing from external extensions path
|
||||||
|
# This handles cases where extensions are in /var/lib/lnbits/extensions
|
||||||
|
try:
|
||||||
|
# Add extensions path to sys.path if not already there
|
||||||
|
extensions_path = settings.lnbits_extensions_path or "/var/lib/lnbits/extensions"
|
||||||
|
if extensions_path not in sys.path:
|
||||||
|
sys.path.insert(0, extensions_path)
|
||||||
|
|
||||||
|
lnurlp_crud = importlib.import_module("lnurlp.crud")
|
||||||
|
lnurlp_models = importlib.import_module("lnurlp.models")
|
||||||
|
except ImportError as e:
|
||||||
|
logger.warning(f"lnurlp extension not found in any location: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
|
create_pay_link = lnurlp_crud.create_pay_link
|
||||||
|
CreatePayLinkData = lnurlp_models.CreatePayLinkData
|
||||||
|
|
||||||
pay_link_data = CreatePayLinkData(
|
pay_link_data = CreatePayLinkData(
|
||||||
description="Bitcoinmat Receiving Address",
|
description="Bitcoinmat Receiving Address",
|
||||||
|
|
@ -215,11 +237,8 @@ async def _create_default_pay_link(account: Account, wallet) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
await create_pay_link(pay_link_data)
|
await create_pay_link(pay_link_data)
|
||||||
|
logger.info(f"Successfully created default pay link for user {account.username}")
|
||||||
|
|
||||||
except ImportError as e:
|
|
||||||
logger.warning(
|
|
||||||
f"lnurlp extension not available for creating default pay link: {e}"
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to create default pay link: {e}")
|
logger.error(f"Failed to create default pay link: {e}")
|
||||||
raise
|
# Don't raise - we don't want user creation to fail if pay link creation fails
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue