all repos — caroster @ 2c7296589b29fe5ac46d3e65e14931a57022a709

[Octree] Group carpool to your event https://caroster.io

backend/src/bootstrap/user-subscribe.ts (view raw)

 1import sendgrid from "../lib/sendgrid";
 2
 3export default async ({ strapi }) => {
 4  strapi.db.lifecycles.subscribe({
 5    models: ["plugin::users-permissions.user"],
 6
 7    async afterCreate({ result }) {
 8      if (result.email) {
 9        await sendgrid.subscribe(result.email);
10        strapi.log.info(
11          `New user with email address ${result.email} subscribed to mailing list`
12        );
13      }
14    },
15  });
16};