contact messages: mailto recipient is Brand <email>
The contact-email frame now carries the RFC-encoded recipient (John Smith <john@example.com> → John%20Smith%20%3Cjohn@example.com%3E), encoded server-side where the current brand lives; the link text stays the bare address and the localized subject rides the query as before.
This commit is contained in:
1 parent
8d577dc56e
commit
c568af8285
3 files changed
+17
-4
No files matched your search
@@ -20,10 +20,11 @@ const emit = defineEmits(['send', 'close'])
|
||||
const admin = computed(() => props.state.mode === 'admin')
|
||||
|
||||
// The visitor dialog's title is the localized site contact label (the
|
||||
// {contact:} buttons' default label); the mailto link carries the
|
||||
// localized subject.
|
||||
// {contact:} buttons' default label). The mailto href carries the
|
||||
// server-encoded "Brand <email>" recipient and the localized subject;
|
||||
// the link text is the bare address.
|
||||
const mailto = computed(
|
||||
() => `mailto:${props.state.email}?subject=${encodeURIComponent(props.state.subject)}`
|
||||
() => `mailto:${props.state.mailtoTo}?subject=${encodeURIComponent(props.state.subject)}`
|
||||
)
|
||||
|
||||
// Escape closes, like the paskia dialogs whose backdrop we share.
|
||||
|
||||
@@ -31,6 +31,7 @@ const state = reactive({
|
||||
// link with subject prefilled.
|
||||
label: 'Contact us',
|
||||
email: '',
|
||||
mailtoTo: '', // RFC-encoded "Brand <email>" recipient for the mailto href
|
||||
subject: '',
|
||||
})
|
||||
|
||||
@@ -145,6 +146,7 @@ function onPow(msg) {
|
||||
|
||||
function onEmail(msg) {
|
||||
state.email = msg.email || ''
|
||||
state.mailtoTo = msg.to || '' // RFC-encoded "Brand <email>" recipient
|
||||
}
|
||||
|
||||
// An upload hit the end of the PoW quota: re-register (the server pushes
|
||||
|
||||
+11
-1
@@ -265,7 +265,17 @@ async def visitor_proven(ws: WebSocket, raw: dict) -> bytes | None:
|
||||
_quota[key] = POW_QUOTA
|
||||
await ws.send_json({"type": "pow", "quota": POW_QUOTA})
|
||||
if data.contact_email:
|
||||
await ws.send_json({"type": "contact-email", "email": data.contact_email})
|
||||
# The mailto recipient is "Brand <email>" (RFC-encoded here; the
|
||||
# link text is the bare address, the subject is the client's
|
||||
# localized contact_subject).
|
||||
recipient = (
|
||||
quote(f"{data.brand} <{data.contact_email}>", safe="@")
|
||||
if data.brand.strip()
|
||||
else quote(data.contact_email, safe="@")
|
||||
)
|
||||
await ws.send_json(
|
||||
{"type": "contact-email", "email": data.contact_email, "to": recipient}
|
||||
)
|
||||
return key
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user