diff --git a/server/api/controllers/user.js b/server/api/controllers/user.js
index 3252331..cc10594 100644
--- a/server/api/controllers/user.js
+++ b/server/api/controllers/user.js
@@ -590,7 +590,7 @@ export const deleteUser = async ({ user: { role }, params: { id } }, res) => {
}
};
-export const unsubscribeMail = async ({ user: { id } }, res) => {
+export const unsubscribeMail = async ({ params: { id } }, res) => {
try {
await User.update(
{ notifications: false },
diff --git a/server/api/helpers/mailer/templates/articleGotNewComment.js b/server/api/helpers/mailer/templates/articleGotNewComment.js
index 5d6ecfc..34808a0 100644
--- a/server/api/helpers/mailer/templates/articleGotNewComment.js
+++ b/server/api/helpers/mailer/templates/articleGotNewComment.js
@@ -1,5 +1,5 @@
export default ({
- firstname, id, title, commenter, commentBody
+ firstname, id, title, commenter, commentBody, userId
}) => `
@@ -101,12 +101,12 @@ export default ({
|
- ©
+ | ©
Author's
Haven
|
- Courtesy
- of Really Good Emails
+ Unsubscribe
+ from all future emails.
|
diff --git a/server/api/helpers/mailer/templates/newArticleTemplate.js b/server/api/helpers/mailer/templates/newArticleTemplate.js
index 052c5c8..5014c5c 100644
--- a/server/api/helpers/mailer/templates/newArticleTemplate.js
+++ b/server/api/helpers/mailer/templates/newArticleTemplate.js
@@ -1,5 +1,5 @@
export default ({
- firstname, author, id, title
+ firstname, author, id, title, userId
}) => `
@@ -100,12 +100,12 @@ export default ({
|
- ©
+ | ©
Author's
Haven
|
- Courtesy
- of Really Good Emails
+ Unsubscribe
+ from all future emails.
|
diff --git a/server/api/helpers/notification/bookmarkers.js b/server/api/helpers/notification/bookmarkers.js
index 785a33d..50dcc02 100644
--- a/server/api/helpers/notification/bookmarkers.js
+++ b/server/api/helpers/notification/bookmarkers.js
@@ -15,9 +15,8 @@ export default async (articleId, commentBody, commenterId) => {
const info = {
commenter, commentBody, articleId, title
};
-
- bookmarks.forEach(async ({ userId }) => {
- const { firstname, email } = await User.findByPk(userId);
- articleGotNewComment({ ...info, firstname }, email);
+ bookmarks.forEach(async ({ userId: id }) => {
+ const { firstname, email, id: userId } = await User.findByPk(id);
+ articleGotNewComment({ ...info, firstname, userId }, email);
});
};
diff --git a/server/api/helpers/notification/followers.js b/server/api/helpers/notification/followers.js
index ef63eb1..bf449c2 100644
--- a/server/api/helpers/notification/followers.js
+++ b/server/api/helpers/notification/followers.js
@@ -4,11 +4,13 @@ import { newArticleMail } from '../mailer/mailer';
export default async (authorId, id, title) => {
const authorObj = await User.findByPk(authorId);
const followers = await authorObj.getFollowers({
- attributes: ['email', 'firstname', 'notifications']
+ attributes: ['email', 'firstname', 'id', 'notifications']
});
const info = { author: `${authorObj.firstname}`, id, title };
- followers.forEach(async ({ firstname, email, notifications }) => {
- if (notifications) await newArticleMail({ ...info, firstname }, email);
+ followers.forEach(async ({
+ firstname, id: userId, email, notifications
+ }) => {
+ if (notifications) await newArticleMail({ ...info, firstname, userId }, email);
});
};
diff --git a/server/api/routes/user.js b/server/api/routes/user.js
index daf19d0..03ac8ca 100644
--- a/server/api/routes/user.js
+++ b/server/api/routes/user.js
@@ -40,6 +40,6 @@ userRouter.get('/:userId/profile', getUserProfile);
userRouter.patch('/:userId/profile', passport.authenticate('jwt', { session: false }),
profileUpdateValidation, updateUserProfile);
-userRouter.patch('/:id/unsubscribe', passport.authenticate('jwt', { session: false }), unsubscribeMail);
+userRouter.patch('/:id/unsubscribe', unsubscribeMail);
export default userRouter;