improve email notification copy; add different copy for daily email
This commit is contained in:
@@ -20,7 +20,11 @@ const generateRealEstateLinks = realEstates => {
|
||||
return realEstateLinks;
|
||||
};
|
||||
|
||||
const generateNotificationEmail = (realEstates, searchRequestId) => {
|
||||
const generateNotificationEmail = (
|
||||
realEstates,
|
||||
searchRequestId,
|
||||
dailyNotification = false
|
||||
) => {
|
||||
const truncateList = realEstates.length > MAX_REAL_ESTATES_IN_EMAIL;
|
||||
const realEstatesToShow = truncateList
|
||||
? realEstates.slice(0, MAX_REAL_ESTATES_IN_EMAIL)
|
||||
@@ -30,9 +34,20 @@ const generateNotificationEmail = (realEstates, searchRequestId) => {
|
||||
const realEstateLinks = generateRealEstateLinks(realEstatesToShow);
|
||||
const moreRealEstates = `<div>Kompletan spisak nekretnina možete pogledati na <a href="${allRealEstatesLink}">listi nekretnina</a><div>`;
|
||||
const emailFooter = generateEmailFooter(searchRequestId);
|
||||
const asapMessageBody =
|
||||
realEstates.length > 1
|
||||
? "Pronašli smo nekretnine koje odgovaraju Vašoj pretrazi"
|
||||
: "Pronašli smo nekretninu koja odgovara Vašoj pretrazi";
|
||||
|
||||
const dailyMessageBody =
|
||||
realEstates.length > 1
|
||||
? "U posljednja 24h objavljene su sljedeće nekretnine koje odgovaraju uslovima Vaše pretrage"
|
||||
: "U posljednja 24h objavljena je sljedeća nekretnina koja odgovara uslovima Vaše pretrage";
|
||||
|
||||
const messageBody = dailyNotification ? dailyMessageBody : asapMessageBody;
|
||||
|
||||
return `<h3>Zdravo</h3>
|
||||
<h4>Pronašli smo nekretnine koje odgovaraju Vašoj pretrazi</h4>
|
||||
<h4>${messageBody}</h4>
|
||||
<div>
|
||||
${realEstateLinks}
|
||||
<div/>
|
||||
|
||||
@@ -30,7 +30,7 @@ const notifyForNewSearchRequest = async searchRequest => {
|
||||
await sendEmail(email, "Kivi - novi zahtjev za pretragu", emailContent);
|
||||
};
|
||||
|
||||
const notifyMatches = async matches => {
|
||||
const notifyMatches = async (matches, dailyNotification = false) => {
|
||||
const searchRequestsToNotify = Object.keys(matches);
|
||||
|
||||
const asyncSendEmailActions = [];
|
||||
@@ -42,7 +42,8 @@ const notifyMatches = async matches => {
|
||||
if (allMatchingRealEstates.length > 0) {
|
||||
const emailContent = generateNotificationEmail(
|
||||
allMatchingRealEstates,
|
||||
id
|
||||
id,
|
||||
dailyNotification
|
||||
);
|
||||
const emailSubject = generateEmailSubject(
|
||||
allMatchingRealEstates.length,
|
||||
@@ -105,7 +106,7 @@ const notifyRequestsWithDailyOption = async () => {
|
||||
searchRequestMatch.save();
|
||||
}
|
||||
|
||||
await notifyMatches(matches);
|
||||
await notifyMatches(matches, true);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user