@dhyasama/totem-models 3.2.1 → 3.4.0

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/lib/Account.js CHANGED
@@ -14,33 +14,9 @@ module.exports = function(mongoose, config) {
14
14
  var Account = new Schema({
15
15
 
16
16
  username: { type: String, required: true, unique: true },
17
- password: { type: String, default: '' },
18
17
  email: { type: String, required: true, unique: true },
19
- reset: {
20
- token: { type: String },
21
- expiresOn: { type: Date }
22
- },
23
- setup: {
24
- token: { type: String },
25
- expiresOn: { type: Date },
26
- complete: { type: Boolean},
27
- terms: {
28
- raw: { type: String },
29
- hash: { type: String }
30
- }
31
- },
32
- twoFactorAuth: {
33
- enabled: { type: Boolean },
34
- phone: { type: String },
35
- country: {
36
- callingCode: { type: String },
37
- abbreviation: { type: String }
38
- },
39
- verified: { type: Boolean }
40
- },
41
18
  admin: { type: Boolean },
42
19
  active: { type: Boolean },
43
- subscriber: { type: Boolean },
44
20
  role: { type: String, enum: ['admin', 'lp-full', 'lp-names', 'welcome', 'none'] },
45
21
 
46
22
  // Enable this and iLevel links will show on portfolio pages
@@ -85,12 +61,30 @@ module.exports = function(mongoose, config) {
85
61
  calendar: {
86
62
  active: { type: Boolean, default: false }, // only pull if this is active
87
63
  forcePullAll: { type: Boolean, default: false } // override newest event date as min and go back all the way
64
+ },
65
+
66
+ inbound: {
67
+ active: { type: Boolean, default: false }
88
68
  }
89
69
 
90
70
  });
91
71
 
92
- Account.methods.phone = function() {
93
- return this.twoFactorAuth.country.callingCode + this.twoFactorAuth.phone;
72
+ Account.statics.findByEmail = function(email, cb) {
73
+ this
74
+ .findOne({ 'email': email})
75
+ .populate('person')
76
+ .exec(function (err, account) {
77
+ cb(err, account);
78
+ });
79
+ };
80
+
81
+ Account.statics.findByUsername = function(username, cb) {
82
+ this
83
+ .findOne({ 'username': new RegExp(username, 'i') })
84
+ .populate('person')
85
+ .exec(function (err, account) {
86
+ cb(err, account);
87
+ });
94
88
  };
95
89
 
96
90
  Account.statics.getById = function (id, cb) {
@@ -127,91 +121,6 @@ module.exports = function(mongoose, config) {
127
121
  .exec(cb);
128
122
  };
129
123
 
130
- Account.statics.upsert = function(account, cb) {
131
- account.save(cb);
132
- };
133
-
134
- Account.statics.findByUsername = function(username, cb) {
135
- this
136
- .findOne({ 'username': new RegExp(username, 'i') })
137
- .populate('person')
138
- .exec(function (err, account) {
139
- cb(err, account);
140
- });
141
- };
142
-
143
- Account.statics.findByEmail = function(email, cb) {
144
- this
145
- .findOne({ 'email': email})
146
- .populate('person')
147
- .exec(function (err, account) {
148
- cb(err, account);
149
- });
150
- };
151
-
152
- Account.statics.findByffEmail = function(email, cb) {
153
- email = email.toLowerCase();
154
-
155
- if (email.indexOf('@ffvc.com') > -1) {
156
- this
157
- .findOne({ 'email': email})
158
- .populate('person')
159
- .exec(function (err, account) {
160
- cb(err, account);
161
- });
162
- } else {
163
- //passing in null err so passport hits failureRedirect: '/login'
164
- cb(null, null);
165
- }
166
- };
167
-
168
- Account.statics.findByResetToken = function(token, cb) {
169
- this
170
- .findOne({ 'reset.token': token})
171
- .populate('person')
172
- .exec(function (err, account) {
173
- cb(err, account);
174
- });
175
- };
176
-
177
- Account.statics.findBySetupToken = function(token, cb) {
178
- this
179
- .findOne({ 'setup.token': token})
180
- .populate('person')
181
- .exec(function (err, account) {
182
- cb(err, account);
183
- });
184
- };
185
-
186
- Account.statics.findByCredentials = function (username, cleartextPassword, cb) {
187
-
188
- this
189
- .findOne({ 'username': new RegExp(username, 'i') })
190
- .populate('person')
191
- .exec(function (err, account) {
192
-
193
- if (err) {
194
- return cb(err, null);
195
- }
196
- else if (account != null) {
197
-
198
- // found user, now check password
199
-
200
- bcrypt.compare(cleartextPassword, account.password, function(err, res) {
201
- if (err) { return cb(err, null); } // error
202
- else if (res) { return cb(null, account); } // correct password
203
- else { return cb(null, null); } // wrong password
204
- });
205
-
206
- }
207
- else {
208
- return cb(null, null); // user not found
209
- }
210
-
211
- });
212
-
213
- };
214
-
215
124
  Account.statics.listGoogleAccounts = function(cb) {
216
125
 
217
126
  this
@@ -252,6 +161,10 @@ module.exports = function(mongoose, config) {
252
161
 
253
162
  };
254
163
 
164
+ Account.statics.upsert = function(account, cb) {
165
+ account.save(cb);
166
+ };
167
+
255
168
  Account.post('remove', function(doc) {
256
169
  // CalendarEvent.account
257
170
  // Person.account
package/lib/Message.js CHANGED
@@ -17,7 +17,10 @@ module.exports = function(mongoose, config) {
17
17
  createdOn: { type: Date, required: true },
18
18
  webhook: { type: Schema.ObjectId, ref: 'Webhook', required: true },
19
19
  type: { type: String, required: true, enum: ['email'], default: 'email' }, // for future options
20
+ subtype: { type: String, required: true, enum: ['boards', 'updates'] },
20
21
  customer: { type: Schema.ObjectId, ref: 'Organization', required: true },
22
+ organization: { type: Schema.ObjectId, ref: 'Organization' },
23
+ originalMessageDate: { type: Date, required: false, default: null },
21
24
  subject: { type: String, required: false, default: null, trim: true },
22
25
  body: { type: String, required: false, default: null, trim: true },
23
26
  recipients: {
@@ -121,6 +124,28 @@ module.exports = function(mongoose, config) {
121
124
 
122
125
  };
123
126
 
127
+ Message.statics.getById = function getById(id, cb) {
128
+
129
+ var self = this;
130
+ var query = self.findOne({
131
+ _id: id,
132
+ customer: config.CUSTOMER_ID
133
+ });
134
+ query.populate('organization', 'name logoUrl');
135
+ query.populate('recipients.internal', 'name avatarUrl title doNotDisplay');
136
+ query.populate('recipients.external', 'name avatarUrl title doNotDisplay');
137
+ query.populate({
138
+ path: 'notes',
139
+ match: { customer: config.CUSTOMER_ID }
140
+ });
141
+ query.populate({
142
+ path: 'documents',
143
+ match: { customer: config.CUSTOMER_ID }
144
+ });
145
+ query.exec(cb);
146
+
147
+ };
148
+
124
149
  Message.statics.getForCustomer = function getForCustomer(customerId, cb) {
125
150
 
126
151
  var self = this;
@@ -175,6 +175,14 @@ module.exports = function(mongoose, config) {
175
175
 
176
176
  eshares: {
177
177
  firmid: { type: String, unique: true, partialFilterExpression : { type :"string" }, trim: true }
178
+ },
179
+
180
+ calendar: {
181
+ active: { type: Boolean, default: false }
182
+ },
183
+
184
+ inbound: {
185
+ active: { type: Boolean, default: false }
178
186
  }
179
187
 
180
188
  },
@@ -497,6 +505,18 @@ module.exports = function(mongoose, config) {
497
505
 
498
506
  });
499
507
 
508
+ Organization.virtual('websites').get(function () {
509
+
510
+ var self = this;
511
+ var result = self.websiteAliases || [];
512
+ result.push(self.website);
513
+ result = _.compact(result);
514
+ result = _.uniq(result);
515
+
516
+ return result;
517
+
518
+ });
519
+
500
520
 
501
521
 
502
522
  ///////////////////////////////////////////////////////////////////////////////////////
@@ -722,7 +742,7 @@ module.exports = function(mongoose, config) {
722
742
  };
723
743
 
724
744
  Organization.statics.findBySlugs = function findBySlugs(slugs, cb) {
725
- this.find({ 'slug': { $in : slugs }, 'deleted': {$ne: true} }).exec(cb);
745
+ this.find({ 'slug': { $in : slugs } }).exec(cb);
726
746
  };
727
747
 
728
748
  Organization.statics.findDupes = function findDupes(org, options, cb) {
package/lib/Person.js CHANGED
@@ -806,7 +806,7 @@ module.exports = function(mongoose, config) {
806
806
 
807
807
  Person.statics.findBySlugs = function (slugs, cb) {
808
808
  this
809
- .find({ 'slug': { $in : slugs }, 'deleted': {$ne: true} })
809
+ .find({ 'slug': { $in : slugs } })
810
810
  .exec(cb);
811
811
  };
812
812
 
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "3.1.0",
3
+ "version": "3.3.1",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -9,7 +9,7 @@
9
9
  "resolved": "https://registry.npmjs.org/@dhyasama/ffvc-crypto/-/ffvc-crypto-1.0.1.tgz",
10
10
  "integrity": "sha1-O1UU14Q0SDVoffjK3xuAjI0cZW8=",
11
11
  "requires": {
12
- "bcrypt": "0.8.7"
12
+ "bcrypt": "^0.8.0"
13
13
  }
14
14
  },
15
15
  "@dhyasama/ffvc-geoip": {
@@ -17,9 +17,9 @@
17
17
  "resolved": "https://registry.npmjs.org/@dhyasama/ffvc-geoip/-/ffvc-geoip-1.1.0.tgz",
18
18
  "integrity": "sha1-6HUN5wvosZYD267aURaHnyQWTkk=",
19
19
  "requires": {
20
- "@dhyasama/ffvc-utilities": "1.5.3",
20
+ "@dhyasama/ffvc-utilities": "^1.0.0",
21
21
  "range_check": "0.0.5",
22
- "request": "2.85.0"
22
+ "request": "^2.51.0"
23
23
  },
24
24
  "dependencies": {
25
25
  "@dhyasama/ffvc-utilities": {
@@ -27,10 +27,10 @@
27
27
  "resolved": "https://registry.npmjs.org/@dhyasama/ffvc-utilities/-/ffvc-utilities-1.5.3.tgz",
28
28
  "integrity": "sha1-Bhhn6pnmakNzxmkzhX8CKaEFfvQ=",
29
29
  "requires": {
30
- "isnumeric": "0.1.5",
31
- "mongoose": "4.13.12",
32
- "node-uuid": "1.4.8",
33
- "underscore": "1.8.3"
30
+ "isnumeric": "^0.1.4",
31
+ "mongoose": "^4.5.8",
32
+ "node-uuid": "^1.4.2",
33
+ "underscore": "^1.8.3"
34
34
  }
35
35
  },
36
36
  "async": {
@@ -38,7 +38,7 @@
38
38
  "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz",
39
39
  "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=",
40
40
  "requires": {
41
- "lodash": "4.17.5"
41
+ "lodash": "^4.14.0"
42
42
  }
43
43
  },
44
44
  "mongoose": {
@@ -47,7 +47,7 @@
47
47
  "integrity": "sha512-pH8NK5AYGbnPeEFFGs5ACk18vzzcy4DFT48U9kKvkfg6SI3nJZkzGfN7o1NDWjy+kP26hWyU/AMhYTfe5hSVnA==",
48
48
  "requires": {
49
49
  "async": "2.1.4",
50
- "bson": "1.0.6",
50
+ "bson": "~1.0.4",
51
51
  "hooks-fixed": "2.0.2",
52
52
  "kareem": "1.5.0",
53
53
  "lodash.get": "4.4.2",
@@ -73,9 +73,9 @@
73
73
  "resolved": "https://registry.npmjs.org/@dhyasama/ffvc-s3/-/ffvc-s3-1.0.5.tgz",
74
74
  "integrity": "sha1-Mvh5KLjGbn5d0fthsNM5oms82go=",
75
75
  "requires": {
76
- "@dhyasama/ffvc-utilities": "1.5.3",
77
- "aws-sdk": "2.209.0",
78
- "file-encryptor": "0.1.1"
76
+ "@dhyasama/ffvc-utilities": "^1.0.0",
77
+ "aws-sdk": "^2.1.5",
78
+ "file-encryptor": "^0.1.0"
79
79
  },
80
80
  "dependencies": {
81
81
  "@dhyasama/ffvc-utilities": {
@@ -83,10 +83,10 @@
83
83
  "resolved": "https://registry.npmjs.org/@dhyasama/ffvc-utilities/-/ffvc-utilities-1.5.3.tgz",
84
84
  "integrity": "sha1-Bhhn6pnmakNzxmkzhX8CKaEFfvQ=",
85
85
  "requires": {
86
- "isnumeric": "0.1.5",
87
- "mongoose": "4.13.12",
88
- "node-uuid": "1.4.8",
89
- "underscore": "1.8.3"
86
+ "isnumeric": "^0.1.4",
87
+ "mongoose": "^4.5.8",
88
+ "node-uuid": "^1.4.2",
89
+ "underscore": "^1.8.3"
90
90
  }
91
91
  },
92
92
  "async": {
@@ -94,7 +94,7 @@
94
94
  "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz",
95
95
  "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=",
96
96
  "requires": {
97
- "lodash": "4.17.5"
97
+ "lodash": "^4.14.0"
98
98
  }
99
99
  },
100
100
  "mongoose": {
@@ -103,7 +103,7 @@
103
103
  "integrity": "sha512-pH8NK5AYGbnPeEFFGs5ACk18vzzcy4DFT48U9kKvkfg6SI3nJZkzGfN7o1NDWjy+kP26hWyU/AMhYTfe5hSVnA==",
104
104
  "requires": {
105
105
  "async": "2.1.4",
106
- "bson": "1.0.6",
106
+ "bson": "~1.0.4",
107
107
  "hooks-fixed": "2.0.2",
108
108
  "kareem": "1.5.0",
109
109
  "lodash.get": "4.4.2",
@@ -125,33 +125,33 @@
125
125
  }
126
126
  },
127
127
  "@dhyasama/ffvc-utilities": {
128
- "version": "2.2.0",
129
- "resolved": "https://registry.npmjs.org/@dhyasama/ffvc-utilities/-/ffvc-utilities-2.2.0.tgz",
130
- "integrity": "sha1-HqeGJiAcbDwKRMBWhi1KZS8gIFo=",
128
+ "version": "2.3.1",
129
+ "resolved": "https://registry.npmjs.org/@dhyasama/ffvc-utilities/-/ffvc-utilities-2.3.1.tgz",
130
+ "integrity": "sha1-gGczAMBGxW9AhC7zKQ5/f/Ggq34=",
131
131
  "requires": {
132
- "email-addresses": "3.0.1",
133
- "isnumeric": "0.1.5",
134
- "mongoose": "4.13.12",
135
- "node-uuid": "1.4.8",
136
- "parse-domain": "1.2.0",
137
- "underscore": "1.9.0"
132
+ "email-addresses": "^3.0.1",
133
+ "isnumeric": "^0.1.4",
134
+ "mongoose": "^4.5.8",
135
+ "node-uuid": "^1.4.2",
136
+ "parse-domain": "^1.1.0",
137
+ "underscore": "^1.8.3"
138
138
  },
139
139
  "dependencies": {
140
140
  "async": {
141
- "version": "2.1.4",
142
- "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz",
143
- "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=",
141
+ "version": "2.6.0",
142
+ "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
143
+ "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==",
144
144
  "requires": {
145
- "lodash": "4.17.5"
145
+ "lodash": "^4.14.0"
146
146
  }
147
147
  },
148
148
  "mongoose": {
149
- "version": "4.13.12",
150
- "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.13.12.tgz",
151
- "integrity": "sha512-pH8NK5AYGbnPeEFFGs5ACk18vzzcy4DFT48U9kKvkfg6SI3nJZkzGfN7o1NDWjy+kP26hWyU/AMhYTfe5hSVnA==",
149
+ "version": "4.13.13",
150
+ "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.13.13.tgz",
151
+ "integrity": "sha512-QBuryf62TVwpbdsaeJS6Ym3/FlrMhp7Xa5MkuomIX+wBeOSkMR8MjIDuiMZVZmQvN8j9/FnL7uZ9DX2wIJifYw==",
152
152
  "requires": {
153
- "async": "2.1.4",
154
- "bson": "1.0.6",
153
+ "async": "2.6.0",
154
+ "bson": "~1.0.4",
155
155
  "hooks-fixed": "2.0.2",
156
156
  "kareem": "1.5.0",
157
157
  "lodash.get": "4.4.2",
@@ -177,10 +177,10 @@
177
177
  "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
178
178
  "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
179
179
  "requires": {
180
- "co": "4.6.0",
181
- "fast-deep-equal": "1.1.0",
182
- "fast-json-stable-stringify": "2.0.0",
183
- "json-schema-traverse": "0.3.1"
180
+ "co": "^4.6.0",
181
+ "fast-deep-equal": "^1.0.0",
182
+ "fast-json-stable-stringify": "^2.0.0",
183
+ "json-schema-traverse": "^0.3.0"
184
184
  }
185
185
  },
186
186
  "asn1": {
@@ -194,11 +194,18 @@
194
194
  "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
195
195
  },
196
196
  "async": {
197
- "version": "2.6.0",
198
- "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
199
- "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==",
197
+ "version": "2.6.1",
198
+ "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
199
+ "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
200
200
  "requires": {
201
- "lodash": "4.17.5"
201
+ "lodash": "^4.17.10"
202
+ },
203
+ "dependencies": {
204
+ "lodash": {
205
+ "version": "4.17.10",
206
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
207
+ "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
208
+ }
202
209
  }
203
210
  },
204
211
  "asynckit": {
@@ -217,7 +224,7 @@
217
224
  "integrity": "sha1-z+bKI3NvZlkystFMyOTknX6dIMw=",
218
225
  "requires": {
219
226
  "buffer": "4.9.1",
220
- "events": "1.1.1",
227
+ "events": "^1.1.1",
221
228
  "jmespath": "0.15.0",
222
229
  "querystring": "0.2.0",
223
230
  "sax": "1.2.1",
@@ -264,7 +271,7 @@
264
271
  "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=",
265
272
  "optional": true,
266
273
  "requires": {
267
- "tweetnacl": "0.14.5"
274
+ "tweetnacl": "^0.14.3"
268
275
  }
269
276
  },
270
277
  "bindings": {
@@ -282,7 +289,7 @@
282
289
  "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz",
283
290
  "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=",
284
291
  "requires": {
285
- "hoek": "4.2.1"
292
+ "hoek": "4.x.x"
286
293
  }
287
294
  },
288
295
  "bson": {
@@ -295,9 +302,9 @@
295
302
  "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
296
303
  "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
297
304
  "requires": {
298
- "base64-js": "1.2.3",
299
- "ieee754": "1.1.8",
300
- "isarray": "1.0.0"
305
+ "base64-js": "^1.0.2",
306
+ "ieee754": "^1.1.4",
307
+ "isarray": "^1.0.0"
301
308
  }
302
309
  },
303
310
  "buffer-shims": {
@@ -325,7 +332,7 @@
325
332
  "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
326
333
  "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
327
334
  "requires": {
328
- "delayed-stream": "1.0.0"
335
+ "delayed-stream": "~1.0.0"
329
336
  }
330
337
  },
331
338
  "core-util-is": {
@@ -338,7 +345,7 @@
338
345
  "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz",
339
346
  "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=",
340
347
  "requires": {
341
- "boom": "5.2.0"
348
+ "boom": "5.x.x"
342
349
  },
343
350
  "dependencies": {
344
351
  "boom": {
@@ -346,7 +353,7 @@
346
353
  "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz",
347
354
  "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==",
348
355
  "requires": {
349
- "hoek": "4.2.1"
356
+ "hoek": "4.x.x"
350
357
  }
351
358
  }
352
359
  }
@@ -356,7 +363,7 @@
356
363
  "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
357
364
  "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
358
365
  "requires": {
359
- "assert-plus": "1.0.0"
366
+ "assert-plus": "^1.0.0"
360
367
  }
361
368
  },
362
369
  "debug": {
@@ -378,7 +385,7 @@
378
385
  "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=",
379
386
  "optional": true,
380
387
  "requires": {
381
- "jsbn": "0.1.1"
388
+ "jsbn": "~0.1.0"
382
389
  }
383
390
  },
384
391
  "email-addresses": {
@@ -436,9 +443,9 @@
436
443
  "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
437
444
  "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
438
445
  "requires": {
439
- "asynckit": "0.4.0",
446
+ "asynckit": "^0.4.0",
440
447
  "combined-stream": "1.0.6",
441
- "mime-types": "2.1.18"
448
+ "mime-types": "^2.1.12"
442
449
  }
443
450
  },
444
451
  "getpass": {
@@ -446,7 +453,7 @@
446
453
  "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
447
454
  "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
448
455
  "requires": {
449
- "assert-plus": "1.0.0"
456
+ "assert-plus": "^1.0.0"
450
457
  }
451
458
  },
452
459
  "har-schema": {
@@ -459,8 +466,8 @@
459
466
  "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
460
467
  "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
461
468
  "requires": {
462
- "ajv": "5.5.2",
463
- "har-schema": "2.0.0"
469
+ "ajv": "^5.1.0",
470
+ "har-schema": "^2.0.0"
464
471
  }
465
472
  },
466
473
  "hawk": {
@@ -468,10 +475,10 @@
468
475
  "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz",
469
476
  "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==",
470
477
  "requires": {
471
- "boom": "4.3.1",
472
- "cryptiles": "3.1.2",
473
- "hoek": "4.2.1",
474
- "sntp": "2.1.0"
478
+ "boom": "4.x.x",
479
+ "cryptiles": "3.x.x",
480
+ "hoek": "4.x.x",
481
+ "sntp": "2.x.x"
475
482
  }
476
483
  },
477
484
  "hoek": {
@@ -494,9 +501,9 @@
494
501
  "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
495
502
  "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
496
503
  "requires": {
497
- "assert-plus": "1.0.0",
498
- "jsprim": "1.4.1",
499
- "sshpk": "1.14.1"
504
+ "assert-plus": "^1.0.0",
505
+ "jsprim": "^1.2.2",
506
+ "sshpk": "^1.7.0"
500
507
  }
501
508
  },
502
509
  "ieee754": {
@@ -514,7 +521,7 @@
514
521
  "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-0.1.1.tgz",
515
522
  "integrity": "sha1-KManwRagIcVVVE+QarGtVAsdY1o=",
516
523
  "requires": {
517
- "coffee-script": "1.12.7"
524
+ "coffee-script": ">= 1.1.1"
518
525
  }
519
526
  },
520
527
  "is-typedarray": {
@@ -605,7 +612,7 @@
605
612
  "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
606
613
  "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
607
614
  "requires": {
608
- "mime-db": "1.33.0"
615
+ "mime-db": "~1.33.0"
609
616
  }
610
617
  },
611
618
  "moment": {
@@ -628,8 +635,8 @@
628
635
  "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.18.tgz",
629
636
  "integrity": "sha1-TEYTm986HwMt7ZHbSfOO7AFlkFA=",
630
637
  "requires": {
631
- "bson": "1.0.6",
632
- "require_optional": "1.0.1"
638
+ "bson": "~1.0.4",
639
+ "require_optional": "~1.0.0"
633
640
  }
634
641
  },
635
642
  "mongoose-deep-populate": {
@@ -642,9 +649,9 @@
642
649
  "resolved": "https://registry.npmjs.org/mongoose-filter-denormalize/-/mongoose-filter-denormalize-0.2.1.tgz",
643
650
  "integrity": "sha1-SUhd/n+6xuegc7Jha7CRJapmX74=",
644
651
  "requires": {
645
- "lodash": "2.2.1",
646
- "mongoose": "3.6.20",
647
- "sanitizer": "0.1.3"
652
+ "lodash": "~2.2.0",
653
+ "mongoose": "~3.6.0",
654
+ "sanitizer": "~0.1.0"
648
655
  },
649
656
  "dependencies": {
650
657
  "bson": {
@@ -723,7 +730,7 @@
723
730
  "resolved": "https://registry.npmjs.org/mongoose-post-find/-/mongoose-post-find-0.0.2.tgz",
724
731
  "integrity": "sha1-3ulQHmkxmOhR0Q+HImFfjfkE3Bw=",
725
732
  "requires": {
726
- "mongoose": "3.8.40"
733
+ "mongoose": "~3.8.0"
727
734
  },
728
735
  "dependencies": {
729
736
  "bluebird": {
@@ -736,7 +743,7 @@
736
743
  "resolved": "https://registry.npmjs.org/bson/-/bson-0.2.22.tgz",
737
744
  "integrity": "sha1-/NoQPybQwHTVpS1Qkn24D9ArSzk=",
738
745
  "requires": {
739
- "nan": "1.8.4"
746
+ "nan": "~1.8"
740
747
  }
741
748
  },
742
749
  "debug": {
@@ -760,7 +767,7 @@
760
767
  "integrity": "sha1-yymJHCHCKsGV8xQLl90SIE/qfcI=",
761
768
  "optional": true,
762
769
  "requires": {
763
- "nan": "1.8.4"
770
+ "nan": "~1.8"
764
771
  }
765
772
  },
766
773
  "mongodb": {
@@ -768,9 +775,9 @@
768
775
  "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-1.4.38.tgz",
769
776
  "integrity": "sha1-jP/WGBAK86RkiplUmL/Py07Yq9I=",
770
777
  "requires": {
771
- "bson": "0.2.22",
778
+ "bson": "~0.2",
772
779
  "kerberos": "0.0.11",
773
- "readable-stream": "2.3.5"
780
+ "readable-stream": "latest"
774
781
  }
775
782
  },
776
783
  "mongoose": {
@@ -832,24 +839,33 @@
832
839
  "optional": true
833
840
  },
834
841
  "readable-stream": {
835
- "version": "2.3.5",
836
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz",
837
- "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==",
842
+ "version": "2.3.6",
843
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
844
+ "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
838
845
  "optional": true,
839
846
  "requires": {
840
- "core-util-is": "1.0.2",
841
- "inherits": "2.0.3",
842
- "isarray": "1.0.0",
843
- "process-nextick-args": "2.0.0",
844
- "safe-buffer": "5.1.1",
845
- "string_decoder": "1.0.3",
846
- "util-deprecate": "1.0.2"
847
+ "core-util-is": "~1.0.0",
848
+ "inherits": "~2.0.3",
849
+ "isarray": "~1.0.0",
850
+ "process-nextick-args": "~2.0.0",
851
+ "safe-buffer": "~5.1.1",
852
+ "string_decoder": "~1.1.1",
853
+ "util-deprecate": "~1.0.1"
847
854
  }
848
855
  },
849
856
  "sliced": {
850
857
  "version": "0.0.5",
851
858
  "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz",
852
859
  "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8="
860
+ },
861
+ "string_decoder": {
862
+ "version": "1.1.1",
863
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
864
+ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
865
+ "optional": true,
866
+ "requires": {
867
+ "safe-buffer": "~5.1.0"
868
+ }
853
869
  }
854
870
  }
855
871
  },
@@ -959,13 +975,13 @@
959
975
  "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz",
960
976
  "integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=",
961
977
  "requires": {
962
- "buffer-shims": "1.0.0",
963
- "core-util-is": "1.0.2",
964
- "inherits": "2.0.3",
965
- "isarray": "1.0.0",
966
- "process-nextick-args": "1.0.7",
967
- "string_decoder": "1.0.3",
968
- "util-deprecate": "1.0.2"
978
+ "buffer-shims": "~1.0.0",
979
+ "core-util-is": "~1.0.0",
980
+ "inherits": "~2.0.1",
981
+ "isarray": "~1.0.0",
982
+ "process-nextick-args": "~1.0.6",
983
+ "string_decoder": "~1.0.0",
984
+ "util-deprecate": "~1.0.1"
969
985
  }
970
986
  },
971
987
  "regexp-clone": {
@@ -978,28 +994,28 @@
978
994
  "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz",
979
995
  "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==",
980
996
  "requires": {
981
- "aws-sign2": "0.7.0",
982
- "aws4": "1.6.0",
983
- "caseless": "0.12.0",
984
- "combined-stream": "1.0.6",
985
- "extend": "3.0.1",
986
- "forever-agent": "0.6.1",
987
- "form-data": "2.3.2",
988
- "har-validator": "5.0.3",
989
- "hawk": "6.0.2",
990
- "http-signature": "1.2.0",
991
- "is-typedarray": "1.0.0",
992
- "isstream": "0.1.2",
993
- "json-stringify-safe": "5.0.1",
994
- "mime-types": "2.1.18",
995
- "oauth-sign": "0.8.2",
996
- "performance-now": "2.1.0",
997
- "qs": "6.5.1",
998
- "safe-buffer": "5.1.1",
999
- "stringstream": "0.0.5",
1000
- "tough-cookie": "2.3.4",
1001
- "tunnel-agent": "0.6.0",
1002
- "uuid": "3.2.1"
997
+ "aws-sign2": "~0.7.0",
998
+ "aws4": "^1.6.0",
999
+ "caseless": "~0.12.0",
1000
+ "combined-stream": "~1.0.5",
1001
+ "extend": "~3.0.1",
1002
+ "forever-agent": "~0.6.1",
1003
+ "form-data": "~2.3.1",
1004
+ "har-validator": "~5.0.3",
1005
+ "hawk": "~6.0.2",
1006
+ "http-signature": "~1.2.0",
1007
+ "is-typedarray": "~1.0.0",
1008
+ "isstream": "~0.1.2",
1009
+ "json-stringify-safe": "~5.0.1",
1010
+ "mime-types": "~2.1.17",
1011
+ "oauth-sign": "~0.8.2",
1012
+ "performance-now": "^2.1.0",
1013
+ "qs": "~6.5.1",
1014
+ "safe-buffer": "^5.1.1",
1015
+ "stringstream": "~0.0.5",
1016
+ "tough-cookie": "~2.3.3",
1017
+ "tunnel-agent": "^0.6.0",
1018
+ "uuid": "^3.1.0"
1003
1019
  },
1004
1020
  "dependencies": {
1005
1021
  "uuid": {
@@ -1014,8 +1030,8 @@
1014
1030
  "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
1015
1031
  "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
1016
1032
  "requires": {
1017
- "resolve-from": "2.0.0",
1018
- "semver": "5.5.0"
1033
+ "resolve-from": "^2.0.0",
1034
+ "semver": "^5.1.0"
1019
1035
  }
1020
1036
  },
1021
1037
  "resolve-from": {
@@ -1053,7 +1069,7 @@
1053
1069
  "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz",
1054
1070
  "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==",
1055
1071
  "requires": {
1056
- "hoek": "4.2.1"
1072
+ "hoek": "4.x.x"
1057
1073
  }
1058
1074
  },
1059
1075
  "sshpk": {
@@ -1061,14 +1077,14 @@
1061
1077
  "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz",
1062
1078
  "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=",
1063
1079
  "requires": {
1064
- "asn1": "0.2.3",
1065
- "assert-plus": "1.0.0",
1066
- "bcrypt-pbkdf": "1.0.1",
1067
- "dashdash": "1.14.1",
1068
- "ecc-jsbn": "0.1.1",
1069
- "getpass": "0.1.7",
1070
- "jsbn": "0.1.1",
1071
- "tweetnacl": "0.14.5"
1080
+ "asn1": "~0.2.3",
1081
+ "assert-plus": "^1.0.0",
1082
+ "bcrypt-pbkdf": "^1.0.0",
1083
+ "dashdash": "^1.12.0",
1084
+ "ecc-jsbn": "~0.1.1",
1085
+ "getpass": "^0.1.1",
1086
+ "jsbn": "~0.1.0",
1087
+ "tweetnacl": "~0.14.0"
1072
1088
  }
1073
1089
  },
1074
1090
  "string_decoder": {
@@ -1076,7 +1092,7 @@
1076
1092
  "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
1077
1093
  "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
1078
1094
  "requires": {
1079
- "safe-buffer": "5.1.1"
1095
+ "safe-buffer": "~5.1.0"
1080
1096
  }
1081
1097
  },
1082
1098
  "stringstream": {
@@ -1089,7 +1105,7 @@
1089
1105
  "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
1090
1106
  "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
1091
1107
  "requires": {
1092
- "punycode": "1.4.1"
1108
+ "punycode": "^1.4.1"
1093
1109
  }
1094
1110
  },
1095
1111
  "tunnel-agent": {
@@ -1097,7 +1113,7 @@
1097
1113
  "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
1098
1114
  "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
1099
1115
  "requires": {
1100
- "safe-buffer": "5.1.1"
1116
+ "safe-buffer": "^5.0.1"
1101
1117
  }
1102
1118
  },
1103
1119
  "tweetnacl": {
@@ -1142,9 +1158,9 @@
1142
1158
  "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
1143
1159
  "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
1144
1160
  "requires": {
1145
- "assert-plus": "1.0.0",
1161
+ "assert-plus": "^1.0.0",
1146
1162
  "core-util-is": "1.0.2",
1147
- "extsprintf": "1.3.0"
1163
+ "extsprintf": "^1.2.0"
1148
1164
  }
1149
1165
  },
1150
1166
  "xml2js": {
@@ -1152,8 +1168,8 @@
1152
1168
  "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz",
1153
1169
  "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=",
1154
1170
  "requires": {
1155
- "sax": "1.2.1",
1156
- "xmlbuilder": "4.2.1"
1171
+ "sax": ">=0.6.0",
1172
+ "xmlbuilder": "^4.1.0"
1157
1173
  }
1158
1174
  },
1159
1175
  "xmlbuilder": {
@@ -1161,7 +1177,7 @@
1161
1177
  "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz",
1162
1178
  "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=",
1163
1179
  "requires": {
1164
- "lodash": "4.17.5"
1180
+ "lodash": "^4.0.0"
1165
1181
  }
1166
1182
  }
1167
1183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "3.2.1",
3
+ "version": "3.4.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -15,8 +15,8 @@
15
15
  "@dhyasama/ffvc-crypto": "^1.0.0",
16
16
  "@dhyasama/ffvc-geoip": "^1.0.0",
17
17
  "@dhyasama/ffvc-s3": "^1.0.0",
18
- "@dhyasama/ffvc-utilities": "^2.2.0",
19
- "async": "^2.6.0",
18
+ "@dhyasama/ffvc-utilities": "^2.3.1",
19
+ "async": "^2.6.1",
20
20
  "awesome-phonenumber": "^1.0.14",
21
21
  "bcrypt": "^0.8.0",
22
22
  "bluebird": "^3.5.0",
package/test/Account.js CHANGED
@@ -45,10 +45,7 @@ describe('Account', function() {
45
45
  var account = new Account();
46
46
 
47
47
  account.username = 'testy';
48
- account.email = 'sebastian+soler@gmail.com'
49
- account.reset.token = '123456789';
50
- account.setup.token = '987654321';
51
- account.password = hash;
48
+ account.email = 'test@totemvc.com';
52
49
  account.person = newPerson;
53
50
  account.active = true;
54
51
 
@@ -88,37 +85,7 @@ describe('Account', function() {
88
85
 
89
86
  it('finds by email', function(done) {
90
87
 
91
- Account.findByEmail('sebastian+soler@gmail.com', function(err, account) {
92
- should.not.exist(err);
93
- should.exist(account);
94
- done();
95
- });
96
-
97
- });
98
-
99
- it('finds by reset token', function(done) {
100
-
101
- Account.findByResetToken('123456789', function(err, account) {
102
- should.not.exist(err);
103
- should.exist(account);
104
- done();
105
- });
106
-
107
- });
108
-
109
- it('finds by setup token', function(done) {
110
-
111
- Account.findBySetupToken('987654321', function(err, account) {
112
- should.not.exist(err);
113
- should.exist(account);
114
- done();
115
- });
116
-
117
- });
118
-
119
- it('finds by username and password', function(done) {
120
-
121
- Account.findByCredentials('testy', 'testy', function(err, account) {
88
+ Account.findByEmail('test@totemvc.com', function(err, account) {
122
89
  should.not.exist(err);
123
90
  should.exist(account);
124
91
  done();
package/test/Document.js CHANGED
@@ -52,6 +52,8 @@ describe('Document', function() {
52
52
  message = new Message({
53
53
  webhook: new mongoose.Types.ObjectId(),
54
54
  customer: config.CUSTOMER_ID,
55
+ type: 'email',
56
+ subtype: 'boards',
55
57
  raw: { test: 'test' }
56
58
  });
57
59
 
package/test/Message.js CHANGED
@@ -8,13 +8,17 @@ var
8
8
  moment = require('moment'),
9
9
  mongoose = require('mongoose'),
10
10
  clearDB = require('mocha-mongoose')(config.db.uri, {noClear: true}),
11
- Message = mongoose.model('Message');
11
+ Document = mongoose.model('Document'),
12
+ Message = mongoose.model('Message'),
13
+ Note = mongoose.model('Note');
12
14
 
13
15
  var totemCustomerId1 = new mongoose.Types.ObjectId();
14
16
  var totemCustomerId2 = new mongoose.Types.ObjectId();
15
17
  var externalAttendee1 = new mongoose.Types.ObjectId();
16
18
  var externalAttendee2 = new mongoose.Types.ObjectId();
17
19
 
20
+ var messageOne;
21
+
18
22
  describe('Message', function() {
19
23
 
20
24
  before(function(done) {
@@ -32,6 +36,8 @@ describe('Message', function() {
32
36
  webhook: new mongoose.Types.ObjectId(),
33
37
  customer: totemCustomerId1,
34
38
  subject: 'Message one',
39
+ type: 'email',
40
+ subtype: 'boards',
35
41
  recipients: {
36
42
  external: [externalAttendee1]
37
43
  },
@@ -41,6 +47,7 @@ describe('Message', function() {
41
47
  Message.upsert(message, function(err, result) {
42
48
  should.not.exist(err);
43
49
  should.exist(result);
50
+ messageOne = result;
44
51
  done();
45
52
  });
46
53
 
@@ -52,6 +59,8 @@ describe('Message', function() {
52
59
  webhook: new mongoose.Types.ObjectId(),
53
60
  customer: totemCustomerId2,
54
61
  subject: 'Message two',
62
+ type: 'email',
63
+ subtype: 'boards',
55
64
  recipients: {
56
65
  external: [externalAttendee2]
57
66
  },
@@ -66,6 +75,70 @@ describe('Message', function() {
66
75
 
67
76
  });
68
77
 
78
+ it('creates a document for a message', function(done) {
79
+
80
+ config.CUSTOMER_ID = totemCustomerId1;
81
+
82
+ Document.createForModel({
83
+ customer: config.CUSTOMER_ID,
84
+ createdBy: new mongoose.Types.ObjectId(),
85
+ name: 'plain.txt',
86
+ contentType: 'text/plain',
87
+ contentLength: 124,
88
+ s3: {
89
+ bucket: 'totem',
90
+ key: 'docs'
91
+ }
92
+ }, Message, messageOne._id, function(err, result) {
93
+
94
+ should.not.exist(err);
95
+ should.exist(result);
96
+ should.exist(result.document);
97
+ should.exist(result.addedTo);
98
+ result.addedTo.documents.length.should.equal(1);
99
+
100
+ return done();
101
+
102
+ });
103
+
104
+ });
105
+
106
+ it('creates a note for a message', function(done) {
107
+
108
+ config.CUSTOMER_ID = totemCustomerId1;
109
+
110
+ Note.createForModel({
111
+ createdBy: new mongoose.Types.ObjectId(),
112
+ text: 'Best note ever!'
113
+ }, Message, messageOne._id, function(err, result) {
114
+
115
+ should.not.exist(err);
116
+ should.exist(result);
117
+ should.exist(result.note);
118
+ should.exist(result.addedTo);
119
+ result.addedTo.notes.length.should.equal(1);
120
+
121
+ return done();
122
+
123
+ });
124
+
125
+ });
126
+
127
+ it('gets a message by id', function(done) {
128
+
129
+ config.CUSTOMER_ID = totemCustomerId1;
130
+
131
+ Message.getById(messageOne.id, function(err, result) {
132
+ should.not.exist(err);
133
+ should.exist(result);
134
+ result.subject.should.equal('Message one');
135
+ result.documents.length.should.equal(1);
136
+ result.notes.length.should.equal(1);
137
+ done();
138
+ });
139
+
140
+ });
141
+
69
142
  it('gets messages for a person', function(done) {
70
143
 
71
144
  config.CUSTOMER_ID = totemCustomerId1;
@@ -114,6 +187,8 @@ describe('Message', function() {
114
187
  webhook: new mongoose.Types.ObjectId(),
115
188
  customer: totemCustomerId2,
116
189
  subject: 'test 3',
190
+ type: 'email',
191
+ subtype: 'boards',
117
192
  recipients: {
118
193
  external: [new mongoose.Types.ObjectId()]
119
194
  },
@@ -144,4 +219,16 @@ describe('Message', function() {
144
219
 
145
220
  });
146
221
 
222
+ it('tries to get a message belonging to another customer', function(done) {
223
+
224
+ config.CUSTOMER_ID = totemCustomerId2;
225
+
226
+ Message.getById(messageOne.id, function(err, result) {
227
+ should.not.exist(err);
228
+ should.not.exist(result);
229
+ done();
230
+ });
231
+
232
+ });
233
+
147
234
  });
package/test/Person.js CHANGED
@@ -537,9 +537,6 @@ describe('Person', function() {
537
537
 
538
538
  account.username = 'testy';
539
539
  account.email = 'test@ffvc.com';
540
- account.reset.token = '123456789';
541
- account.setup.token = '987654321';
542
- account.password = 'piratebooty';
543
540
  account.person = person;
544
541
 
545
542
  Account.upsert(account, function(err, updatedAccount) {