Only send emails to users with emails
This commit is contained in:
parent
fc9f3f1aa7
commit
96c524a90c
1 changed files with 15 additions and 14 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import sendEmail from '../../../modules/server/send-email';
|
import sendEmail from '../../../modules/server/send-email';
|
||||||
import getOAuthProfile from '../../../modules/get-oauth-profile';
|
import getOAuthProfile from '../../../modules/get-oauth-profile';
|
||||||
|
|
@ -9,20 +10,20 @@ export default (options, user, lang) => {
|
||||||
const applicationName = i18n.t('AppName');
|
const applicationName = i18n.t('AppName');
|
||||||
const firstName = OAuthProfile ? OAuthProfile.name.first : options.profile.name.first;
|
const firstName = OAuthProfile ? OAuthProfile.name.first : options.profile.name.first;
|
||||||
const emailAddress = OAuthProfile ? OAuthProfile.email : options.email;
|
const emailAddress = OAuthProfile ? OAuthProfile.email : options.email;
|
||||||
|
if (emailAddress) {
|
||||||
return sendEmail({
|
sendEmail({
|
||||||
to: emailAddress,
|
to: emailAddress,
|
||||||
from: `${applicationName} <noreply@comunes.org>`,
|
from: `${applicationName} <noreply@comunes.org>`,
|
||||||
subject: `[${applicationName}] Welcome, ${firstName}!`,
|
subject: `[${applicationName}] Welcome, ${firstName}!`,
|
||||||
lang,
|
lang,
|
||||||
template: 'welcome',
|
template: 'welcome',
|
||||||
templateVars: {
|
templateVars: {
|
||||||
applicationName,
|
applicationName,
|
||||||
firstName,
|
firstName,
|
||||||
welcomeUrl: Meteor.absoluteUrl('subscriptions') // e.g., returns http://localhost:3000/documents
|
welcomeUrl: Meteor.absoluteUrl('subscriptions') // e.g., returns http://localhost:3000/documents
|
||||||
}
|
}
|
||||||
})
|
}).catch((error) => {
|
||||||
.catch((error) => {
|
|
||||||
throw new Meteor.Error('500', `${error}`);
|
throw new Meteor.Error('500', `${error}`);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue