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.
41 lines
960 B
41 lines
960 B
// emoji-reaction.js
|
|
// Copyright (C) 2022 DTP Technologies, LLC
|
|
// License: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
const REACTION_LIST = [
|
|
'clap',
|
|
'fire',
|
|
'happy',
|
|
'laugh',
|
|
'angry',
|
|
'honk',
|
|
];
|
|
|
|
const EmojiReactionSchema = new Schema({
|
|
created: { type: Date, default: Date.now, required: true, index: -1, expires: '30d' },
|
|
|
|
/*
|
|
* The thing for which a reaction is being filed.
|
|
*/
|
|
subjectType: { type: String, required: true },
|
|
subject: { type: Schema.ObjectId, required: true, index: 1, refPath: 'subjectType' },
|
|
|
|
/*
|
|
* The user creating the reaction
|
|
*/
|
|
userType: { type: String, required: true },
|
|
user: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' },
|
|
|
|
reaction: { type: String, enum: REACTION_LIST, required: true },
|
|
timestamp: { type: Number },
|
|
});
|
|
|
|
module.exports = (conn) => {
|
|
return conn.model('EmojiReaction', EmojiReactionSchema);
|
|
};
|