feat(admin): consentement aux annonces et désabonnement sans connexion
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 5m58s
CI / Deploy production (on server) (push) Successful in 26s

Les comptes déjà créés ne sont pas inscrits. Le choix est facultatif à l’inscription et dans les paramètres. Un lien public demande confirmation avant d’arrêter les actualités, sans toucher aux messages de compte.
This commit is contained in:
Antigravity
2026-09-06 09:23:10 +00:00
parent 6fa12f6e13
commit 360e58e473
33 changed files with 1036 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
'use server'
import { auth } from '@/auth'
import { marketingConsentText } from '@/lib/marketing/consent-copy'
import { getMarketingPreferenceView, setMarketingOptIn } from '@/lib/marketing/preference'
import { marketingRequestMeta } from '@/lib/marketing/request-meta'
export async function getMyMarketingPreference() {
const session = await auth()
const userId = (session?.user as { id?: string } | undefined)?.id
if (!userId) return null
return getMarketingPreferenceView(userId)
}
export async function updateMyMarketingPreference(optedIn: boolean, language?: string) {
const session = await auth()
const userId = (session?.user as { id?: string } | undefined)?.id
if (!userId) return { ok: false as const, error: 'auth' as const }
const meta = await marketingRequestMeta()
const result = await setMarketingOptIn({
userId,
optedIn,
source: 'settings',
language: language || null,
meta,
})
if (!result.ok) return { ok: false as const, error: result.error }
return { ok: true as const, legalText: optedIn ? marketingConsentText(language) : null }
}