Fix case where a number was sometimes a string

This commit is contained in:
Phillip Thelen
2022-12-09 12:16:33 +01:00
parent 8b2af1ef56
commit cde5fbef85
2 changed files with 22 additions and 0 deletions
@@ -52,6 +52,9 @@ schema.plugin(baseModel, {
schema.methods.incrementPerkCounterAndReward = async function incrementPerkCounterAndReward
(userID, adding) {
if (typeof adding === 'string' || adding instanceof String) {
adding = parseInt(adding)
}
// if perkMonthCount wasn't used before, initialize it.
if (this.perkMonthCount == undefined && adding == 1) {
this.perkMonthCount = (this.consecutive.count-1) % SUBSCRIPTION_BASIC_BLOCK_LENGTH;