Add document unsubscribe link in email footer (#5762)

This commit is contained in:
Tom Moor
2023-09-03 19:04:28 -04:00
committed by GitHub
parent 0261e0712c
commit d7c331532d
24 changed files with 347 additions and 161 deletions

View File

@@ -33,11 +33,8 @@ const handleUnsubscribe = async (
const userId = (ctx.input.body.userId ?? ctx.input.query.userId) as string;
const token = (ctx.input.body.token ?? ctx.input.query.token) as string;
const user = await User.scope("withTeam").findByPk(userId, {
rejectOnEmpty: true,
});
const unsubscribeToken = NotificationSettingsHelper.unsubscribeToken(
user,
userId,
eventType
);
@@ -46,6 +43,10 @@ const handleUnsubscribe = async (
return;
}
const user = await User.scope("withTeam").findByPk(userId, {
rejectOnEmpty: true,
});
user.setNotificationEventType(eventType, false);
await user.save();
ctx.redirect(`${user.team.url}/settings/notifications?success`);