// user-notification.js // Copyright (C) 2022 DTP Technologies, LLC // License: Apache-2.0 'use strict'; const mongoose = require('mongoose'); const Schema = mongoose.Schema; const NOTIFICATION_STATUS_LIST = ['new', 'seen']; /* * A notification is a user-specific bookmark to an event we know the user is * interested in. These are the "timelines" presented to members. * * Notifications are only created for LOCAL users (not Core users). A * notification sent to a CoreUser will be delivered to their Core. When it * arrives, it becomes a UserNotification for that local user on that Core. */ const UserNotificationSchema = new Schema({ created: { type: Date, default: Date.now, required: true, index: -1, expires: '7d' }, user: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' }, status: { type: String, enum: NOTIFICATION_STATUS_LIST, default: 'new', required: true }, event: { type: Schema.ObjectId, required: true, ref: 'KaleidoscopeEvent' }, }); module.exports = mongoose.model('UserNotification', UserNotificationSchema);