Skip to content

Commit 6768b78

Browse files
committed
Custom subject and body
1 parent 0824b11 commit 6768b78

4 files changed

Lines changed: 42 additions & 13 deletions

File tree

models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class EventExtra(BaseModel):
2626
min_tickets: int = 1
2727
email_notifications: bool = False
2828
nostr_notifications: bool = False
29+
notification_subject: str = ""
30+
notification_body: str = ""
2931

3032

3133
class CreateEvent(BaseModel):

services.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
from lnbits.core.models.users import UserNotifications
66
from lnbits.core.services.nostr import send_nostr_dm
7-
from lnbits.core.services.notifications import send_user_notification
7+
from lnbits.core.services.notifications import (
8+
send_email_notification,
9+
send_user_notification,
10+
)
811
from lnbits.settings import settings
912
from lnbits.utils.nostr import normalize_private_key, normalize_public_key
1013
from lnurl import execute
@@ -53,11 +56,15 @@ async def _send_ticket_notification(ticket: Ticket) -> None:
5356
return
5457

5558
ticket_url = _ticket_url(ticket)
56-
message = (
57-
f"{settings.lnbits_site_title}\n"
58-
f"Your ticket for '{event.name}' is ready.\n"
59-
f"Open it here: {ticket_url}"
59+
subject = (
60+
event.extra.notification_subject.strip()
61+
or f"Your ticket for '{event.name}' is ready"
62+
)
63+
body = (
64+
event.extra.notification_body.strip()
65+
or f"Your ticket for '{event.name}' is ready."
6066
)
67+
message = f"{body}\n\nOpen it here: {ticket_url}"
6168
updated = False
6269

6370
if (
@@ -66,11 +73,7 @@ async def _send_ticket_notification(ticket: Ticket) -> None:
6673
and ticket.email
6774
):
6875
try:
69-
await send_user_notification(
70-
UserNotifications(email_address=ticket.email),
71-
message,
72-
"text_message",
73-
)
76+
await send_email_notification([ticket.email], message, subject)
7477
ticket.extra.email_notification_sent = True
7578
updated = True
7679
except Exception as exc:

static/js/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ window.PageEvents = {
101101
allow_fiat: false,
102102
fiat_currency: 'GBP',
103103
extra: {
104-
promo_codes: []
104+
promo_codes: [],
105+
notification_subject: '',
106+
notification_body: ''
105107
}
106108
}
107109
}
@@ -197,7 +199,9 @@ window.PageEvents = {
197199
min_tickets: 1,
198200
email_notifications: false,
199201
nostr_notifications: false,
200-
promo_codes: []
202+
promo_codes: [],
203+
notification_subject: '',
204+
notification_body: ''
201205
}
202206
}
203207
}
@@ -212,7 +216,9 @@ window.PageEvents = {
212216
extra: {
213217
email_notifications: false,
214218
nostr_notifications: false,
215-
promo_codes: []
219+
promo_codes: [],
220+
notification_subject: '',
221+
notification_body: ''
216222
}
217223
}
218224
},

static/js/index.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,24 @@
513513
></q-toggle>
514514
</q-expansion-item>
515515

516+
<q-separator class="q-my-md"></q-separator>
517+
<q-input
518+
filled
519+
dense
520+
v-model.trim="formDialog.data.extra.notification_subject"
521+
type="text"
522+
label="Ticket notification subject"
523+
hint="Used as the email subject when sending paid ticket links."
524+
></q-input>
525+
<q-input
526+
filled
527+
dense
528+
v-model.trim="formDialog.data.extra.notification_body"
529+
type="textarea"
530+
label="Ticket notification body"
531+
hint="Shown before the ticket link in the paid ticket notification."
532+
></q-input>
533+
516534
<div class="row q-mt-lg">
517535
<q-btn
518536
v-if="formDialog.data.id"

0 commit comments

Comments
 (0)