mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 20:46:40 -04:00
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
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);
|
|
},
|
|
addUserToMailChimpList: function(user){
|
|
if (!user || !Users.can.editById(this.userId, user)) {
|
|
throw new Meteor.Error(601, __('sorry_you_cannot_edit_this_user'));
|
|
}
|
|
|
|
try {
|
|
return MailChimpList.add(user, false);
|
|
} catch (error) {
|
|
throw new Meteor.Error(500, error.message);
|
|
}
|
|
},
|
|
removeUserFromMailChimpList(user) {
|
|
if (!user || !Users.can.editById(this.userId, user)) {
|
|
throw new Meteor.Error(601, __('sorry_you_cannot_edit_this_user'));
|
|
}
|
|
|
|
try {
|
|
return MailChimpList.remove(user);
|
|
} catch (error) {
|
|
throw new Meteor.Error(500, error.message);
|
|
}
|
|
},
|
|
addEmailToMailChimpList: function (email) {
|
|
try {
|
|
return MailChimpList.add(email, true);
|
|
} catch (error) {
|
|
throw new Meteor.Error(500, error.message);
|
|
}
|
|
}
|
|
});
|