-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaidVersionIntroducer.js
48 lines (43 loc) · 1.27 KB
/
paidVersionIntroducer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var config = require('config');
var util = require('util');
var partials = require('express-partials');
var session = require('express-session')
var MongoStore = require('connect-mongo')(session);
var fs = require('fs');
//mongo
var mongo = require('mongodb');
var monk = require('monk');
var db = monk(config.get('mongo.uri'));
var async = require('async');
var users = db.get('users')
var mailer = require('./app_modules/mailer');
var paidVersionIntroTemplate = fs.readFileSync(path.join(__dirname,'./views/emails/paid-version-intro.ejs'), 'utf8');
async.waterfall([
function(callback){
users.find({google:{$exists:true},unsubscribes:{$exists:false}},function(err,allUsers){
callback(err,allUsers)
})
},
function(allUsers,callback){
console.log('got %s users',allUsers.length)
mailer.sendMulti(
allUsers, //recipients
'[' + config.get('app.name') + '] Introducing GitMonkey Paid Version',
paidVersionIntroTemplate,
{
},
'paid-version-intro',
function(err){
callback(err)
}
);
}
],function(err){
console.log('err is %s',err)
})