diff --git a/app/controllers/publishRealEstate.js b/app/controllers/publishRealEstate.js index eff5175..7e00e3d 100644 --- a/app/controllers/publishRealEstate.js +++ b/app/controllers/publishRealEstate.js @@ -1,7 +1,10 @@ const { findRealEstateByAgencyId } = require("../helpers/db/realEstate"); const { bulkUpsertKiviPhotos } = require("../helpers/db/kiviOriginalAdsPhotos"); const { currentKiviRealEstate } = require("../helpers/url"); - +const { + notifyForNewRealEstates, + notifyForNewAdPublish +} = require("../services/notificationService"); const validate = require("validate.js"); const { @@ -318,6 +321,11 @@ const postPublishInputs = async (req, res) => { await kiviOriginal.save(); + //Calling function to notify real estate owner that ads is published on Kivi page after 1 sec + setTimeout(notifyForNewAdPublish, 1000, realEstate, kiviOriginal); + //Calling function to notify users of new real estate after 2 min + setTimeout(notifyForNewRealEstates, 1000 * 60 * 2, [realEstate]); + res.redirect(nextStepPage); }; diff --git a/app/helpers/emailContentGenerator.js b/app/helpers/emailContentGenerator.js index d201e8f..62e66ba 100644 --- a/app/helpers/emailContentGenerator.js +++ b/app/helpers/emailContentGenerator.js @@ -202,9 +202,26 @@ const generateCheckUpEmail = searchRequest => { ${emailFooter}`; }; +const generateNewAdPublishEmail = (realEstate, numberOfMatchingRequests) => { + return `