Added notification for new ad pusblish and new real estate.
This commit is contained in:
@@ -11,7 +11,8 @@ const {
|
||||
generateNotificationEmail,
|
||||
generateNewSearchRequestEmail,
|
||||
generateEmailSubject,
|
||||
generateCheckUpEmail
|
||||
generateCheckUpEmail,
|
||||
generateNewAdPublishEmail
|
||||
} = require("../helpers/emailContentGenerator");
|
||||
const {
|
||||
findNotNotifiedMatches,
|
||||
@@ -147,9 +148,27 @@ const checkUpNotify = async () => {
|
||||
await Promise.all(asyncSendEmailActions);
|
||||
};
|
||||
|
||||
const notifyForNewAdPublish = async (realEstate, kiviOriginal) => {
|
||||
// console.log("Real estate:", realEstate);
|
||||
// console.log("Kivi original:", kiviOriginal);
|
||||
const email = kiviOriginal.dataValues.email;
|
||||
const emailSubject = `${stagingTag}Kivi: Uspješno ste objavili oglas!`;
|
||||
const matches = await matchRealEstates([realEstate]);
|
||||
|
||||
const numberOfMatchingRequests = Object.keys(matches).length;
|
||||
|
||||
const emailContent = generateNewAdPublishEmail(
|
||||
realEstate,
|
||||
numberOfMatchingRequests
|
||||
);
|
||||
|
||||
await sendEmail(email, emailSubject, emailContent);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
notifyForNewRealEstates,
|
||||
notifyForNewSearchRequest,
|
||||
notifyRequestsWithDailyOption,
|
||||
notifyForNewAdPublish,
|
||||
checkUpNotify
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user