Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(email-templates): 'created email templates for sprint automation' #998

Open
wants to merge 4 commits into
base: dev-sprint-automation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion functions/model/mailer/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -141,4 +210,5 @@ exports.demoRequestMailer = function(mailType, userName, userEmail, userContact,
const message = data;
sendMail("admin@worktez.com", message[0], message[1]);
});
};
};

18 changes: 18 additions & 0 deletions functions/model/mailer/tark/generateTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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);
Expand Down
Loading