@dhyasama/totem-models 9.68.0 → 9.69.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.
|
@@ -18,9 +18,6 @@ module.exports = function(mongoose, config) {
|
|
|
18
18
|
// attach document to email (only option currently supported)
|
|
19
19
|
attachToEmail: { type: Boolean, required: true, default: true },
|
|
20
20
|
|
|
21
|
-
// job was added to queue to send email
|
|
22
|
-
sentToQueue: { type: Boolean, required: true, default: false },
|
|
23
|
-
|
|
24
21
|
// when email was sent
|
|
25
22
|
sentOn: { type: Date, required: false },
|
|
26
23
|
|
|
@@ -72,10 +69,8 @@ module.exports = function(mongoose, config) {
|
|
|
72
69
|
const self = this;
|
|
73
70
|
|
|
74
71
|
if (!cb) { throw new Error('cb is required'); }
|
|
75
|
-
if (!campaignId) { return cb(new Error('campaignId is required'), null); }
|
|
76
|
-
if (!mongoose.Types.ObjectId.isValid(campaignId)) { return cb(new Error('campaignId is not a valid ObjectId'), null); }
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
const query = self.find({
|
|
79
74
|
campaign: { $in: campaignIds }
|
|
80
75
|
});
|
|
81
76
|
|
|
@@ -124,22 +119,17 @@ module.exports = function(mongoose, config) {
|
|
|
124
119
|
|
|
125
120
|
};
|
|
126
121
|
|
|
127
|
-
|
|
128
|
-
// Scheduled worker jobs will use this and add them to the queue to send
|
|
129
|
-
LimitedPartnerCommunication.statics.getReadyToSend = function getReadyToSend(options, cb) {
|
|
122
|
+
LimitedPartnerCommunication.statics.getUnsentByCampaigns = function getUnsentByCampaigns(campaignIds, options, cb) {
|
|
130
123
|
|
|
131
124
|
const self = this;
|
|
132
|
-
const now = new Date();
|
|
133
125
|
|
|
134
126
|
if (!cb) { throw new Error('cb is required'); }
|
|
135
127
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
const query = self.find({
|
|
129
|
+
campaign: { $in: campaignIds },
|
|
130
|
+
$and: [{ sentOn: null }] // matches null or not set
|
|
139
131
|
});
|
|
140
132
|
|
|
141
|
-
query.populate('campaign');
|
|
142
|
-
|
|
143
133
|
query.exec(cb);
|
|
144
134
|
|
|
145
135
|
};
|