diff --git a/core/server/services/members/middleware.js b/core/server/services/members/middleware.js index a81996fbb7..d07013a1e9 100644 --- a/core/server/services/members/middleware.js +++ b/core/server/services/members/middleware.js @@ -75,7 +75,7 @@ const getMemberNewsletters = async function (req, res) { return res.end('Email address not found.'); } - const data = _.pick(memberData.toJSON(), 'uuid', 'email', 'name', 'newsletters', 'status'); + const data = _.pick(memberData.toJSON(), 'uuid', 'email', 'name', 'newsletters', 'enable_comment_notifications', 'status'); return res.json(data); } catch (err) { res.writeHead(400); @@ -91,7 +91,7 @@ const updateMemberNewsletters = async function (req, res) { return res.end('Invalid member uuid'); } - const data = _.pick(req.body, 'newsletters'); + const data = _.pick(req.body, 'newsletters', 'enable_comment_notifications'); const memberData = await membersService.api.members.get({ uuid: memberUuid }); @@ -106,7 +106,7 @@ const updateMemberNewsletters = async function (req, res) { }; const updatedMember = await membersService.api.members.update(data, options); - const updatedMemberData = _.pick(updatedMember.toJSON(), ['uuid', 'email', 'name', 'newsletters', 'status']); + const updatedMemberData = _.pick(updatedMember.toJSON(), ['uuid', 'email', 'name', 'newsletters', 'enable_comment_notifications', 'status']); res.json(updatedMemberData); } catch (err) { res.writeHead(400); @@ -116,7 +116,7 @@ const updateMemberNewsletters = async function (req, res) { const updateMemberData = async function (req, res) { try { - const data = _.pick(req.body, 'name', 'subscribed', 'newsletters'); + const data = _.pick(req.body, 'name', 'subscribed', 'newsletters', 'enable_comment_notifications'); const member = await membersService.ssr.getMemberDataFromSession(req, res); if (member) { const options = { diff --git a/core/server/services/members/utils.js b/core/server/services/members/utils.js index 77bd9dd6b2..f93b353562 100644 --- a/core/server/services/members/utils.js +++ b/core/server/services/members/utils.js @@ -16,7 +16,8 @@ module.exports.formattedMemberResponse = function formattedMemberResponse(member avatar_image: member.avatar_image, subscribed: !!member.subscribed, subscriptions: member.subscriptions || [], - paid: member.status !== 'free' + paid: member.status !== 'free', + enable_comment_notifications: member.enable_comment_notifications }; if (member.newsletters) { data.newsletters = formatNewsletterResponse(member.newsletters); diff --git a/package.json b/package.json index 214e6440c9..dc3c480b2f 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@tryghost/logging": "2.2.3", "@tryghost/magic-link": "1.0.26", "@tryghost/member-events": "0.4.6", - "@tryghost/members-api": "8.1.3", + "@tryghost/members-api": "8.2.0", "@tryghost/members-events-service": "0.4.3", "@tryghost/members-importer": "0.5.16", "@tryghost/members-offers": "0.11.6", diff --git a/test/unit/server/services/members/utils.test.js b/test/unit/server/services/members/utils.test.js index be3cf472b6..3322b29015 100644 --- a/test/unit/server/services/members/utils.test.js +++ b/test/unit/server/services/members/utils.test.js @@ -22,7 +22,8 @@ describe('Members Service - utils', function () { avatar_image: 'https://gravatar.com/avatar/7d8efd2c2a781111599a8cae293cf704?s=250&d=blank', subscribed: true, status: 'free', - extra: 'property' + extra: 'property', + enable_comment_notifications: true }); should(member1).deepEqual({ uuid: 'uuid-1', @@ -32,7 +33,8 @@ describe('Members Service - utils', function () { avatar_image: 'https://gravatar.com/avatar/7d8efd2c2a781111599a8cae293cf704?s=250&d=blank', subscribed: true, subscriptions: [], - paid: false + paid: false, + enable_comment_notifications: true }); }); @@ -52,7 +54,8 @@ describe('Members Service - utils', function () { sender_name: 'Jamie', sender_email: 'jamie@example.com', sort_order: 0 - }] + }], + enable_comment_notifications: false }); should(member1).deepEqual({ uuid: 'uuid-1', @@ -68,7 +71,8 @@ describe('Members Service - utils', function () { name: 'Daily brief', description: 'One email daily', sort_order: 0 - }] + }], + enable_comment_notifications: false }); }); }); diff --git a/yarn.lock b/yarn.lock index 511a50071f..f9143a565b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1909,10 +1909,10 @@ "@tryghost/domain-events" "^0.1.14" "@tryghost/member-events" "^0.4.6" -"@tryghost/members-api@8.1.3": - version "8.1.3" - resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-8.1.3.tgz#8ddcf3d12e31639969a9678b3eb87fb6e49a7c5c" - integrity sha512-XJLXfwSd4EGbk5D9XJ0qOIF/9QBroT51/MN89Vtufw8MLHMx5OxlbIWfCXezrZHADg9GHWyao0xej3MQjGJqAA== +"@tryghost/members-api@8.2.0": + version "8.2.0" + resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-8.2.0.tgz#11e043a716e740f42c6590be44072ff4d3ef884a" + integrity sha512-MCLgN/ixaQDIhmNbXpofoTF9pBgbbLAUcNsoM/WBIPJkzAO7yYL/Np5xtvg4nVrH+/6SrAzYe/IH8wB0mc5QVA== dependencies: "@nexes/nql" "^0.6.0" "@tryghost/debug" "^0.1.2"