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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ + + + + +
+ + + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +

New Sprint has been Started

+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+

Hi $MemberName$,

+

 

+

The new sprint $SprintName$ for team $TeamName$ has been started on $StartDate$.

+

 

+

Please review your assigned task for the current sprint.

+

 

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ + + + +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+

Worktez © All Rights Reserved.

+

Simplify and organize the way teams work.

+

 

+

If you have any thoughts, queries about this email, please reach out to www.worktez.com .

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+
+ + + + + + + + + + +
+ + LinkedIn + +
+ + + + + + + + + +
+ + YouTube + +
+ + + + + + + + + +
+ + GitHub + +
+ + + + +
+
+ +
+ + +
+
+
+ + +
+
+
+ + + + +
+ + + + + \ No newline at end of file diff --git a/functions/model/mailer/templates/sprintReminder.html b/functions/model/mailer/templates/sprintReminder.html new file mode 100644 index 000000000..75f59810a --- /dev/null +++ b/functions/model/mailer/templates/sprintReminder.html @@ -0,0 +1,425 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ + + + + +
+ + + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +

The Sprint is Almost Over

+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+

Hi $MemberName$,

+

 

+

The current sprint $SprintName$ for team $TeamName$ is coming to an end on $EndDate$.

+

 

+

Please complete your pending tasks before this date to avoid automatic transfer to the next sprint.

+

 

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ + + + +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+

Worktez © All Rights Reserved.

+

Simplify and organize the way teams work.

+

 

+

If you have any thoughts, queries about this email, please reach out to www.worktez.com .

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+
+ + + + + + + + + + +
+ + LinkedIn + +
+ + + + + + + + + +
+ + YouTube + +
+ + + + + + + + + +
+ + GitHub + +
+ + + + +
+
+ +
+ + +
+
+
+ + +
+
+
+ + + + +
+ + + + + \ No newline at end of file diff --git a/functions/model/scheduledFunctions/tark/autoSprint.js b/functions/model/scheduledFunctions/tark/autoSprint.js index f770f569f..a529e78dc 100644 --- a/functions/model/scheduledFunctions/tark/autoSprint.js +++ b/functions/model/scheduledFunctions/tark/autoSprint.js @@ -19,6 +19,7 @@ ***********************************************************/ const { createSprintName } = require("../../application/lib"); +const { sprintReminderMailer } = require("../../mailer/lib"); const { getAllOrgs } = require("../../organization/lib"); const { getSprint } = require("../../sprints/lib"); const { updateAutoSprintStatus } = require("../../sprints/tark/updateAutoSprintStatus"); @@ -36,13 +37,14 @@ exports.autoSprint = function() { const teamsPromise = getAllTeams(orgDomain).then(function(doc) { doc.forEach(function(tData) { const teamData = tData.data(); + let endDate; + const date = new Date(); if (teamData.SchedulerDetails.AutoSprint == true) { teamPromises.push( getSprint(orgDomain, teamData.TeamName, createSprintName(teamData.CurrentSprintId)) .then(function(sdata) { - const endDate = new Date(sdata.EndDate); - const date = new Date(); + endDate = new Date(sdata.EndDate); console.log(date, endDate); if (date > endDate) { @@ -54,7 +56,11 @@ exports.autoSprint = function() { } if (teamData.SchedulerDetails.TimelyEmail == true) { - // Send Email about sprint Activity + const diffTime = Math.abs(endDate - date); + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + if (diffDays<=5) { + sprintReminderMailer(orgDomain, teamData.TeamName, teamData.createSprintName(teamData.currentSprintId)); + } console.log("Sending Timely Emails", teamData.Id); } }); diff --git a/functions/model/sprints/tark/updateAutoSprintStatus.js b/functions/model/sprints/tark/updateAutoSprintStatus.js index 8f35b2bdb..9e8a2b654 100644 --- a/functions/model/sprints/tark/updateAutoSprintStatus.js +++ b/functions/model/sprints/tark/updateAutoSprintStatus.js @@ -18,6 +18,7 @@ ***********************************************************/ const { currentDate, currentTime, createSprintName, addDays } = require("../../application/lib"); +const { sprintCreationMailer } = require("../../mailer/lib"); const { getOrgUseAppKey } = require("../../organization/lib"); const { migrateTasks } = require("../../tasks/tark/migrateTasks"); const { getTeamUseTeamId, updateTeamDetails } = require("../../teams/lib"); @@ -114,6 +115,7 @@ exports.updateAutoSprintStatus = function(appKey, teamId) { }; const updateTeamCurrentSprint = updateTeamDetails(inputJson, orgDomain, teamName); + sprintCreationMailer(orgDomain, teamName, createSprintName(newSprintNumber), startDate); const promises = [getSprintPromise, createSprint, updateTeamCurrentSprint]; return Promise.all(promises); }).catch((error) => {