Skip to content

Commit

Permalink
fix: messages on tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
talvasconcelos committed Oct 11, 2024
1 parent 7b6ac01 commit 67cc762
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def private_key(self) -> PrivateKey:

@property
def public_key(self) -> str:
return P
return self.private_key.public_key.hex()



Expand Down
17 changes: 13 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
from lnbits.tasks import register_invoice_listener
from lnbits.utils.exchange_rates import fiat_amount_as_satoshis

from .crud import get_appointment, get_schedule, set_appointment_paid
from .crud import (
get_appointment,
get_or_create_calendar_settings,
get_schedule,
set_appointment_paid,
)
from .helpers import normalize_public_key
from .services import nostr_send_msg

Expand Down Expand Up @@ -44,7 +49,12 @@ async def on_invoice_paid(payment: Payment) -> None:

if abs(payment.amount) >= lower_bound: # allow 1% error
await set_appointment_paid(payment.payment_hash)
if schedule.public_key:
settings = await get_or_create_calendar_settings()
if not settings or not settings.nostr_private_key:
return

if schedule.public_key and appointment.nostr_pubkey:

# notify the user that the appointment has been paid
pubkey = schedule.pubkey_hex
assert pubkey
Expand All @@ -59,8 +69,7 @@ async def on_invoice_paid(payment: Payment) -> None:
"""
await nostr_send_msg(pubkey, msg)

if appointment.nostr_pubkey:
#notify client that the appointment has been paid
# notify client that the appointment has been paid
pubkey = normalize_public_key(appointment.nostr_pubkey)
msg = f"""
[DO NOT REPLY TO THIS MESSAGE]
Expand Down
1 change: 1 addition & 0 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async def api_appointment_create(data: CreateAppointment):
memo=f"{schedule.name}",
extra={"tag": "lncalendar", "name": data.name, "email": data.email},
)

await create_appointment(
schedule_id=data.schedule, payment_hash=payment_hash, data=data
)
Expand Down

0 comments on commit 67cc762

Please sign in to comment.