dataRequest.js 1015 B

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