fix: User afterCreate hook using deprecated column

This commit is contained in:
Tom Moor
2021-04-03 18:37:06 -07:00
parent 3ffa21b07f
commit 4777176d84

View File

@ -238,13 +238,7 @@ User.beforeSave(uploadAvatar);
User.beforeCreate(setRandomJwtSecret);
User.afterCreate(async (user) => {
const team = await Team.findByPk(user.teamId);
// From Slack support:
// If you wish to contact users at an email address obtained through Slack,
// you need them to opt-in through a clear and separate process.
if (user.service && user.service !== "slack") {
sendEmail("welcome", user.email, { teamUrl: team.url });
}
});
// By default when a user signs up we subscribe them to email notifications
@ -267,6 +261,14 @@ User.afterCreate(async (user, options) => {
},
transaction: options.transaction,
}),
NotificationSetting.findOrCreate({
where: {
userId: user.id,
teamId: user.teamId,
event: "emails.features",
},
transaction: options.transaction,
}),
]);
});