@dhyasama/totem-models 3.3.1 → 3.4.1

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/.npmignore ADDED
@@ -0,0 +1,14 @@
1
+ lib-cov
2
+ *.seed
3
+ *.log
4
+ *.csv
5
+ *.dat
6
+ *.out
7
+ *.pid
8
+ *.gz
9
+
10
+ npm-debug.log
11
+ node_modules
12
+
13
+ .DS_Store
14
+ .idea
package/lib/Account.js CHANGED
@@ -70,12 +70,13 @@ module.exports = function(mongoose, config) {
70
70
  });
71
71
 
72
72
  Account.statics.findByEmail = function(email, cb) {
73
- this
74
- .findOne({ 'email': email})
73
+
74
+ var self = this;
75
+
76
+ self
77
+ .findOne({ 'email': (email || '').toLowerCase()})
75
78
  .populate('person')
76
- .exec(function (err, account) {
77
- cb(err, account);
78
- });
79
+ .exec(cb);
79
80
  };
80
81
 
81
82
  Account.statics.findByUsername = function(username, cb) {
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;
@@ -505,6 +505,18 @@ module.exports = function(mongoose, config) {
505
505
 
506
506
  });
507
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
+
508
520
 
509
521
 
510
522
  ///////////////////////////////////////////////////////////////////////////////////////