@dhyasama/totem-models 3.2.0 → 3.2.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/lib/Document.js CHANGED
@@ -25,7 +25,10 @@ module.exports = function(mongoose, config) {
25
25
 
26
26
  contentLength: { type: String, required: true },
27
27
 
28
- s3key: { type: String, required: true }
28
+ s3: {
29
+ bucket: { type: String, required: true, trim: true },
30
+ key: { type: String, required: true, trim: true }
31
+ }
29
32
 
30
33
  });
31
34
 
@@ -61,7 +64,6 @@ module.exports = function(mongoose, config) {
61
64
  };
62
65
 
63
66
  doc.createdOn = new Date();
64
- doc.customer = config.CUSTOMER_ID;
65
67
 
66
68
  this.create(doc, addToModel);
67
69
 
@@ -78,7 +78,7 @@ module.exports = function(mongoose, config) {
78
78
 
79
79
  var self = this;
80
80
  var query = self.find({ totemCustomerId: customerId, _id: { $gt: sinceObjectId } });
81
-
81
+ query.populate('attendees.external');
82
82
  query.exec(cb);
83
83
 
84
84
  };
package/lib/Message.js CHANGED
@@ -25,7 +25,8 @@ module.exports = function(mongoose, config) {
25
25
  external: [{ type: Schema.ObjectId, ref: 'Person', index: true }] // everyone else
26
26
  },
27
27
  notes: [ { type: Schema.ObjectId, ref: 'Note' } ],
28
- documents: [ { type: Schema.ObjectId, ref: 'Document' } ]
28
+ documents: [ { type: Schema.ObjectId, ref: 'Document' } ],
29
+ raw: { type: Schema.Types.Mixed, required: true }
29
30
 
30
31
  });
31
32
 
@@ -1306,7 +1306,7 @@ module.exports = function(mongoose, config) {
1306
1306
  self.people = _.reject(self.people, function(p) { return p.person == null; });
1307
1307
 
1308
1308
  // dedupe
1309
- self.people = _.uniq(self.people, function(p) { return p.person._id ? p.person._id : p.person; });
1309
+ self.people = _.uniq(self.people, function(p) { return p.person._id ? p.person._id.toString() : p.person.toString(); });
1310
1310
 
1311
1311
  };
1312
1312
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
package/test/Document.js CHANGED
@@ -51,7 +51,8 @@ describe('Document', function() {
51
51
 
52
52
  message = new Message({
53
53
  webhook: new mongoose.Types.ObjectId(),
54
- customer: config.CUSTOMER_ID
54
+ customer: config.CUSTOMER_ID,
55
+ raw: { test: 'test' }
55
56
  });
56
57
 
57
58
  Message.upsert(message, function(err, result) {
@@ -129,11 +130,15 @@ describe('Document', function() {
129
130
  it('creates a document for an interaction', function(done) {
130
131
 
131
132
  Document.createForModel({
133
+ customer: config.CUSTOMER_ID,
132
134
  createdBy: documentCreator,
133
135
  name: 'your_mom.doc',
134
136
  contentType: 'application/doc',
135
137
  contentLength: 1248,
136
- s3key: '/totem/docs'
138
+ s3: {
139
+ bucket: 'totem',
140
+ key: 'docs'
141
+ }
137
142
  }, Interaction, interaction._id, function(err, result) {
138
143
 
139
144
  should.not.exist(err);
@@ -151,11 +156,15 @@ describe('Document', function() {
151
156
  it('creates a document for a message', function(done) {
152
157
 
153
158
  Document.createForModel({
159
+ customer: config.CUSTOMER_ID,
154
160
  createdBy: documentCreator,
155
161
  name: 'plain.txt',
156
162
  contentType: 'text/plain',
157
163
  contentLength: 124,
158
- s3key: '/totem/doculate'
164
+ s3: {
165
+ bucket: 'totem',
166
+ key: 'docs'
167
+ }
159
168
  }, Message, message._id, function(err, result) {
160
169
 
161
170
  should.not.exist(err);
@@ -173,11 +182,15 @@ describe('Document', function() {
173
182
  it('creates a document for an organization', function(done) {
174
183
 
175
184
  Document.createForModel({
185
+ customer: config.CUSTOMER_ID,
176
186
  createdBy: documentCreator,
177
187
  name: 'test_file.jpg',
178
188
  contentType: 'image/jpeg',
179
189
  contentLength: 12345,
180
- s3key: '/totem/documents'
190
+ s3: {
191
+ bucket: 'totem',
192
+ key: 'docs'
193
+ }
181
194
  }, Organization, org._id, function(err, result) {
182
195
 
183
196
  should.not.exist(err);
@@ -197,11 +210,15 @@ describe('Document', function() {
197
210
  it('creates a document for a person', function(done) {
198
211
 
199
212
  Document.createForModel({
213
+ customer: config.CUSTOMER_ID,
200
214
  createdBy: documentCreator,
201
215
  name: 'test.pdf',
202
216
  contentType: 'application/pdf',
203
217
  contentLength: 54321,
204
- s3key: '/documents/totem'
218
+ s3: {
219
+ bucket: 'totem',
220
+ key: 'docs'
221
+ }
205
222
  }, Person, person._id, function(err, result) {
206
223
 
207
224
  should.not.exist(err);
package/test/Message.js CHANGED
@@ -34,7 +34,8 @@ describe('Message', function() {
34
34
  subject: 'Message one',
35
35
  recipients: {
36
36
  external: [externalAttendee1]
37
- }
37
+ },
38
+ raw: { test: 'test' }
38
39
  });
39
40
 
40
41
  Message.upsert(message, function(err, result) {
@@ -53,7 +54,8 @@ describe('Message', function() {
53
54
  subject: 'Message two',
54
55
  recipients: {
55
56
  external: [externalAttendee2]
56
- }
57
+ },
58
+ raw: { test: 'test' }
57
59
  });
58
60
 
59
61
  Message.upsert(message, function(err, result) {
@@ -114,7 +116,8 @@ describe('Message', function() {
114
116
  subject: 'test 3',
115
117
  recipients: {
116
118
  external: [new mongoose.Types.ObjectId()]
117
- }
119
+ },
120
+ raw: { test: 'test' }
118
121
  });
119
122
 
120
123
  Message.upsert(message, function(err, result) {