Custom subject and body
This commit is contained in:
parent
0824b1120b
commit
6768b78c6f
4 changed files with 42 additions and 13 deletions
|
|
@ -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):
|
||||
|
|
|
|||
23
services.py
23
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:
|
||||
|
|
|
|||
|
|
@ -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: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -513,6 +513,24 @@
|
|||
></q-toggle>
|
||||
</q-expansion-item>
|
||||
|
||||
<q-separator class="q-my-md"></q-separator>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="formDialog.data.extra.notification_subject"
|
||||
type="text"
|
||||
label="Ticket notification subject"
|
||||
hint="Used as the email subject when sending paid ticket links."
|
||||
></q-input>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="formDialog.data.extra.notification_body"
|
||||
type="textarea"
|
||||
label="Ticket notification body"
|
||||
hint="Shown before the ticket link in the paid ticket notification."
|
||||
></q-input>
|
||||
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
v-if="formDialog.data.id"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue