dataRequest.js 1014 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. to,
  14. subject: `Data Request - ${type}`,
  15. html: `
  16. Hello,
  17. <br>
  18. <br>
  19. User ${userId} has requested to ${type} the data for their account on Musare.
  20. <br>
  21. <br>
  22. This request can be viewed and resolved in the
  23. <a href="${config.get("url.secure") ? "https" : "http"}://${config.get(
  24. "url.host"
  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. };