-
-
Save matthlavacka/6f01baee21adf4a35dfec50512c46d01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Time now ' + new Date()); | |
const t = new Date(); | |
t.setSeconds(t.getSeconds() + 10); | |
console.log('Setting job to future in 10 seconds ' + t); | |
SyncedCron.add({ | |
name: 'aggregateNotifications', | |
schedule: function (parser) { | |
// Every 12 hours | |
return parser.text('every 12 hours'); | |
}, | |
job: function () { | |
const time = new Date(Date.now() - 1000 * 3600 * 12); | |
notifications = Notifications.aggregate([ | |
{ "$match": { | |
"date": { "$gte": time }, | |
}}, | |
]); | |
_(notifications).each(function(item) { | |
}); | |
var xsmtpapi = { | |
"to": receiver, | |
"sub": { | |
":firstname":post.createdBy, | |
":friendname":username, | |
":artist":post.artist, | |
":title":post.title, | |
}, | |
"filters": { | |
"templates": { | |
"settings": { | |
"enable": 1, | |
"template_id": "d0fa08b2-9400-405f-a47e-d09bbda979b1" | |
} | |
} | |
}, | |
} | |
Email.send({ | |
from: "hello@village.fm", | |
to:receiver, | |
subject: subject, | |
headers: { | |
"X-SMTPAPI": JSON.stringify(xsmtpapi), | |
"Content-Type" : "text/html" | |
} | |
}); | |
} | |
}); | |
SyncedCron.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment