56 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-02-06 15:21:25 -05:00
var allowed = {};
allowed["ybq987@gmail.com"] = true;
allowed["dweinger@bloomfield.org"] = true;
2016-02-11 19:11:57 -05:00
//allowed["ksjdragon@gmail.com"] = true;
2016-02-06 15:21:25 -05:00
schedule.permit(['insert', 'update', 'remove']).never().apply();
// schedule.remove({});
SyncedCron.add({
name: 'Remove Entries past today',
schedule: function(parser) {
2016-02-24 09:38:55 -05:00
return parser.recur().on('19:35:00').time();
},
job: function() {
2016-03-01 16:46:37 -05:00
var thedate = moment();
var today = thedate.format("X");
// Remove matchng Documents
schedule.remove({timestamp: {$lt: today}});
2016-03-01 16:46:37 -05:00
console.log(thedate.format());
}
});
SyncedCron.start();
2016-02-06 15:21:25 -05:00
Meteor.methods({
2016-03-01 16:46:37 -05:00
add_button: function(chrome, pre, post, other) {
2016-02-08 21:25:30 -05:00
if ((Meteor.user() != undefined) && (Meteor.user().services.google.email in allowed) && !(pre === "")) {
mymoment = moment(pre.replace("/", "-"), "MM-DD-YYYY");
2016-02-10 11:58:21 -05:00
thepretext = mymoment.toISOString().split("T")[0];
time = mymoment.format("X");
previous = schedule.find({"pretext": thepretext}).fetch();
if (previous.length > 0) {
entry = previous[0]
2016-03-01 16:46:37 -05:00
schedule.update(entry._id, {"aftertext": post, "pretext": entry.pretext, "other": other, "timestamp": entry.timestamp});
2016-02-10 11:58:21 -05:00
} else {
schedule.insert({
"pretext": thepretext,
2016-02-08 21:25:30 -05:00
"aftertext": post,
2016-03-01 16:46:37 -05:00
"other": other,
2016-02-10 11:58:21 -05:00
"timestamp": time
});
}
2016-02-06 15:21:25 -05:00
}
},
remove: function(chrome) {
if (Meteor.user() != undefined && Meteor.user().services.google.email in allowed) {
schedule.remove(chrome._id);
}
2016-02-06 15:21:25 -05:00
}
2016-02-07 15:20:03 -05:00
})