mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-09 02:56:02 +08:00
Revise landing messaging and add news feed
This commit is contained in:
32
server/models/UpdateSubscriber.ts
Normal file
32
server/models/UpdateSubscriber.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import mongoose from 'mongoose'
|
||||
|
||||
export interface UpdateSubscriberDocument extends mongoose.Document {
|
||||
email: string
|
||||
name?: string
|
||||
source: string
|
||||
consentPrivacy: boolean
|
||||
consentMarketing: boolean
|
||||
subscribedAt: Date
|
||||
lastUpdatedAt: Date
|
||||
}
|
||||
|
||||
const updateSubscriberSchema = new mongoose.Schema<UpdateSubscriberDocument>({
|
||||
email: { type: String, required: true, lowercase: true, trim: true, unique: true },
|
||||
name: { type: String, trim: true },
|
||||
source: { type: String, default: 'landing-updates' },
|
||||
consentPrivacy: { type: Boolean, default: false },
|
||||
consentMarketing: { type: Boolean, default: false },
|
||||
subscribedAt: { type: Date, default: () => new Date() },
|
||||
lastUpdatedAt: { type: Date, default: () => new Date() },
|
||||
})
|
||||
|
||||
updateSubscriberSchema.pre('save', function updateTimestamp(this: UpdateSubscriberDocument, next) {
|
||||
if (this.isModified()) {
|
||||
this.set('lastUpdatedAt', new Date())
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
export const UpdateSubscriber =
|
||||
(mongoose.models.UpdateSubscriber as mongoose.Model<UpdateSubscriberDocument> | undefined) ||
|
||||
mongoose.model<UpdateSubscriberDocument>('UpdateSubscriber', updateSubscriberSchema)
|
||||
Reference in New Issue
Block a user