|
|
|
@ -7,6 +7,8 @@
|
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
|
|
const EMITTER_TYPE_LIST = ['User','CoreUser','OAuth2Client'];
|
|
|
|
|
|
|
|
|
|
const KaleidoscopeEventSchema = new Schema({
|
|
|
|
|
created: { type: Date, default: Date.now, required: true, index: -1, expires: '30d' },
|
|
|
|
|
action: { type: String, required: true, lowercase: true },
|
|
|
|
@ -28,8 +30,9 @@ const KaleidoscopeEventSchema = new Schema({
|
|
|
|
|
scopes: { type: [String] },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
author: {
|
|
|
|
|
userId: { type: Schema.ObjectId, required: true },
|
|
|
|
|
emitter: {
|
|
|
|
|
emitterType: { type: String, enum: EMITTER_TYPE_LIST },
|
|
|
|
|
emitterId: { type: Schema.ObjectId, refPath: 'source.emitter.emitterType' },
|
|
|
|
|
displayName: { type: String },
|
|
|
|
|
username: { type: String },
|
|
|
|
|
href: { type: String },
|
|
|
|
@ -45,7 +48,7 @@ const KaleidoscopeEventSchema = new Schema({
|
|
|
|
|
*/
|
|
|
|
|
KaleidoscopeEventSchema.index({
|
|
|
|
|
'source.site.domainKey': 1,
|
|
|
|
|
'source.author.userId': 1,
|
|
|
|
|
'source.emitter.emitterId': 1,
|
|
|
|
|
}, {
|
|
|
|
|
name: 'evtsrc_site_author_index',
|
|
|
|
|
});
|
|
|
|
|