mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
* WIP(guilds): AB test pester modal * WIP(AB-test): guild pester cont'd * fix(style): linting error * fix(AB-test): markModified and notif enum * fix(tests): update AB expectations * fix(modal): remove extra includes * feat(achievements): add Joined Guild cheevo Also removes unused achievement sprites, and properly saves counter used in A/B testing * fix(style): linting error from conflict
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
import mongoose from 'mongoose';
|
|
import baseModel from '../libs/baseModel';
|
|
import { v4 as uuid } from 'uuid';
|
|
import validator from 'validator';
|
|
|
|
const NOTIFICATION_TYPES = [
|
|
'DROPS_ENABLED',
|
|
'REBIRTH_ENABLED',
|
|
'WON_CHALLENGE',
|
|
'STREAK_ACHIEVEMENT',
|
|
'ULTIMATE_GEAR_ACHIEVEMENT',
|
|
'REBIRTH_ACHIEVEMENT',
|
|
'NEW_CONTRIBUTOR_LEVEL',
|
|
'CRON',
|
|
'GROUP_TASK_APPROVAL',
|
|
'GROUP_TASK_APPROVED',
|
|
'LOGIN_INCENTIVE',
|
|
'GROUP_INVITE_ACCEPTED',
|
|
'SCORED_TASK',
|
|
'BOSS_DAMAGE', // Not used currently but kept to avoid validation errors
|
|
'GUILD_PROMPT',
|
|
'GUILD_JOINED_ACHIEVEMENT',
|
|
];
|
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
export let schema = new Schema({
|
|
id: {
|
|
type: String,
|
|
default: uuid,
|
|
validate: [validator.isUUID, 'Invalid uuid.'],
|
|
required: true,
|
|
},
|
|
type: {type: String, required: true, enum: NOTIFICATION_TYPES},
|
|
data: {type: Schema.Types.Mixed, default: () => {
|
|
return {};
|
|
}},
|
|
}, {
|
|
strict: true,
|
|
minimize: false, // So empty objects are returned
|
|
_id: false, // use id instead of _id
|
|
});
|
|
|
|
schema.plugin(baseModel, {
|
|
noSet: ['_id', 'id'],
|
|
// timestamps: true, // Temporarily removed to debug a possible bug
|
|
_id: false, // use id instead of _id
|
|
});
|
|
|
|
export let model = mongoose.model('UserNotification', schema);
|