Send enrollment emails to groups rather than accounts


#1

I am hoping someone can help out with this small problem I am facing. I want to send enrollment emails to a group for a user rather than just a user. I can’t necessarily find a way to develop around the current framework of enrollment emails to get this done without modifying the method.

The webapp is focused on guilds in a video game, so you can be invited to an individual guild, and invited to multiple guilds.

Essentially, I want to do something like this:

Meteor.methods({
  'inviteToGuild': function (playerProfile, guildId) {
    var userId = Accounts.createUser(playerProfile);
    Accounts.sendGroupEnrollmentEmail(userId, guildId);
    return userId;
  }
});

Accounts.onGroupEnrollmentLink(function (token, groupId) {
  var user = Meteor.users.findOne({
    "services.password.reset.token": token
  });
  Roles.addUserToRole(user._id, 'player', groupId);
});

One method I took was to make an entirely new set of methods and email templates under “enrollToGroup” but this seems clunky and unmaintainable. Has anyone faced this before?