Updating group.removeMember api to send an email for rescinded party invite (#8280)

* feature: updating group.removeMember api to send an email to a user when an invite was rescinded or when no message was provided by the performing user.

* Adding validation that the email is being sent to the right user.

* fixing linting error
This commit is contained in:
Travis
2016-12-15 11:47:18 -08:00
committed by Matteo Pagliazzi
parent faeb040a83
commit 9ed17df1e3
2 changed files with 50 additions and 3 deletions

View File

@@ -468,9 +468,10 @@ api.leaveGroup = {
};
// Send an email to the removed user with an optional message from the leader
function _sendMessageToRemoved (group, removedUser, message) {
function _sendMessageToRemoved (group, removedUser, message, isInGroup) {
if (removedUser.preferences.emailNotifications.kickedGroup !== false) {
sendTxnEmail(removedUser, `kicked-from-${group.type}`, [
let subject = isInGroup ? `kicked-from-${group.type}` : `${group.type}-invite-rescinded`;
sendTxnEmail(removedUser, subject, [
{name: 'GROUP_NAME', content: group.name},
{name: 'MESSAGE', content: message},
{name: 'GUILDS_LINK', content: '/#/options/groups/guilds/public'},
@@ -575,7 +576,7 @@ api.removeGroupMember = {
}
let message = req.query.message;
if (message) _sendMessageToRemoved(group, member, message);
_sendMessageToRemoved(group, member, message, isInGroup);
await Bluebird.all([
member.save(),