playov2-js-utilities 0.3.69 → 0.3.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -28
- package/index.js +4 -4
- package/lib/constants.js +20 -20
- package/lib/cron.js +43 -43
- package/lib/db/models/user.js +112 -0
- package/lib/db/mongo.js +3 -0
- package/lib/db_interface/mongo/index.js +5 -5
- package/lib/db_interface/mongo/schemas/activitySchemas/_activityIndex.js +10 -10
- package/lib/db_interface/mongo/schemas/activitySchemas/activityInsurance.js +17 -17
- package/lib/db_interface/mongo/schemas/activitySchemas/activityLocation.js +104 -104
- package/lib/db_interface/mongo/schemas/activitySchemas/activityQueryBlock.js +11 -11
- package/lib/db_interface/mongo/schemas/activitySchemas/activityView.js +13 -13
- package/lib/db_interface/mongo/schemas/activitySchemas/cronJobLog.js +12 -12
- package/lib/db_interface/mongo/schemas/activitySchemas/playogame.request.js +37 -37
- package/lib/db_interface/mongo/schemas/activitySchemas/scheduled.tasks.js +52 -52
- package/lib/db_interface/mongo/schemas/activitySchemas/userActivity.js +133 -133
- package/lib/db_interface/mongo/schemas/gamebookSchemas/_gamebookIndex.js +2 -2
- package/lib/db_interface/mongo/schemas/gamebookSchemas/activityNotes.js +19 -19
- package/lib/db_interface/mongo/schemas/gamebookSchemas/expense.js +36 -36
- package/lib/db_interface/mongo/schemas/gamebookSchemas/expenseLogs.js +13 -13
- package/lib/db_interface/mongo/schemas/gamebookSchemas/message.requests.js +29 -29
- package/lib/db_interface/mongo/schemas/gamebookSchemas/nonPlayoExpenseUsers.js +14 -14
- package/lib/db_interface/mongo/schemas/gamebookSchemas/playpals.js +69 -69
- package/lib/db_interface/mongo/schemas/gamebookSchemas/postActivity.js +51 -51
- package/lib/db_interface/mongo/schemas/gamebookSchemas/tags.js +12 -12
- package/lib/db_interface/mongo/schemas/userSchemas/QuickActions.js +25 -25
- package/lib/db_interface/mongo/schemas/userSchemas/_userIndex.js +7 -7
- package/lib/db_interface/mongo/schemas/userSchemas/blockedUser.js +11 -11
- package/lib/db_interface/mongo/schemas/userSchemas/city.js +62 -62
- package/lib/db_interface/mongo/schemas/userSchemas/country.js +63 -63
- package/lib/db_interface/mongo/schemas/userSchemas/emailOtp.js +12 -12
- package/lib/db_interface/mongo/schemas/userSchemas/emailVerificationToken.js +11 -11
- package/lib/db_interface/mongo/schemas/userSchemas/gt.trial.games.js +24 -24
- package/lib/db_interface/mongo/schemas/userSchemas/invite.js +14 -14
- package/lib/db_interface/mongo/schemas/userSchemas/karmaConfig.js +11 -11
- package/lib/db_interface/mongo/schemas/userSchemas/karmaLog.js +28 -28
- package/lib/db_interface/mongo/schemas/userSchemas/passwordResetToken.js +11 -11
- package/lib/db_interface/mongo/schemas/userSchemas/playo.subscription.pack.js +67 -67
- package/lib/db_interface/mongo/schemas/userSchemas/rankings.js +16 -16
- package/lib/db_interface/mongo/schemas/userSchemas/sports.js +26 -26
- package/lib/db_interface/mongo/schemas/userSchemas/sportsCategory.js +11 -11
- package/lib/db_interface/mongo/schemas/userSchemas/tempUser.js +35 -35
- package/lib/db_interface/mongo/schemas/userSchemas/trendingSports.js +14 -14
- package/lib/db_interface/mongo/schemas/userSchemas/user.activity.health.kit.data.js +26 -26
- package/lib/db_interface/mongo/schemas/userSchemas/user.contacts.js +33 -33
- package/lib/db_interface/mongo/schemas/userSchemas/user.js +111 -111
- package/lib/db_interface/mongo/schemas/userSchemas/userAlerts.js +23 -23
- package/lib/db_interface/mongo/schemas/userSchemas/userCredentials.js +50 -50
- package/lib/db_interface/mongo/schemas/userSchemas/userFavourites.js +81 -81
- package/lib/db_interface/mongo/schemas/userSchemas/userOtp.js +9 -9
- package/lib/db_interface/mongo/schemas/userSchemas/userReputation.js +21 -21
- package/lib/db_interface/mongo/schemas/userSchemas/userSocial.js +17 -17
- package/lib/db_interface/mongo/schemas/userSchemas/year.in.playo.js +51 -51
- package/lib/db_interface/mongo/schemas/venueSchemas/_venueIndex.js +3 -3
- package/lib/db_interface/mongo/schemas/venueSchemas/ameneties.js +9 -9
- package/lib/db_interface/mongo/schemas/venueSchemas/cityArea.js +45 -45
- package/lib/db_interface/mongo/schemas/venueSchemas/clubConstraints.js +17 -17
- package/lib/db_interface/mongo/schemas/venueSchemas/corporateOffer.js +17 -17
- package/lib/db_interface/mongo/schemas/venueSchemas/couponOffers.js +39 -39
- package/lib/db_interface/mongo/schemas/venueSchemas/gamebagMember.js +11 -11
- package/lib/db_interface/mongo/schemas/venueSchemas/offer.js +48 -48
- package/lib/db_interface/mongo/schemas/venueSchemas/thirdParty.js +12 -12
- package/lib/db_interface/mongo/schemas/venueSchemas/venue.js +134 -134
- package/lib/db_interface/mongo/schemas/venueSchemas/venueEnquires.js +22 -22
- package/lib/db_interface/mongo/schemas/venueSchemas/venueMembers.js +14 -14
- package/lib/db_interface/mongo/schemas/venueSchemas/venueRating.js +18 -18
- package/lib/index.js +22 -23
- package/lib/logger.js +115 -115
- package/lib/message_publisher/index.js +144 -144
- package/lib/middleware.js +46 -46
- package/lib/notification-templates.js +254 -254
- package/lib/notification.config.js +476 -476
- package/lib/playo.utils/playo.error.handler.js +23 -23
- package/lib/playo.utils/playo.http.handler.js +162 -162
- package/lib/playo.utils/playo.res.generator.js +58 -58
- package/lib/profanityFilter/profanityFilter.js +14 -14
- package/lib/profanityFilter/profanityWords.js +2 -2
- package/lib/ratings/index.js +95 -95
- package/lib/request.js +135 -135
- package/lib/responseHandler/responseHandler.js +52 -52
- package/lib/util.js +151 -151
- package/package.json +36 -36
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const { Schema, model } = require('mongoose');
|
|
2
|
-
|
|
3
|
-
const TempUserSchema = new Schema({
|
|
4
|
-
id: { type: String, required: true },
|
|
5
|
-
deviceType: {
|
|
6
|
-
type: Number,
|
|
7
|
-
enum: [11, 0, 1], // 1 -> android, 11 -> ios, 0 -> web (not used)
|
|
8
|
-
default: -1
|
|
9
|
-
},
|
|
10
|
-
onesignalId: [{ type: String }], // onesignalId
|
|
11
|
-
fcmId: { type: String }, // unique id for devices
|
|
12
|
-
version: { type: String, default: '' },
|
|
13
|
-
ispCarrier: { type: String, default: '' },
|
|
14
|
-
geoLocation: {
|
|
15
|
-
type: { type: String, default: 'Point' },
|
|
16
|
-
coordinates: { type: [Number], default: [0, 0] }
|
|
17
|
-
},
|
|
18
|
-
geoLocationCity: {
|
|
19
|
-
type: { type: String, default: 'Point' },
|
|
20
|
-
coordinates: { type: [Number], default: [0, 0] }
|
|
21
|
-
},
|
|
22
|
-
lastActiveAreaName: { type: String, default: '' },
|
|
23
|
-
cityCode: { type: Number, default: 0 },
|
|
24
|
-
placeId: { type: String, default: '' },
|
|
25
|
-
countryCode: { type: String, default: '' },
|
|
26
|
-
phoneCountryCode: { type: String, default: '' },
|
|
27
|
-
deviceModel: { type: String, default: '' },
|
|
28
|
-
versionCode: { type: Number, default: 0 },
|
|
29
|
-
userRegistered : { type: Boolean, default: false },
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
timestamps: { createdAt: 'createdTS', updatedAt: "modTS" }
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
|
|
1
|
+
const { Schema, model } = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const TempUserSchema = new Schema({
|
|
4
|
+
id: { type: String, required: true },
|
|
5
|
+
deviceType: {
|
|
6
|
+
type: Number,
|
|
7
|
+
enum: [11, 0, 1], // 1 -> android, 11 -> ios, 0 -> web (not used)
|
|
8
|
+
default: -1
|
|
9
|
+
},
|
|
10
|
+
onesignalId: [{ type: String }], // onesignalId
|
|
11
|
+
fcmId: { type: String }, // unique id for devices
|
|
12
|
+
version: { type: String, default: '' },
|
|
13
|
+
ispCarrier: { type: String, default: '' },
|
|
14
|
+
geoLocation: {
|
|
15
|
+
type: { type: String, default: 'Point' },
|
|
16
|
+
coordinates: { type: [Number], default: [0, 0] }
|
|
17
|
+
},
|
|
18
|
+
geoLocationCity: {
|
|
19
|
+
type: { type: String, default: 'Point' },
|
|
20
|
+
coordinates: { type: [Number], default: [0, 0] }
|
|
21
|
+
},
|
|
22
|
+
lastActiveAreaName: { type: String, default: '' },
|
|
23
|
+
cityCode: { type: Number, default: 0 },
|
|
24
|
+
placeId: { type: String, default: '' },
|
|
25
|
+
countryCode: { type: String, default: '' },
|
|
26
|
+
phoneCountryCode: { type: String, default: '' },
|
|
27
|
+
deviceModel: { type: String, default: '' },
|
|
28
|
+
versionCode: { type: Number, default: 0 },
|
|
29
|
+
userRegistered : { type: Boolean, default: false },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
timestamps: { createdAt: 'createdTS', updatedAt: "modTS" }
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
36
|
module.exports = model('TempUser', TempUserSchema);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const { Schema, model } = require('mongoose');
|
|
2
|
-
|
|
3
|
-
const TrendingSportsSchema = new Schema({
|
|
4
|
-
sportId: { type: String, required: true },
|
|
5
|
-
isTrending: { type: Boolean, required: true },
|
|
6
|
-
tags: {
|
|
7
|
-
type: [
|
|
8
|
-
{ type: String }
|
|
9
|
-
],
|
|
10
|
-
default: []
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
module.exports = model('TrendingSports', TrendingSportsSchema);
|
|
1
|
+
const { Schema, model } = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const TrendingSportsSchema = new Schema({
|
|
4
|
+
sportId: { type: String, required: true },
|
|
5
|
+
isTrending: { type: Boolean, required: true },
|
|
6
|
+
tags: {
|
|
7
|
+
type: [
|
|
8
|
+
{ type: String }
|
|
9
|
+
],
|
|
10
|
+
default: []
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
module.exports = model('TrendingSports', TrendingSportsSchema);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
const Schema = mongoose.Schema;
|
|
3
|
-
const MongooseUtils = require('../mongoose.utils');
|
|
4
|
-
|
|
5
|
-
const userHealthKitSchema = new Schema({
|
|
6
|
-
userId: { type: String, required: true },
|
|
7
|
-
activityId: { type: String, required: true },
|
|
8
|
-
healthKitActivityDate: { type: Date, default: Date.now },
|
|
9
|
-
peakHeartrateReached: { type: Number, default: 0 },
|
|
10
|
-
stepsTaken: { type: Number, default: 0 },
|
|
11
|
-
kCaloriesBurned: { type: Number, default: 0 },
|
|
12
|
-
minutesPlayed: { type: Number, default: 0 },
|
|
13
|
-
distanceCoveredInMetres: { type: Number, default: 0 },
|
|
14
|
-
healthKitDataSource: { type: String, required: true }, // google / ios
|
|
15
|
-
year: { type: Number, required: true },
|
|
16
|
-
week: { type: Number, required: true },
|
|
17
|
-
sportId: { type: String, required: true },
|
|
18
|
-
metadata: {},
|
|
19
|
-
isValid: { type: Boolean, default: true },
|
|
20
|
-
lastSyncedDate: { type: Date, default: null },
|
|
21
|
-
}, MongooseUtils.defaultSchemaOptions);
|
|
22
|
-
|
|
23
|
-
// compound indexes on - userId and healthKitActivityDate
|
|
24
|
-
// userId, activityId
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const Schema = mongoose.Schema;
|
|
3
|
+
const MongooseUtils = require('../mongoose.utils');
|
|
4
|
+
|
|
5
|
+
const userHealthKitSchema = new Schema({
|
|
6
|
+
userId: { type: String, required: true },
|
|
7
|
+
activityId: { type: String, required: true },
|
|
8
|
+
healthKitActivityDate: { type: Date, default: Date.now },
|
|
9
|
+
peakHeartrateReached: { type: Number, default: 0 },
|
|
10
|
+
stepsTaken: { type: Number, default: 0 },
|
|
11
|
+
kCaloriesBurned: { type: Number, default: 0 },
|
|
12
|
+
minutesPlayed: { type: Number, default: 0 },
|
|
13
|
+
distanceCoveredInMetres: { type: Number, default: 0 },
|
|
14
|
+
healthKitDataSource: { type: String, required: true }, // google / ios
|
|
15
|
+
year: { type: Number, required: true },
|
|
16
|
+
week: { type: Number, required: true },
|
|
17
|
+
sportId: { type: String, required: true },
|
|
18
|
+
metadata: {},
|
|
19
|
+
isValid: { type: Boolean, default: true },
|
|
20
|
+
lastSyncedDate: { type: Date, default: null },
|
|
21
|
+
}, MongooseUtils.defaultSchemaOptions);
|
|
22
|
+
|
|
23
|
+
// compound indexes on - userId and healthKitActivityDate
|
|
24
|
+
// userId, activityId
|
|
25
|
+
|
|
26
|
+
|
|
27
27
|
module.exports = mongoose.model('userhealthkitdata', userHealthKitSchema);
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
const Schema = mongoose.Schema;
|
|
3
|
-
const MongooseUtils = require('../mongoose.utils');
|
|
4
|
-
|
|
5
|
-
const userContactsSchema = new Schema({
|
|
6
|
-
id: String,
|
|
7
|
-
userId: String,
|
|
8
|
-
fName: String,
|
|
9
|
-
lName: String,
|
|
10
|
-
email: String,
|
|
11
|
-
mobile: {
|
|
12
|
-
countryCode: String,
|
|
13
|
-
phone: String
|
|
14
|
-
},
|
|
15
|
-
playPal: {
|
|
16
|
-
type: Boolean,
|
|
17
|
-
default: false
|
|
18
|
-
},
|
|
19
|
-
contactId: {
|
|
20
|
-
type: String,
|
|
21
|
-
default: null
|
|
22
|
-
},
|
|
23
|
-
active: {
|
|
24
|
-
type: Boolean,
|
|
25
|
-
default: true
|
|
26
|
-
},
|
|
27
|
-
linkingId: String
|
|
28
|
-
}, MongooseUtils.defaultSchemaOptions);
|
|
29
|
-
|
|
30
|
-
userContactsSchema.virtual('onPlayo').get(function () {
|
|
31
|
-
return this.contactId !== null;
|
|
32
|
-
});
|
|
33
|
-
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const Schema = mongoose.Schema;
|
|
3
|
+
const MongooseUtils = require('../mongoose.utils');
|
|
4
|
+
|
|
5
|
+
const userContactsSchema = new Schema({
|
|
6
|
+
id: String,
|
|
7
|
+
userId: String,
|
|
8
|
+
fName: String,
|
|
9
|
+
lName: String,
|
|
10
|
+
email: String,
|
|
11
|
+
mobile: {
|
|
12
|
+
countryCode: String,
|
|
13
|
+
phone: String
|
|
14
|
+
},
|
|
15
|
+
playPal: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
contactId: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
active: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: true
|
|
26
|
+
},
|
|
27
|
+
linkingId: String
|
|
28
|
+
}, MongooseUtils.defaultSchemaOptions);
|
|
29
|
+
|
|
30
|
+
userContactsSchema.virtual('onPlayo').get(function () {
|
|
31
|
+
return this.contactId !== null;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
34
|
module.exports = mongoose.model('UserContacts', userContactsSchema);
|
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
const mongoose = require('mongoose')
|
|
2
|
-
const Schema = mongoose.Schema
|
|
3
|
-
const userSchema = new Schema({
|
|
4
|
-
id: { type: String, required: true, unique: true },
|
|
5
|
-
fName: { type: String, default: "" },
|
|
6
|
-
lName: { type: String, default: "" },
|
|
7
|
-
userName: {type: String, default: ""},
|
|
8
|
-
email: { type: String, primary: true, default: "" },
|
|
9
|
-
officialEmail: { type: String, required: false },
|
|
10
|
-
mobile: { type: String, default: "" },
|
|
11
|
-
oldPlayoId: { type: String, default: "" },
|
|
12
|
-
lastActiveAreaName: { type: String, default: "" },
|
|
13
|
-
active: { type: Date, default: Date.now },
|
|
14
|
-
phoneCountryCode: { type: String, default: "" },
|
|
15
|
-
countryCode: { type: String, default: "" },
|
|
16
|
-
cityCode: { type: Number, default: 1 },
|
|
17
|
-
profilePicUrl: { type: String, default: "" },
|
|
18
|
-
gender: { type: Number, default: 2, min: 0, max: 3 }, // 0-female , 1-male, 2-does not matter;3-others
|
|
19
|
-
karma: { type: Number, default: 0 },
|
|
20
|
-
karmaRedeem: { type: Number, default: 0 },
|
|
21
|
-
city: { type: String, default: "" },
|
|
22
|
-
geoLocation: {
|
|
23
|
-
type: { type: String, enum: ['Point'], default: 'Point' },
|
|
24
|
-
coordinates: {
|
|
25
|
-
type : [Number], default: [0, 0]
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
geoLocationCity: {
|
|
29
|
-
type: { type: String },
|
|
30
|
-
coordinates: []
|
|
31
|
-
},
|
|
32
|
-
bio: { type: String, default: "" },
|
|
33
|
-
palsCount: Number,
|
|
34
|
-
emailVerified: { type: Boolean, default: false },
|
|
35
|
-
officialEmailVerified: { type: Boolean, default: false },
|
|
36
|
-
verified: { type: Boolean, default: false },
|
|
37
|
-
reportCount: Number,
|
|
38
|
-
superUser: { type: Boolean, default: false },
|
|
39
|
-
venueId: { type: String, default: "" },
|
|
40
|
-
rules: { type: String, default: "" },
|
|
41
|
-
messages: [ // for notifications
|
|
42
|
-
{
|
|
43
|
-
key: String,
|
|
44
|
-
value: String
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
isOnApplozic: { type: Boolean, default: false },
|
|
48
|
-
lastPlayed: { type: Date, default: null },
|
|
49
|
-
// createdTS: { type: Date, default: Date.now },
|
|
50
|
-
// modTS: {
|
|
51
|
-
// type: Date, default: new Date().toISOString(),
|
|
52
|
-
|
|
53
|
-
// },
|
|
54
|
-
helpTS: { type: Date, default: Date.now },
|
|
55
|
-
deviceType: { type: Number, default: -1 }, //11-ios, 0-android - 11 is correct for ios
|
|
56
|
-
deviceModel: { type: String, default: "" },
|
|
57
|
-
gcmRegId: [],
|
|
58
|
-
iosRegId: [],
|
|
59
|
-
iosBadge: { type: Number, default: 0 },
|
|
60
|
-
version: { type: Number, default: 0 },
|
|
61
|
-
onesignalId: [],
|
|
62
|
-
shareLink: { type: String, default: "" },
|
|
63
|
-
deferLink: { type: String, default: "" },
|
|
64
|
-
chatStatus: { type: Number, default: 0 },
|
|
65
|
-
fullLink: { type: String, default: "" },
|
|
66
|
-
referralLink: { type: String, default: null },
|
|
67
|
-
lastResetOn: { type: Date, default: null },
|
|
68
|
-
oldEmail: { type: String, default: "" },
|
|
69
|
-
oldMobile: { type: String, default: "" },
|
|
70
|
-
publicActivityLimit: { type: Number, default: 5 },
|
|
71
|
-
placeId: { type: String },
|
|
72
|
-
paytmOpenId: { type: String },
|
|
73
|
-
paidHostName: { type: String, default: "" },
|
|
74
|
-
paidHostCity: { type: String, default: "" },
|
|
75
|
-
activityHistory: [
|
|
76
|
-
{
|
|
77
|
-
_id: false,
|
|
78
|
-
activityId: { type: String, unique: true },
|
|
79
|
-
activityTS: Date
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
lastProcessed: Date,
|
|
83
|
-
calendarLink: { type: String, default: "" },
|
|
84
|
-
activityStack: Boolean, // config which informs whether user's activities are to be stacked
|
|
85
|
-
extraFields: [{
|
|
86
|
-
_id: false,
|
|
87
|
-
id: { type: String, required: true },
|
|
88
|
-
value: { type: String, required: true }
|
|
89
|
-
}],
|
|
90
|
-
lastContactSyncedAt : {
|
|
91
|
-
type: Date,
|
|
92
|
-
default: null
|
|
93
|
-
},
|
|
94
|
-
onboardSource: {
|
|
95
|
-
type: String,
|
|
96
|
-
enum: ['web', 'android', 'ios', 'others'],
|
|
97
|
-
default: 'others'
|
|
98
|
-
}
|
|
99
|
-
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } })
|
|
100
|
-
|
|
101
|
-
userSchema.index({ 'onesignalId': 1 }, { 'background': true })
|
|
102
|
-
userSchema.index({ 'mobile': 1 })
|
|
103
|
-
userSchema.index({ 'email': 1 }, { collation: { locale: "en", strength: 2 } }) // case insensitive index
|
|
104
|
-
userSchema.index({ 'officialEmail': 1 }, { collation: { locale: "en", strength: 2 } }) // case insensitive index
|
|
105
|
-
|
|
106
|
-
userSchema.index({ 'oldPlayoId': 1 })
|
|
107
|
-
|
|
108
|
-
const User = mongoose.model('User', userSchema)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
module.exports = User
|
|
1
|
+
const mongoose = require('mongoose')
|
|
2
|
+
const Schema = mongoose.Schema
|
|
3
|
+
const userSchema = new Schema({
|
|
4
|
+
id: { type: String, required: true, unique: true },
|
|
5
|
+
fName: { type: String, default: "" },
|
|
6
|
+
lName: { type: String, default: "" },
|
|
7
|
+
userName: {type: String, default: ""},
|
|
8
|
+
email: { type: String, primary: true, default: "" },
|
|
9
|
+
officialEmail: { type: String, required: false },
|
|
10
|
+
mobile: { type: String, default: "" },
|
|
11
|
+
oldPlayoId: { type: String, default: "" },
|
|
12
|
+
lastActiveAreaName: { type: String, default: "" },
|
|
13
|
+
active: { type: Date, default: Date.now },
|
|
14
|
+
phoneCountryCode: { type: String, default: "" },
|
|
15
|
+
countryCode: { type: String, default: "" },
|
|
16
|
+
cityCode: { type: Number, default: 1 },
|
|
17
|
+
profilePicUrl: { type: String, default: "" },
|
|
18
|
+
gender: { type: Number, default: 2, min: 0, max: 3 }, // 0-female , 1-male, 2-does not matter;3-others
|
|
19
|
+
karma: { type: Number, default: 0 },
|
|
20
|
+
karmaRedeem: { type: Number, default: 0 },
|
|
21
|
+
city: { type: String, default: "" },
|
|
22
|
+
geoLocation: {
|
|
23
|
+
type: { type: String, enum: ['Point'], default: 'Point' },
|
|
24
|
+
coordinates: {
|
|
25
|
+
type : [Number], default: [0, 0]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
geoLocationCity: {
|
|
29
|
+
type: { type: String },
|
|
30
|
+
coordinates: []
|
|
31
|
+
},
|
|
32
|
+
bio: { type: String, default: "" },
|
|
33
|
+
palsCount: Number,
|
|
34
|
+
emailVerified: { type: Boolean, default: false },
|
|
35
|
+
officialEmailVerified: { type: Boolean, default: false },
|
|
36
|
+
verified: { type: Boolean, default: false },
|
|
37
|
+
reportCount: Number,
|
|
38
|
+
superUser: { type: Boolean, default: false },
|
|
39
|
+
venueId: { type: String, default: "" },
|
|
40
|
+
rules: { type: String, default: "" },
|
|
41
|
+
messages: [ // for notifications
|
|
42
|
+
{
|
|
43
|
+
key: String,
|
|
44
|
+
value: String
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
isOnApplozic: { type: Boolean, default: false },
|
|
48
|
+
lastPlayed: { type: Date, default: null },
|
|
49
|
+
// createdTS: { type: Date, default: Date.now },
|
|
50
|
+
// modTS: {
|
|
51
|
+
// type: Date, default: new Date().toISOString(),
|
|
52
|
+
|
|
53
|
+
// },
|
|
54
|
+
helpTS: { type: Date, default: Date.now },
|
|
55
|
+
deviceType: { type: Number, default: -1 }, //11-ios, 0-android - 11 is correct for ios
|
|
56
|
+
deviceModel: { type: String, default: "" },
|
|
57
|
+
gcmRegId: [],
|
|
58
|
+
iosRegId: [],
|
|
59
|
+
iosBadge: { type: Number, default: 0 },
|
|
60
|
+
version: { type: Number, default: 0 },
|
|
61
|
+
onesignalId: [],
|
|
62
|
+
shareLink: { type: String, default: "" },
|
|
63
|
+
deferLink: { type: String, default: "" },
|
|
64
|
+
chatStatus: { type: Number, default: 0 },
|
|
65
|
+
fullLink: { type: String, default: "" },
|
|
66
|
+
referralLink: { type: String, default: null },
|
|
67
|
+
lastResetOn: { type: Date, default: null },
|
|
68
|
+
oldEmail: { type: String, default: "" },
|
|
69
|
+
oldMobile: { type: String, default: "" },
|
|
70
|
+
publicActivityLimit: { type: Number, default: 5 },
|
|
71
|
+
placeId: { type: String },
|
|
72
|
+
paytmOpenId: { type: String },
|
|
73
|
+
paidHostName: { type: String, default: "" },
|
|
74
|
+
paidHostCity: { type: String, default: "" },
|
|
75
|
+
activityHistory: [
|
|
76
|
+
{
|
|
77
|
+
_id: false,
|
|
78
|
+
activityId: { type: String, unique: true },
|
|
79
|
+
activityTS: Date
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
lastProcessed: Date,
|
|
83
|
+
calendarLink: { type: String, default: "" },
|
|
84
|
+
activityStack: Boolean, // config which informs whether user's activities are to be stacked
|
|
85
|
+
extraFields: [{
|
|
86
|
+
_id: false,
|
|
87
|
+
id: { type: String, required: true },
|
|
88
|
+
value: { type: String, required: true }
|
|
89
|
+
}],
|
|
90
|
+
lastContactSyncedAt : {
|
|
91
|
+
type: Date,
|
|
92
|
+
default: null
|
|
93
|
+
},
|
|
94
|
+
onboardSource: {
|
|
95
|
+
type: String,
|
|
96
|
+
enum: ['web', 'android', 'ios', 'others'],
|
|
97
|
+
default: 'others'
|
|
98
|
+
}
|
|
99
|
+
}, { timestamps: { createdAt: 'createdTS', updatedAt: "modTS" } })
|
|
100
|
+
|
|
101
|
+
userSchema.index({ 'onesignalId': 1 }, { 'background': true })
|
|
102
|
+
userSchema.index({ 'mobile': 1 })
|
|
103
|
+
userSchema.index({ 'email': 1 }, { collation: { locale: "en", strength: 2 } }) // case insensitive index
|
|
104
|
+
userSchema.index({ 'officialEmail': 1 }, { collation: { locale: "en", strength: 2 } }) // case insensitive index
|
|
105
|
+
|
|
106
|
+
userSchema.index({ 'oldPlayoId': 1 })
|
|
107
|
+
|
|
108
|
+
const User = mongoose.model('User', userSchema)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
module.exports = User
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var mongoose = require('mongoose');
|
|
2
|
-
var Schema = mongoose.Schema;
|
|
3
|
-
|
|
4
|
-
var userAlertSchema = new Schema({
|
|
5
|
-
userId: { type: String },
|
|
6
|
-
id: { type: String },
|
|
7
|
-
message: { type: String, default: "" },
|
|
8
|
-
isRead: { type: Boolean, default: false },
|
|
9
|
-
delete: { type: Boolean, default: false },
|
|
10
|
-
pic: { type: String, default: "" },
|
|
11
|
-
data: {
|
|
12
|
-
url: String
|
|
13
|
-
},
|
|
14
|
-
source: { type: String, default: "" },
|
|
15
|
-
isInvitation: { type: Boolean, default: false },
|
|
16
|
-
invitationExpiry: Date,
|
|
17
|
-
expiry: Date,
|
|
18
|
-
createdTS: { type: Date, default: Date.now },
|
|
19
|
-
notificationId: { type: String }
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
userAlertSchema.index({ 'userId': 1 })
|
|
23
|
-
|
|
1
|
+
var mongoose = require('mongoose');
|
|
2
|
+
var Schema = mongoose.Schema;
|
|
3
|
+
|
|
4
|
+
var userAlertSchema = new Schema({
|
|
5
|
+
userId: { type: String },
|
|
6
|
+
id: { type: String },
|
|
7
|
+
message: { type: String, default: "" },
|
|
8
|
+
isRead: { type: Boolean, default: false },
|
|
9
|
+
delete: { type: Boolean, default: false },
|
|
10
|
+
pic: { type: String, default: "" },
|
|
11
|
+
data: {
|
|
12
|
+
url: String
|
|
13
|
+
},
|
|
14
|
+
source: { type: String, default: "" },
|
|
15
|
+
isInvitation: { type: Boolean, default: false },
|
|
16
|
+
invitationExpiry: Date,
|
|
17
|
+
expiry: Date,
|
|
18
|
+
createdTS: { type: Date, default: Date.now },
|
|
19
|
+
notificationId: { type: String }
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
userAlertSchema.index({ 'userId': 1 })
|
|
23
|
+
|
|
24
24
|
module.exports = mongoose.model('UserAlert', userAlertSchema);
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
const MONGOOSE = require('mongoose')
|
|
2
|
-
const Schema = MONGOOSE.Schema
|
|
3
|
-
const bcrypt = require("bcrypt")
|
|
4
|
-
const UTIL = require('../util')
|
|
5
|
-
const SALT_WORK_FACTOR = 10
|
|
6
|
-
const userCredentialSchema = new Schema({
|
|
7
|
-
// _id: false,
|
|
8
|
-
userId: { type: String, required: true, unique: true },
|
|
9
|
-
password: String
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
userCredentialSchema.pre('save', function (next) {
|
|
14
|
-
var user = this;
|
|
15
|
-
|
|
16
|
-
// only hash the password if it has been modified (or is new)
|
|
17
|
-
if (!user.isModified('password')) return next();
|
|
18
|
-
|
|
19
|
-
// generate a salt
|
|
20
|
-
bcrypt.genSalt(SALT_WORK_FACTOR, function (err, salt) {
|
|
21
|
-
if (err) return next(err);
|
|
22
|
-
|
|
23
|
-
// hash the password along with our new salt
|
|
24
|
-
bcrypt.hash(user.password, salt, function (err, hash) {
|
|
25
|
-
if (err) return next(err);
|
|
26
|
-
|
|
27
|
-
// override the cleartext password with the hashed one
|
|
28
|
-
user.password = hash;
|
|
29
|
-
next();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
userCredentialSchema.methods.comparePassword = function (candidatePassword) {
|
|
35
|
-
// console.log("incoming password", candidatePassword, this.password)
|
|
36
|
-
return bcrypt.compare(candidatePassword, this.password).then(res => {
|
|
37
|
-
if (res)
|
|
38
|
-
return true
|
|
39
|
-
else
|
|
40
|
-
return false
|
|
41
|
-
}).catch(err => {
|
|
42
|
-
return err
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
module.exports = MONGOOSE.model('usercredentials', userCredentialSchema)
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
const MONGOOSE = require('mongoose')
|
|
2
|
+
const Schema = MONGOOSE.Schema
|
|
3
|
+
const bcrypt = require("bcrypt")
|
|
4
|
+
const UTIL = require('../util')
|
|
5
|
+
const SALT_WORK_FACTOR = 10
|
|
6
|
+
const userCredentialSchema = new Schema({
|
|
7
|
+
// _id: false,
|
|
8
|
+
userId: { type: String, required: true, unique: true },
|
|
9
|
+
password: String
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
userCredentialSchema.pre('save', function (next) {
|
|
14
|
+
var user = this;
|
|
15
|
+
|
|
16
|
+
// only hash the password if it has been modified (or is new)
|
|
17
|
+
if (!user.isModified('password')) return next();
|
|
18
|
+
|
|
19
|
+
// generate a salt
|
|
20
|
+
bcrypt.genSalt(SALT_WORK_FACTOR, function (err, salt) {
|
|
21
|
+
if (err) return next(err);
|
|
22
|
+
|
|
23
|
+
// hash the password along with our new salt
|
|
24
|
+
bcrypt.hash(user.password, salt, function (err, hash) {
|
|
25
|
+
if (err) return next(err);
|
|
26
|
+
|
|
27
|
+
// override the cleartext password with the hashed one
|
|
28
|
+
user.password = hash;
|
|
29
|
+
next();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
userCredentialSchema.methods.comparePassword = function (candidatePassword) {
|
|
35
|
+
// console.log("incoming password", candidatePassword, this.password)
|
|
36
|
+
return bcrypt.compare(candidatePassword, this.password).then(res => {
|
|
37
|
+
if (res)
|
|
38
|
+
return true
|
|
39
|
+
else
|
|
40
|
+
return false
|
|
41
|
+
}).catch(err => {
|
|
42
|
+
return err
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
module.exports = MONGOOSE.model('usercredentials', userCredentialSchema)
|
|
49
|
+
|
|
50
|
+
|