You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

// user-notification.js
// Copyright (C) 2022 DTP Technologies, LLC
// License: Apache-2.0
'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
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: ['new', 'seen'], default: 'new', required: true },
action: { type: String, required: true, lowercase: true },
label: { type: String },
content: { type: String },
href: { type: String },
source: {
pkg: {
name: { type: String, required: true },
version: { type: String, required: true },
},
site: {
name: { type: String, required: true },
description: { type: String },
domain: { type: String, lowercase: true, required: true },
domainKey: { type: String, lowercase: true, required: true },
company: { type: String },
coreAuth: {
scopes: { type: [String] },
},
},
author: {
userId: { type: Schema.ObjectId, required: true },
displayName: { type: String },
username: { type: String },
href: { type: String },
},
},
attachmentType: { type: String },
attachment: { type: Schema.ObjectId, refPath: 'attachmentType' },
});
module.exports = mongoose.model('UserNotification', UserNotificationSchema);