dataRequest.js 1002 B

12345678910111213141516171819202122232425262728293031323334
  1. import config from "config";
  2. import mail from "../index";
  3. /**
  4. * Sends an email to all admins that a user has submitted a data request
  5. *
  6. * @param {string} to - an array of email addresses of admins
  7. * @param {string} userId - the id of the user the data request is for
  8. * @param {string} type - the type of data request e.g. remove
  9. * @param {Function} cb - gets called when an error occurred or when the operation was successful
  10. */
  11. export default (to, userId, type, cb) => {
  12. const data = {
  13. from: "Musare <noreply@musare.com>",
  14. to,
  15. subject: `Data Request - ${type}`,
  16. html: `
  17. Hello,
  18. <br>
  19. <br>
  20. User ${userId} has requested to ${type} the data for their account on Musare.
  21. <br>
  22. <br>
  23. This request can be viewed and resolved in the <a href="${config.get(
  24. "domain"
  25. )}/admin/users">Users tab of the admin page</a>. Note: All admins will be sent the same message.
  26. `
  27. };
  28. mail.runJob("SEND_MAIL", { data })
  29. .then(() => cb())
  30. .catch(err => cb(err));
  31. };