Fire comments email notifications
This commit is contained in:
parent
90f1e5ba9c
commit
a8a1c43f2c
24 changed files with 820 additions and 42 deletions
19
imports/modules/get-email-of-user.js
Normal file
19
imports/modules/get-email-of-user.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* eslint-disable import/no-absolute-path */
|
||||
|
||||
import getOAuthProfile from '/imports/modules/get-oauth-profile';
|
||||
|
||||
const getEmailOf = (user) => {
|
||||
const hasPassword = user.services && user.services.password && user.services.password.bcrypt;
|
||||
|
||||
// console.log(`Has password: ${hasPassword}`);
|
||||
const OAuthProfile = getOAuthProfile({
|
||||
password: hasPassword,
|
||||
profile: user.profile
|
||||
}, user);
|
||||
const firstName = OAuthProfile ? OAuthProfile.name.first : user.profile.name.first;
|
||||
const emailAddress = OAuthProfile ? OAuthProfile.email :
|
||||
user && user.emails[0] && user.emails[0].verified ? user.emails[0].address : null;
|
||||
return { emailAddress, firstName };
|
||||
};
|
||||
|
||||
export default getEmailOf;
|
||||
|
|
@ -1,11 +1,21 @@
|
|||
/* eslint-disable import/no-absolute-path */
|
||||
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
// import { Email } from 'meteor/email';
|
||||
import i18n from 'i18next';
|
||||
import { getFileNameOfLang } from '/imports/api/Utility/server/files.js';
|
||||
import sendMail from '/imports/startup/server/email';
|
||||
import getPrivateFile from './get-private-file';
|
||||
import templateToText from './handlebars-email-to-text';
|
||||
import templateToHTML from './handlebars-email-to-html';
|
||||
import { getFileNameOfLang } from '/imports/api/Utility/server/files.js';
|
||||
import sendMail from '/imports/startup/server/email';
|
||||
import i18n from 'i18next';
|
||||
|
||||
export function subjectTruncate(n = 70, useWordBoundary = true) {
|
||||
// https://stackoverflow.com/questions/1199352/smart-way-to-shorten-long-strings-with-javascript
|
||||
if (this.length <= n) {
|
||||
return `${this}`;
|
||||
}
|
||||
const subString = this.substr(0, n - 1);
|
||||
return `${useWordBoundary ? subString.substr(0, subString.lastIndexOf(' ')) : subString}...`;
|
||||
}
|
||||
|
||||
const sendEmail = (options, { resolve, reject }) => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue