@dhyasama/totem-models 3.8.0 → 3.8.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 +37 -0
- package/lib/Message.js +1 -0
- package/package.json +1 -1
package/lib/Document.js
CHANGED
|
@@ -34,6 +34,42 @@ module.exports = function(mongoose, config) {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
///////////////////////////////////////////////////////////////////////////////////////
|
|
38
|
+
// VIRTUALS
|
|
39
|
+
// Properties that are not persisted to the database
|
|
40
|
+
///////////////////////////////////////////////////////////////////////////////////////
|
|
41
|
+
|
|
42
|
+
Document.virtual('ignore').get(function () {
|
|
43
|
+
|
|
44
|
+
var self = this;
|
|
45
|
+
var contentLength = self.contentLength || 0;
|
|
46
|
+
var name = self.name || '';
|
|
47
|
+
name = name.toUpperCase();
|
|
48
|
+
|
|
49
|
+
// Probably an Exchange file
|
|
50
|
+
// Exchange creates files such as ATT00001.htm and ATT00002.txt, one for each attachment
|
|
51
|
+
if (name.indexOf('ATT00') == 0) return true;
|
|
52
|
+
|
|
53
|
+
// Google Calendar invitation
|
|
54
|
+
// No need to show since it's in-lined
|
|
55
|
+
else if (name == 'INVITE.ICS' || name == 'INVITATION.ICS') return true;
|
|
56
|
+
|
|
57
|
+
// Probably a signature logo
|
|
58
|
+
else if (name.indexOf('IMAGE0') == 0 && contentLength < 3000) return true;
|
|
59
|
+
|
|
60
|
+
else return false;
|
|
61
|
+
|
|
62
|
+
// {
|
|
63
|
+
// "Name": "image001.jpg",
|
|
64
|
+
// "ContentType": "image/jpeg",
|
|
65
|
+
// "ContentLength": 2468,
|
|
66
|
+
// "ContentID": ""
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
37
73
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
38
74
|
// METHODS
|
|
39
75
|
// Methods operate on a single document that has already been returned
|
|
@@ -131,6 +167,7 @@ module.exports = function(mongoose, config) {
|
|
|
131
167
|
// CONFIG
|
|
132
168
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
133
169
|
|
|
170
|
+
Document.set('toJSON', { virtuals: true });
|
|
134
171
|
Document.set('autoIndex', false);
|
|
135
172
|
Document.on('index', function(err) { console.log('error building document indexes: ' + err); });
|
|
136
173
|
|
package/lib/Message.js
CHANGED
|
@@ -270,6 +270,7 @@ module.exports = function(mongoose, config) {
|
|
|
270
270
|
///////////////////////////////////////
|
|
271
271
|
|
|
272
272
|
Message.set('autoIndex', false);
|
|
273
|
+
Message.set('toJSON', { virtuals: true });
|
|
273
274
|
|
|
274
275
|
var deepPopulate = require('mongoose-deep-populate')(mongoose);
|
|
275
276
|
Message.plugin(deepPopulate);
|