Fixes: Collection creation notification email

Added: Unsubscribe option to notification email footers
Added: Two new notification types (emails not written yet)
Fixed: Validation added to notification setting events
This commit is contained in:
Tom Moor
2018-12-05 23:44:41 -08:00
parent cc8dacba32
commit 9ca0038d39
8 changed files with 131 additions and 17 deletions

View File

@ -133,16 +133,24 @@ User.beforeCreate(setRandomJwtSecret);
User.afterCreate(user => sendEmail('welcome', user.email));
// By default when a user signs up we subscribe them to email notifications
// when documents they created are edited by other team members.
User.afterCreate((user, options) =>
NotificationSetting.findOrCreate({
// when documents they created are edited by other team members and onboarding
User.afterCreate(async (user, options) => {
await NotificationSetting.findOrCreate({
where: {
userId: user.id,
teamId: user.teamId,
event: 'documents.update',
},
transaction: options.transaction,
})
);
});
await NotificationSetting.findOrCreate({
where: {
userId: user.id,
teamId: user.teamId,
event: 'emails.onboarding',
},
transaction: options.transaction,
});
});
export default User;