Merge branch 'master' into 'checkup-email'

# Conflicts:
#   app/config/appConfig.js
#   app/services/notificationService.js
This commit is contained in:
Naida Vatric
2020-01-31 21:59:26 +00:00
26 changed files with 972 additions and 195 deletions

View File

@@ -11,7 +11,8 @@ const {
} = require("../helpers/emailContentGenerator");
const {
findNotNotifiedMatches,
findAllRequestsForCheckUp
findAllRequestsForCheckUp,
findRealEstatesForSearchRequest
} = require("../helpers/db/searchRequestMatch");
const { sendEmail } = require("../services/emailService");
@@ -43,10 +44,18 @@ const notifyMatches = async (matches, dailyNotification = false) => {
const { email, subscribed } = searchRequest;
if (notifyNow && subscribed) {
const allMatchingRealEstates = matches[id].realEstates || [];
//Variable allMatchingRealEstates are real estates that are "new" on the market
//the ones that we notify user in this moment, not all that already exists in db
//New variable allRealEstates are all real estates that exists in db for search req
const allRealEstates = await findRealEstatesForSearchRequest(id);
const noAllRealEstates = allRealEstates.length;
if (allMatchingRealEstates.length > 0) {
const emailContent = generateNotificationEmail(
allMatchingRealEstates,
id,
noAllRealEstates,
dailyNotification
);
const emailSubject = generateEmailSubject(