2016-03-18 11:53:46 +09:00
|
|
|
import Campaign from "./campaign.js";
|
|
|
|
import MailChimpList from "./mailchimp.js";
|
|
|
|
|
|
|
|
Meteor.methods({
|
|
|
|
sendCampaign: function () {
|
|
|
|
if(Users.is.adminById(this.userId))
|
|
|
|
return Campaign.scheduleNextWithMailChimp(false);
|
|
|
|
},
|
|
|
|
testCampaign: function () {
|
|
|
|
if(Users.is.adminById(this.userId))
|
|
|
|
return Campaign.scheduleNextWithMailChimp(true);
|
|
|
|
},
|
|
|
|
addCurrentUserToMailChimpList: function(){
|
|
|
|
var currentUser = Meteor.users.findOne(this.userId);
|
|
|
|
try {
|
|
|
|
return MailChimpList.add(currentUser, false);
|
|
|
|
} catch (error) {
|
|
|
|
throw new Meteor.Error(500, error.message);
|
|
|
|
}
|
|
|
|
},
|
2016-05-23 09:07:13 +02:00
|
|
|
removeCurrentUserFromMailChimpList() {
|
|
|
|
var currentUser = Meteor.users.findOne(this.userId);
|
|
|
|
try {
|
|
|
|
return MailChimpList.remove(currentUser);
|
|
|
|
} catch (error) {
|
|
|
|
throw new Meteor.Error(500, error.message);
|
|
|
|
}
|
|
|
|
},
|
2016-03-18 11:53:46 +09:00
|
|
|
addEmailToMailChimpList: function (email) {
|
|
|
|
try {
|
|
|
|
return MailChimpList.add(email, true);
|
|
|
|
} catch (error) {
|
|
|
|
throw new Meteor.Error(500, error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|