mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
incrementally enable weekly recap emails
This commit is contained in:
@@ -154,6 +154,8 @@ var UserSchema = new Schema({
|
|||||||
weeklyRecapEmailsPhase: {type: Number, 'default': 0},
|
weeklyRecapEmailsPhase: {type: Number, 'default': 0},
|
||||||
// Used to track when the next weekly recap should be sent
|
// Used to track when the next weekly recap should be sent
|
||||||
lastWeeklyRecap: {type: Date, 'default': Date.now},
|
lastWeeklyRecap: {type: Date, 'default': Date.now},
|
||||||
|
// Used to enable weekly recap emails as users login
|
||||||
|
lastWeeklyRecapDiscriminator: Boolean,
|
||||||
communityGuidelinesAccepted: {type: Boolean, 'default': false},
|
communityGuidelinesAccepted: {type: Boolean, 'default': false},
|
||||||
cronCount: {type:Number, 'default':0},
|
cronCount: {type:Number, 'default':0},
|
||||||
welcomed: {type: Boolean, 'default': false},
|
welcomed: {type: Boolean, 'default': false},
|
||||||
@@ -517,8 +519,11 @@ UserSchema.pre('save', function(next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable weekly recap emails for old users who sign in
|
// Enable weekly recap emails for old users who sign in
|
||||||
if(this.flags.lastWeeklyRecapDiscriminator === true){
|
if(this.flags.lastWeeklyRecapDiscriminator){
|
||||||
|
// Enable weekly recap emails in 24 hours
|
||||||
this.flags.lastWeeklyRecap = moment().subtract(6, 'days').toDate();
|
this.flags.lastWeeklyRecap = moment().subtract(6, 'days').toDate();
|
||||||
|
// Unset the field so this is run only once
|
||||||
|
this.flags.lastWeeklyRecapDiscriminator = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXAMPLE CODE for allowing all existing and new players to be
|
// EXAMPLE CODE for allowing all existing and new players to be
|
||||||
|
|||||||
Reference in New Issue
Block a user