Files
myDrive/backend/utils/sendShareEmail.ts
T
2020-12-04 01:43:04 -05:00

30 lines
769 B
TypeScript

import env from "../enviroment/env";
import sgMail from "@sendgrid/mail";
const currentURL = env.remoteURL;
const sendShareEmail = async (file: any, respient: string) => {
if (process.env.NODE_ENV === "test") {
return;
}
const apiKey: any = env.sendgridKey;
const sendgridEmail:any = env.sendgridEmail;
sgMail.setApiKey(apiKey);
const fileLink = `${currentURL}/download-page/${file._id}/${file.metadata.link}`
const msg = {
to: respient,
from: sendgridEmail,
subject: "A File Was Shared With You Through myDrive",
text: `Please navigate to the following link to view the file ${fileLink}`
}
await sgMail.send(msg);
console.log("Share email sent");
}
export default sendShareEmail