From 044107d2a62457a0c44c3822553c74d26cef319c Mon Sep 17 00:00:00 2001 From: abhishek-mishra019 Date: Fri, 22 Sep 2023 00:26:00 +0530 Subject: [PATCH 1/4] feat(email-templates): 'created email templates for sprint automation' --- functions/model/mailer/lib.js | 72 ++- .../model/mailer/tark/generateTemplate.js | 18 + .../mailer/templates/sprintCreation.html | 465 +++++++++++++++++ .../mailer/templates/sprintReminder.html | 479 ++++++++++++++++++ .../scheduledFunctions/tark/autoSprint.js | 12 +- .../sprints/tark/updateAutoSprintStatus.js | 1 + 6 files changed, 1043 insertions(+), 4 deletions(-) create mode 100644 functions/model/mailer/templates/sprintCreation.html create mode 100644 functions/model/mailer/templates/sprintReminder.html diff --git a/functions/model/mailer/lib.js b/functions/model/mailer/lib.js index d477945a2..b148eb68d 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_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 @@ -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..7f2a4a555 --- /dev/null +++ b/functions/model/mailer/templates/sprintCreation.html @@ -0,0 +1,465 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ + + + + +
+ + + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +

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.

+

 

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

Sincerely,

+

 

+

Team Worktez.

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

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..3c6a8d582 --- /dev/null +++ b/functions/model/mailer/templates/sprintReminder.html @@ -0,0 +1,479 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ + + + + +
+ + + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +

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.

+

 

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

Sincerely,

+

 

+

Team Worktez.

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

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..212ebeaa1 100644 --- a/functions/model/sprints/tark/updateAutoSprintStatus.js +++ b/functions/model/sprints/tark/updateAutoSprintStatus.js @@ -127,6 +127,7 @@ exports.updateAutoSprintStatus = function(appKey, teamId) { result = { data: "Sprint Updated Successfully" }; console.log("Sprint final Updated Successfully"); migrateTasks(orgDomain, teamId, teamName, oldSprintNumber, newSprintNumber, orgId); + // mailer for creating new sprint. return result; }).catch((error) => { result = { data: error }; From e526804e7846ddef3ce529ba81a9813473d3f3ad Mon Sep 17 00:00:00 2001 From: abhishek-mishra019 Date: Sat, 23 Sep 2023 21:20:18 +0530 Subject: [PATCH 2/4] more changes in the templates --- .../mailer/templates/sprintCreation.html | 3 +- .../mailer/templates/sprintReminder.html | 58 +------------------ 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/functions/model/mailer/templates/sprintCreation.html b/functions/model/mailer/templates/sprintCreation.html index 7f2a4a555..f4554403e 100644 --- a/functions/model/mailer/templates/sprintCreation.html +++ b/functions/model/mailer/templates/sprintCreation.html @@ -221,7 +221,7 @@

Please review your assigned task for the current sprint.

 

- + @@ -263,6 +263,7 @@

Go to My DashBoard +

diff --git a/functions/model/mailer/templates/sprintReminder.html b/functions/model/mailer/templates/sprintReminder.html index 3c6a8d582..75f59810a 100644 --- a/functions/model/mailer/templates/sprintReminder.html +++ b/functions/model/mailer/templates/sprintReminder.html @@ -1,17 +1,3 @@ - - - @@ -273,10 +259,11 @@

- + Go to My DashBoard +

@@ -299,47 +286,6 @@

-
-
- - - -
-
- -
- - - - - - - -
- -
-

Sincerely,

-

 

-

Team Worktez.

-
- -
- - -
-
-
- - -
-
- - - - - -
From 0dbb1d6a1d6907b508f535d934f1188bedb126b2 Mon Sep 17 00:00:00 2001 From: abhishek-mishra019 Date: Sat, 23 Sep 2023 21:23:59 +0530 Subject: [PATCH 3/4] change in libJS --- functions/model/mailer/lib.js | 2 +- .../mailer/templates/sprintCreation.html | 43 +------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/functions/model/mailer/lib.js b/functions/model/mailer/lib.js index b148eb68d..f9bed5427 100644 --- a/functions/model/mailer/lib.js +++ b/functions/model/mailer/lib.js @@ -135,7 +135,7 @@ exports.sprintCreationMailer = function(orgDomain, teamName, sprintName, startDa valueArray.push(sprintName); valueArray.push(teamName); valueArray.push(startDate); - const mailType = "Sprint_Reminder"; + const mailType = "Sprint_Creation"; generateTemplate(mailType, valueArray).then((data) => { const message = data; sendMail("admin@worktez.com", message[0], message[1]); diff --git a/functions/model/mailer/templates/sprintCreation.html b/functions/model/mailer/templates/sprintCreation.html index f4554403e..96d09163f 100644 --- a/functions/model/mailer/templates/sprintCreation.html +++ b/functions/model/mailer/templates/sprintCreation.html @@ -221,7 +221,7 @@

Please review your assigned task for the current sprint.

 

- + @@ -286,47 +286,6 @@

-
-
- - - -
-
- -
- - - - - - - -
- -
-

Sincerely,

-

 

-

Team Worktez.

-
- -
- - -
-
-
- - -
-
-

- - - - -
From 7b3fb9e647e3965db811bd7947904698367feac7 Mon Sep 17 00:00:00 2001 From: abhishek-mishra019 Date: Tue, 26 Sep 2023 21:16:53 +0530 Subject: [PATCH 4/4] additional commit --- functions/model/sprints/tark/updateAutoSprintStatus.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/model/sprints/tark/updateAutoSprintStatus.js b/functions/model/sprints/tark/updateAutoSprintStatus.js index 212ebeaa1..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) => { @@ -127,7 +129,6 @@ exports.updateAutoSprintStatus = function(appKey, teamId) { result = { data: "Sprint Updated Successfully" }; console.log("Sprint final Updated Successfully"); migrateTasks(orgDomain, teamId, teamName, oldSprintNumber, newSprintNumber, orgId); - // mailer for creating new sprint. return result; }).catch((error) => { result = { data: error };