diff --git a/functions/model/mailer/lib.js b/functions/model/mailer/lib.js index d477945a2..f9bed5427 100644 --- a/functions/model/mailer/lib.js +++ b/functions/model/mailer/lib.js @@ -18,6 +18,7 @@ ***********************************************************/ const { sendMail } = require("../email/lib"); const { getTask } = require("../tasks/lib"); +const { getTeam } = require("../teams/lib"); const { getUserUseEmail } = require("../users/lib"); const { generateTemplate } = require("./tark/generateTemplate"); @@ -79,6 +80,74 @@ exports.taskMailer = function(mailType, taskId, orgDomain, customParameter) { return Promise.resolve(promise); }; +/** + * Description + * @param {any} orgDomain + * @param {any} teamName + * @param {any} sprintName + * @param {any} endDate + * @return {any} + */ +exports.sprintReminderMailer = function(orgDomain, teamName, sprintName, endDate) { + let teamMembers = []; + let valueArray = []; + const promise = getTeam(orgDomain, teamName).then( (teamData) => { + teamMembers = teamData.TeamMembers; + teamMembers.forEach((member) => { + getUserUseEmail(member).then((memberData)=> { + valueArray = []; + valueArray.push(memberData.displayName); + valueArray.push(sprintName); + valueArray.push(teamName); + valueArray.push(endDate); + const mailType = "Sprint_Reminder"; + generateTemplate(mailType, valueArray).then((data) => { + const message = data; + sendMail("admin@worktez.com", message[0], message[1]); + }); + }); + }); + }).catch((error) => { + console.error(error); + return error; + }); + return Promise.resolve(promise); +}; + + +/** + * Description + * @param {any} orgDomain + * @param {any} teamName + * @param {any} sprintName + * @param {any} startDate + * @return {any} + */ +exports.sprintCreationMailer = function(orgDomain, teamName, sprintName, startDate) { + let teamMembers = []; + let valueArray = []; + const promise = getTeam(orgDomain, teamName).then( (teamData) => { + teamMembers = teamData.TeamMembers; + teamMembers.forEach((member) => { + getUserUseEmail(member).then((memberData)=> { + valueArray = []; + valueArray.push(memberData.displayName); + valueArray.push(sprintName); + valueArray.push(teamName); + valueArray.push(startDate); + const mailType = "Sprint_Creation"; + generateTemplate(mailType, valueArray).then((data) => { + const message = data; + sendMail("admin@worktez.com", message[0], message[1]); + }); + }); + }); + }).catch((error) => { + console.error(error); + return error; + }); + return Promise.resolve(promise); +}; /** * Description @@ -141,4 +210,5 @@ exports.demoRequestMailer = function(mailType, userName, userEmail, userContact, const message = data; sendMail("admin@worktez.com", message[0], message[1]); }); -}; \ No newline at end of file +}; + diff --git a/functions/model/mailer/tark/generateTemplate.js b/functions/model/mailer/tark/generateTemplate.js index 14f6284e6..27edbd58b 100644 --- a/functions/model/mailer/tark/generateTemplate.js +++ b/functions/model/mailer/tark/generateTemplate.js @@ -77,6 +77,12 @@ exports.generateTemplate = function(mailType, valueArray) { } else if (mailType == "Demo_Request") { templateName = "demoRequest.html"; mailSubject = "New Demo Request - Worktez"; + } else if (mailType == "Sprint_Reminder") { + templateName = "sprintReminder.html"; + mailSubject = "Sprint Reminder - Worktez"; + } else if (mailType == "Sprint_Creation") { + templateName = "sprintCreation.html"; + mailSubject = "New Sprint Started - Worktez"; } const promise = getTemplate(templateName).then((data) => { if (templateName == "comment.html") { @@ -156,6 +162,18 @@ exports.generateTemplate = function(mailType, valueArray) { data = data.replace("$userEmail$", valueArray[1]); data = data.replace("$userContact$", valueArray[2]); data = data.replace("$orgName$", valueArray[3]); + } else if (templateName == "sprintReminder.html") { + mailSubject = "Sprint Reminder - Worktez" + "( " + valueArray[2] + " )"; + data = data.replace("$MemberName$", valueArray[0]); + data = data.replace("$SprintName$", valueArray[1]); + data = data.replace("$TeamName$", valueArray[2]); + data = data.replace("$EndDate$", valueArray[3]); + } else if (templateName == "sprintCreation.html") { + mailSubject = "New Sprint Started - Worktez" + "( " + valueArray[2] + " )"; + data = data.replace("$MemberName$", valueArray[0]); + data = data.replace("$SprintName$", valueArray[1]); + data = data.replace("$TeamName$", valueArray[2]); + data = data.replace("$StartDate$", valueArray[3]); } subjectMessage = mailSubject; message.push(subjectMessage); diff --git a/functions/model/mailer/templates/sprintCreation.html b/functions/model/mailer/templates/sprintCreation.html new file mode 100644 index 000000000..96d09163f --- /dev/null +++ b/functions/model/mailer/templates/sprintCreation.html @@ -0,0 +1,425 @@ + + + +
+ + + + + + +|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
+
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
+