mirror of
https://github.com/towfiqi/serpbear
synced 2025-06-26 18:15:54 +00:00
fix: Fixes missing Search Console data in Email notification when its integrated through App settings.
This commit is contained in:
parent
29c455ea56
commit
040dab1517
@ -78,7 +78,7 @@ const sendNotificationEmail = async (domain: Domain, settings: SettingsType) =>
|
||||
const domainKeywords:Keyword[] = await Keyword.findAll(query);
|
||||
const keywordsArray = domainKeywords.map((el) => el.get({ plain: true }));
|
||||
const keywords: KeywordType[] = parseKeywords(keywordsArray);
|
||||
const emailHTML = await generateEmail(domainName, keywords);
|
||||
const emailHTML = await generateEmail(domainName, keywords, settings);
|
||||
await transporter.sendMail({
|
||||
from: fromEmail,
|
||||
to: domain.notification_emails || notification_email,
|
||||
|
@ -74,7 +74,7 @@ const getPositionChange = (history:KeywordHistory, position:number) : number =>
|
||||
* @param {keywords[]} keywords - Keywords to scrape
|
||||
* @returns {Promise}
|
||||
*/
|
||||
const generateEmail = async (domainName:string, keywords:KeywordType[]) : Promise<string> => {
|
||||
const generateEmail = async (domainName:string, keywords:KeywordType[], settings: SettingsType) : Promise<string> => {
|
||||
const emailTemplate = await readFile(path.join(__dirname, '..', '..', '..', '..', 'email', 'email.html'), { encoding: 'utf-8' });
|
||||
const currentDate = dayjs(new Date()).format('MMMM D, YYYY');
|
||||
const keywordsCount = keywords.length;
|
||||
@ -113,7 +113,8 @@ const generateEmail = async (domainName:string, keywords:KeywordType[]) : Promis
|
||||
.replace('{{stat}}', stat)
|
||||
.replace('{{preheader}}', stat);
|
||||
|
||||
const isConsoleIntegrated = !!(process.env.SEARCH_CONSOLE_PRIVATE_KEY && process.env.SEARCH_CONSOLE_CLIENT_EMAIL);
|
||||
const isConsoleIntegrated = !!(process.env.SEARCH_CONSOLE_PRIVATE_KEY && process.env.SEARCH_CONSOLE_CLIENT_EMAIL)
|
||||
|| (settings.search_console_client_email && settings.search_console_private_key);
|
||||
const htmlWithSCStats = isConsoleIntegrated ? await generateGoogeleConsoleStats(domainName) : '';
|
||||
const emailHTML = updatedEmail.replace('{{SCStatsTable}}', htmlWithSCStats);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user