@dhyasama/totem-models 3.6.2 → 3.7.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
@@ -154,6 +154,36 @@ module.exports = function(mongoose, config) {
154
154
 
155
155
  };
156
156
 
157
+ Message.statics.getForOrg = function getForOrg(orgId, options, cb) {
158
+
159
+ // This filters by customer so is NOT usable by admin tools
160
+ if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') return cb(new Error('Access denied. Use getForPeopleLite.'), null);
161
+
162
+ var self = this;
163
+ var query = self.find({ customer: config.CUSTOMER_ID, organization: orgId });
164
+ query.populate('recipients.internal', 'name title avatarUrl doNotDisplay');
165
+ query.populate('recipients.external', 'name title avatarUrl doNotDisplay');
166
+ query.populate({
167
+ path: 'notes',
168
+ match: { customer: config.CUSTOMER_ID }
169
+ });
170
+ query.populate({
171
+ path: 'documents',
172
+ match: { customer: config.CUSTOMER_ID }
173
+ });
174
+ query.deepPopulate([
175
+ 'notes.createdBy',
176
+ 'documents.createdBy'
177
+ ], {
178
+ populate: {
179
+ 'notes.createdBy': { select: 'name avatarUrl title' },
180
+ 'documents.createdBy': { select: 'name avatarUrl title' }
181
+ }
182
+ });
183
+ query.exec(cb);
184
+
185
+ };
186
+
157
187
  Message.statics.getForPeople = function getForPeople(personIds, options, cb) {
158
188
 
159
189
  // This filters by customer so is NOT usable by admin tools
package/lib/Round.js CHANGED
@@ -142,12 +142,20 @@ module.exports = function(mongoose, config) {
142
142
  };
143
143
  });
144
144
 
145
+ var websites = rounds[0].organization.websiteAliases || [];
146
+ websites.push(rounds[0].organization.website);
147
+ websites = _.compact(websites);
148
+ websites = _.uniq(websites);
149
+
145
150
  // construct the org
146
151
  var org = {
147
152
  _id: rounds[0].organization._id,
148
153
  name: rounds[0].organization.name,
149
154
  logoUrl: rounds[0].organization.logoUrl,
150
155
  description: rounds[0].organization.description,
156
+ website: rounds[0].organization.website,
157
+ websiteAliases: rounds[0].organization.websiteAliases,
158
+ websites: websites,
151
159
  contact: rounds[0].organization.contact,
152
160
  filters: rounds[0].organization.filters,
153
161
  status: rounds[0].organization.status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "3.6.2",
3
+ "version": "3.7.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -14,7 +14,7 @@ var customerB = new mongoose.Types.ObjectId();
14
14
  var orgA = new mongoose.Types.ObjectId();
15
15
  var orgB = new mongoose.Types.ObjectId();
16
16
 
17
- describe('Financials', function() {
17
+ describe.skip('Financials', function() {
18
18
 
19
19
  before(function(done) {
20
20
  if (mongoose.connection.db) return done();
package/test/Message.js CHANGED
@@ -16,6 +16,8 @@ var totemCustomerId1 = new mongoose.Types.ObjectId();
16
16
  var totemCustomerId2 = new mongoose.Types.ObjectId();
17
17
  var externalAttendee1 = new mongoose.Types.ObjectId();
18
18
  var externalAttendee2 = new mongoose.Types.ObjectId();
19
+ var orgId1 = new mongoose.Types.ObjectId();
20
+ var orgId2 = new mongoose.Types.ObjectId();
19
21
 
20
22
  var messageOne;
21
23
 
@@ -35,6 +37,7 @@ describe('Message', function() {
35
37
  var message = new Message({
36
38
  webhook: new mongoose.Types.ObjectId(),
37
39
  customer: totemCustomerId1,
40
+ organization: orgId1,
38
41
  subject: 'Message one',
39
42
  type: 'email',
40
43
  subtype: 'boards',
@@ -58,6 +61,7 @@ describe('Message', function() {
58
61
  var message = new Message({
59
62
  webhook: new mongoose.Types.ObjectId(),
60
63
  customer: totemCustomerId2,
64
+ organization: orgId2,
61
65
  subject: 'Message two',
62
66
  type: 'email',
63
67
  subtype: 'boards',
@@ -153,6 +157,20 @@ describe('Message', function() {
153
157
 
154
158
  });
155
159
 
160
+ it('gets messages for an org', function(done) {
161
+
162
+ config.CUSTOMER_ID = totemCustomerId1;
163
+
164
+ Message.getForOrg(orgId1, { before: moment().add(1, 'hour').toISOString()}, function(err, result) {
165
+ should.not.exist(err);
166
+ should.exist(result);
167
+ result.length.should.equal(1);
168
+ result[0].subject.should.equal('Message one');
169
+ done();
170
+ });
171
+
172
+ });
173
+
156
174
  it('tries to get messages for a person as an admin process', function(done) {
157
175
 
158
176
  config.CUSTOMER_ID = 'GLOBAL_PROCESS';