`;
const emailFooter = generateEmailFooter(searchRequestId);
const asapMessageBody =
realEstates.length > 1
@@ -70,6 +73,7 @@ const generateNewSearchRequestEmail = (searchRequest, matchingRealEstates) => {
} = searchRequest;
const realEstateLinks = generateRealEstateLinks(matchingRealEstates);
+
const instantRealEstatesText = `
U međuvremenu pogledajte neke od nedavno objavljenih nekretnina koje odgovaraju Vašim uslovima pretrage :
diff --git a/app/services/notificationService.js b/app/services/notificationService.js
index 7495e17..7a4a62a 100644
--- a/app/services/notificationService.js
+++ b/app/services/notificationService.js
@@ -8,7 +8,10 @@ const {
generateNewSearchRequestEmail,
generateEmailSubject
} = require("../helpers/emailContentGenerator");
-const { findNotNotifiedMatches } = require("../helpers/db/searchRequestMatch");
+const {
+ findNotNotifiedMatches,
+ findRealEstatesForSearchRequest
+} = require("../helpers/db/searchRequestMatch");
const { sendEmail } = require("../services/emailService");
const notifyForNewRealEstates = async newRealEstates => {
@@ -39,10 +42,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(