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
|
min_tickets: int = 1
|
||||||
email_notifications: bool = False
|
email_notifications: bool = False
|
||||||
nostr_notifications: bool = False
|
nostr_notifications: bool = False
|
||||||
|
notification_subject: str = ""
|
||||||
|
notification_body: str = ""
|
||||||
|
|
||||||
|
|
||||||
class CreateEvent(BaseModel):
|
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.models.users import UserNotifications
|
||||||
from lnbits.core.services.nostr import send_nostr_dm
|
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.settings import settings
|
||||||
from lnbits.utils.nostr import normalize_private_key, normalize_public_key
|
from lnbits.utils.nostr import normalize_private_key, normalize_public_key
|
||||||
from lnurl import execute
|
from lnurl import execute
|
||||||
|
|
@ -53,11 +56,15 @@ async def _send_ticket_notification(ticket: Ticket) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
ticket_url = _ticket_url(ticket)
|
ticket_url = _ticket_url(ticket)
|
||||||
message = (
|
subject = (
|
||||||
f"{settings.lnbits_site_title}\n"
|
event.extra.notification_subject.strip()
|
||||||
f"Your ticket for '{event.name}' is ready.\n"
|
or f"Your ticket for '{event.name}' is ready"
|
||||||
f"Open it here: {ticket_url}"
|
|
||||||
)
|
)
|
||||||
|
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
|
updated = False
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
@ -66,11 +73,7 @@ async def _send_ticket_notification(ticket: Ticket) -> None:
|
||||||
and ticket.email
|
and ticket.email
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
await send_user_notification(
|
await send_email_notification([ticket.email], message, subject)
|
||||||
UserNotifications(email_address=ticket.email),
|
|
||||||
message,
|
|
||||||
"text_message",
|
|
||||||
)
|
|
||||||
ticket.extra.email_notification_sent = True
|
ticket.extra.email_notification_sent = True
|
||||||
updated = True
|
updated = True
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,9 @@ window.PageEvents = {
|
||||||
allow_fiat: false,
|
allow_fiat: false,
|
||||||
fiat_currency: 'GBP',
|
fiat_currency: 'GBP',
|
||||||
extra: {
|
extra: {
|
||||||
promo_codes: []
|
promo_codes: [],
|
||||||
|
notification_subject: '',
|
||||||
|
notification_body: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +199,9 @@ window.PageEvents = {
|
||||||
min_tickets: 1,
|
min_tickets: 1,
|
||||||
email_notifications: false,
|
email_notifications: false,
|
||||||
nostr_notifications: false,
|
nostr_notifications: false,
|
||||||
promo_codes: []
|
promo_codes: [],
|
||||||
|
notification_subject: '',
|
||||||
|
notification_body: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +216,9 @@ window.PageEvents = {
|
||||||
extra: {
|
extra: {
|
||||||
email_notifications: false,
|
email_notifications: false,
|
||||||
nostr_notifications: false,
|
nostr_notifications: false,
|
||||||
promo_codes: []
|
promo_codes: [],
|
||||||
|
notification_subject: '',
|
||||||
|
notification_body: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,24 @@
|
||||||
></q-toggle>
|
></q-toggle>
|
||||||
</q-expansion-item>
|
</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">
|
<div class="row q-mt-lg">
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="formDialog.data.id"
|
v-if="formDialog.data.id"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue