Revise landing messaging and add news feed

This commit is contained in:
Remi
2025-09-17 15:44:41 +02:00
parent 6882a93417
commit e6755d2042
17 changed files with 1286 additions and 117 deletions

View File

@@ -0,0 +1,38 @@
import { UpdateSubscriber, UpdateSubscriberDocument } from '../models/UpdateSubscriber'
interface RegisterSubscriberOptions {
email: string
name?: string
source?: string
consentPrivacy: boolean
consentMarketing: boolean
}
export async function registerUpdateSubscriber(options: RegisterSubscriberOptions) {
const { email, name, source = 'landing-updates', consentPrivacy, consentMarketing } = options
const now = new Date()
const existing = await UpdateSubscriber.findOne({ email })
if (existing) {
existing.name = name || existing.name
existing.source = source || existing.source
existing.consentPrivacy = existing.consentPrivacy || consentPrivacy
existing.consentMarketing = existing.consentMarketing || consentMarketing
existing.lastUpdatedAt = now
await existing.save()
return { created: false, document: existing as UpdateSubscriberDocument }
}
const document = await UpdateSubscriber.create({
email,
name,
source,
consentPrivacy,
consentMarketing,
subscribedAt: now,
lastUpdatedAt: now,
})
return { created: true, document }
}