From 6768b78c6fd5cb329ffc126e55998c9d7167b043 Mon Sep 17 00:00:00 2001 From: Arc Date: Fri, 8 May 2026 19:14:07 +0100 Subject: [PATCH] Custom subject and body --- models.py | 2 ++ services.py | 23 +++++++++++++---------- static/js/index.js | 12 +++++++++--- static/js/index.vue | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/models.py b/models.py index 20037ec..fa1569f 100644 --- a/models.py +++ b/models.py @@ -26,6 +26,8 @@ class EventExtra(BaseModel): min_tickets: int = 1 email_notifications: bool = False nostr_notifications: bool = False + notification_subject: str = "" + notification_body: str = "" class CreateEvent(BaseModel): diff --git a/services.py b/services.py index 60626fd..479aaa1 100644 --- a/services.py +++ b/services.py @@ -4,7 +4,10 @@ from asyncio.tasks import create_task from lnbits.core.models.users import UserNotifications from lnbits.core.services.nostr import send_nostr_dm -from lnbits.core.services.notifications import send_user_notification +from lnbits.core.services.notifications import ( + send_email_notification, + send_user_notification, +) from lnbits.settings import settings from lnbits.utils.nostr import normalize_private_key, normalize_public_key from lnurl import execute @@ -53,11 +56,15 @@ async def _send_ticket_notification(ticket: Ticket) -> None: return ticket_url = _ticket_url(ticket) - message = ( - f"{settings.lnbits_site_title}\n" - f"Your ticket for '{event.name}' is ready.\n" - f"Open it here: {ticket_url}" + subject = ( + event.extra.notification_subject.strip() + or f"Your ticket for '{event.name}' is ready" ) + body = ( + event.extra.notification_body.strip() + or f"Your ticket for '{event.name}' is ready." + ) + message = f"{body}\n\nOpen it here: {ticket_url}" updated = False if ( @@ -66,11 +73,7 @@ async def _send_ticket_notification(ticket: Ticket) -> None: and ticket.email ): try: - await send_user_notification( - UserNotifications(email_address=ticket.email), - message, - "text_message", - ) + await send_email_notification([ticket.email], message, subject) ticket.extra.email_notification_sent = True updated = True except Exception as exc: diff --git a/static/js/index.js b/static/js/index.js index 07e1b46..d53ed90 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -101,7 +101,9 @@ window.PageEvents = { allow_fiat: false, fiat_currency: 'GBP', extra: { - promo_codes: [] + promo_codes: [], + notification_subject: '', + notification_body: '' } } } @@ -197,7 +199,9 @@ window.PageEvents = { min_tickets: 1, email_notifications: false, nostr_notifications: false, - promo_codes: [] + promo_codes: [], + notification_subject: '', + notification_body: '' } } } @@ -212,7 +216,9 @@ window.PageEvents = { extra: { email_notifications: false, nostr_notifications: false, - promo_codes: [] + promo_codes: [], + notification_subject: '', + notification_body: '' } } }, diff --git a/static/js/index.vue b/static/js/index.vue index 06729f3..0c21058 100644 --- a/static/js/index.vue +++ b/static/js/index.vue @@ -513,6 +513,24 @@ > + + + +