@dhyasama/totem-models 9.45.5 → 9.47.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/Message.js CHANGED
@@ -228,6 +228,25 @@ module.exports = function(mongoose, config) {
228
228
 
229
229
  };
230
230
 
231
+ Message.statics.getMostRecentForOrg = function getMostRecentForOrg(orgId, options, cb) {
232
+
233
+ if (!cb) { throw new Error('cb is required'); }
234
+ if (!orgId) { return cb(new Error('orgId is required'), null); }
235
+ if (!mongoose.Types.ObjectId.isValid(orgId)) { return cb(new Error('orgId is not a valid ObjectId'), null); }
236
+ if (!options) { return cb(new Error('options is required'), null); }
237
+ if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
238
+ if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
239
+
240
+ // Note - This filters by customer so is NOT usable by admin tools
241
+
242
+ const self = this;
243
+
244
+ let query = self.find({ customer: options.CUSTOMER_ID, organization: orgId }).sort({'originalMessageDate': -1}).limit(1);
245
+
246
+ query.exec(cb);
247
+
248
+ };
249
+
231
250
  Message.statics.getForPeople = function getForPeople(personIds, options, cb) {
232
251
 
233
252
  if (!cb) { throw new Error('cb is required'); }
@@ -171,7 +171,7 @@ module.exports = function(mongoose, config) {
171
171
 
172
172
  premium: { type: Boolean, default: false },
173
173
 
174
- totemUrl: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
174
+ totemUrl: { type: String, trim: true, unique: false, partialFilterExpression : { type :"string" } },
175
175
 
176
176
  logos: {
177
177
  light: { type: String, trim: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "9.45.5",
3
+ "version": "9.47.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",