CoderDojo / community-platform

Zen, the CoderDojo Community Platform!
https://zen.coderdojo.com
MIT License
121 stars 55 forks source link

New event form not sending emails #1269

Closed conoramurphy-zz closed 5 years ago

conoramurphy-zz commented 5 years ago

What was expected When creating an event with the new form. Emails should be sent when the option is ticked.

What's happening The emails are not being sent. When using the old form it's still sending emails.

Testing Created a dojo on prod for testing. https://zen.coderdojo.com/dojos/ru/petrominsk-arkhangelsk-oblast/test-do-jo

Technical investigation notes Logentries shows cp-dojos-service timing out trying to call role:cd-profiles,cmd:load_parents_for_user

https://logentries.com/app/ecc739c8#/search/logs/?log_q=where(load_parents_for_user)&last=Today

This is coming from lib/dojos/users/notifyAll.js line 34 in the cp-dojos-service Which is being called from cp-zen-platform in web/lib/handlers/events.js around line 73

Have restarted the k8s pods to see if that helped but it did not. When running locally using maildev all emails are delivered correctly.

Initial thought is maybe because we are not passing a user to the service that is the issue.

Amending the sendEmail function in the event handler like so: (adding the user: req.user.user, line)

const sendDojoEmails = [
  async (req, reply, next) => {
    if (req.sendEmails) {
      return req.seneca.act(
        {
          role: 'cd-dojos',
          cmd: 'notify_all_members',
          data: {
            dojoId: req.dojoId,
            eventId: req.eventId,
            emailSubject: 'Tickets Now Available for %1$s',
          },
          user: req.user.user,
        },
        err => {
          if (err) return next(err);
          return next();
        }
      );
    }
  },
];

Still works locally, and might be worth a try.