Branded email template + footer pages: help center, token unsubscribe, settings deep links
release gate / check (push) Failing after 6m56s
release gate / check (push) Failing after 6m56s
Transactional mail now goes out as the Superbrain HTML design
(internal/mailer/template.html, embedded verbatim) with a plain-text
alternative: multipart/alternative (plain first per RFC 2046), random
boundary, CRLF normalization and SMTP dot-stuffing. Render() fills the
{{placeholders}} with HTML-escaped values and removes optional sections
(CTA + fallback link, note block, footer links, address) when empty;
anchor drift fails the unit tests and degrades to plain text at send
time, never blocking delivery. Password reset gets the headline,
first-name greeting, "Choose a new password" button (Outlook VML
fallback) and expiry/single-use note; notification and agent emails
render title-as-headline with body paragraphs.
The template's footer links are now real pages:
- /help: public help center (10 topic sections + FAQ accordion), linked
from the login page.
- /unsubscribe?token=...: public confirmation page; the HMAC-signed user
id (notify.UnsubscribeToken, domain-separated, stable, no stored row)
IS the credential. POST /api/notifications/unsubscribe accepts the
RFC 8058 one-click shape (token in query, form body ignored) and the
browser JSON shape; it disables the user's enabled email channels and
pauses enabled agent email tasks addressed to their own email
(idempotent, re-enableable, per-client rate limited, audit logged).
- Email preferences deep-links to /settings?tab=notifications; Settings
now honors ?tab=<section> (unknown values fall back to profile).
notify.FooterLinks is the single eligibility point: preferences + help
whenever NEXTAUTH_URL is set; unsubscribe ONLY when the recipient is the
owner's own account email — third-party channel addresses and agent
recipients never receive a link that changes someone else's settings,
and transactional mail (password reset) never carries unsubscribe.
Owner-addressed mail also carries List-Unsubscribe +
List-Unsubscribe-Post headers.
Verified: Go build/vet/unit green; new TestUnsubscribeFlow integration
test pins footer + headers, blast radius (slack channel and third-party
task survive), one-click + JSON paths, idempotence, tampered tokens and
the third-party/transactional exclusions; notifications, phase-2,
password-reset and agent suites green; web lint/SSR-lint/build 0 errors;
full browser regressions pass; live smoke of /help, /unsubscribe states,
the settings deep-link auth gate and bad-token 400 through the proxy.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState, useEffect, useCallback, Fragment } from 'react'
|
||||
import { useSession } from 'next-auth/react'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
|
||||
@@ -50,17 +51,25 @@ const NAV_GROUPS = [
|
||||
|
||||
export function SettingsClient({ oidc, callbackUrl }: { oidc: OidcStatus; callbackUrl: string }) {
|
||||
const { data: session } = useSession()
|
||||
// ?tab=<value> deep links (email footer "Email preferences" lands on
|
||||
// notifications). Unknown values fall back to profile; the Radix tab
|
||||
// values stay the canonical section ids.
|
||||
const requestedTab = useSearchParams().get('tab') ?? ''
|
||||
const initialSection = NAV_GROUPS.some(g => g.items.some(i => i.value === requestedTab))
|
||||
? requestedTab
|
||||
: 'profile'
|
||||
const [imapConfig, setImapConfig] = useState({ host: '', port: 993, tls: true, username: '', password: '', folder: 'INBOX' })
|
||||
const [ncConfig, setNcConfig] = useState({ nextcloudUrl: '', cardDavPath: '', username: '', password: '' })
|
||||
const [savingImap, setSavingImap] = useState(false)
|
||||
const [testingImap, setTestingImap] = useState(false)
|
||||
const [syncingContacts, setSyncingContacts] = useState(false)
|
||||
const [section, setSection] = useState('profile')
|
||||
const [section, setSection] = useState(initialSection)
|
||||
// Below md the grouped nav becomes a list -> detail flow (same
|
||||
// master-detail pattern as collections/tags/contacts); at md+ the
|
||||
// nav and the selected panel sit side by side.
|
||||
// nav and the selected panel sit side by side. A deep link opens the
|
||||
// detail pane directly on narrow screens.
|
||||
const isNarrow = useMediaQuery('(max-width: 767px)')
|
||||
const [mobileDetail, setMobileDetail] = useState(false)
|
||||
const [mobileDetail, setMobileDetail] = useState(initialSection !== 'profile')
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/settings/imap').then(r => r.json()).then(data => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { SettingsClient } from './client'
|
||||
import { getOidcStatus } from '@/lib/oidc-config'
|
||||
import { headers } from 'next/headers'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
@@ -20,5 +21,11 @@ export default async function SettingsPage() {
|
||||
const proto = h.get('x-forwarded-proto') ?? 'http'
|
||||
if (host) callbackUrl = `${proto}://${host}/api/auth/callback/authelia`
|
||||
}
|
||||
return <SettingsClient oidc={getOidcStatus()} callbackUrl={callbackUrl} />
|
||||
// useSearchParams in the client (?tab= deep links, e.g. from email
|
||||
// footers) needs a Suspense boundary for prerender.
|
||||
return (
|
||||
<Suspense>
|
||||
<SettingsClient oidc={getOidcStatus()} callbackUrl={callbackUrl} />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user