Updated default newsletter subscription logic for members (#14482)

refs https://github.com/TryGhost/Team/issues/1469

Previously, members were subscribed to all available newsletters by default when added. This change updates the default newsletters subscription for member to take into account newsletter preferences for auto opt-in(`subscribe_on_signup`) as well as `visibility`.
This commit is contained in:
Rishabh Garg 2022-04-18 13:48:44 +05:30 committed by GitHub
parent d9ac05f97a
commit 88ed60d079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 34 deletions

View File

@ -83,7 +83,7 @@
"@tryghost/logging": "2.1.5", "@tryghost/logging": "2.1.5",
"@tryghost/magic-link": "1.0.21", "@tryghost/magic-link": "1.0.21",
"@tryghost/member-events": "0.4.1", "@tryghost/member-events": "0.4.1",
"@tryghost/members-api": "5.9.1", "@tryghost/members-api": "5.9.2",
"@tryghost/members-events-service": "0.3.3", "@tryghost/members-events-service": "0.3.3",
"@tryghost/members-importer": "0.5.8", "@tryghost/members-importer": "0.5.8",
"@tryghost/members-offers": "0.10.9", "@tryghost/members-offers": "0.10.9",

View File

@ -2103,7 +2103,7 @@ Object {
"slug": "daily-newsletter", "slug": "daily-newsletter",
"sort_order": 1, "sort_order": 1,
"status": "active", "status": "active",
"subscribe_on_signup": true, "subscribe_on_signup": false,
"title_alignment": "center", "title_alignment": "center",
"title_font_category": "serif", "title_font_category": "serif",
"visibility": "members", "visibility": "members",
@ -2125,7 +2125,7 @@ exports[`Members API: with multiple newsletters Can add and edit with custom new
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "1143", "content-length": "1144",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
@ -2172,28 +2172,6 @@ Object {
"title_font_category": "sans_serif", "title_font_category": "sans_serif",
"visibility": "members", "visibility": "members",
}, },
Object {
"body_font_category": "serif",
"description": null,
"footer_content": null,
"header_image": null,
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
"name": "Daily newsletter",
"sender_email": "jamie@example.com",
"sender_name": "Jamie",
"sender_reply_to": "newsletter",
"show_badge": true,
"show_feature_image": true,
"show_header_icon": true,
"show_header_title": true,
"slug": "daily-newsletter",
"sort_order": 1,
"status": "active",
"subscribe_on_signup": true,
"title_alignment": "center",
"title_font_category": "serif",
"visibility": "members",
},
Object { Object {
"body_font_category": "serif", "body_font_category": "serif",
"description": null, "description": null,
@ -2233,7 +2211,7 @@ exports[`Members API: with multiple newsletters Can add with default newsletters
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "2123", "content-length": "1626",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"location": StringMatching /https\\?:\\\\/\\\\/\\.\\*\\?\\\\/members\\\\/\\[a-f0-9\\]\\{24\\}\\\\//, "location": StringMatching /https\\?:\\\\/\\\\/\\.\\*\\?\\\\/members\\\\/\\[a-f0-9\\]\\{24\\}\\\\//,
@ -2481,7 +2459,7 @@ exports[`Members API: with multiple newsletters Can filter on newsletter slug 2:
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "2197", "content-length": "1700",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",

View File

@ -1375,7 +1375,7 @@ describe('Members API: with multiple newsletters', function () {
updated_at: anyISODateTime, updated_at: anyISODateTime,
subscriptions: anyArray, subscriptions: anyArray,
labels: anyArray, labels: anyArray,
newsletters: Array(3).fill({ newsletters: Array(2).fill({
id: matchers.anyObjectId id: matchers.anyObjectId
}) })
}] }]
@ -1388,7 +1388,7 @@ describe('Members API: with multiple newsletters', function () {
it('Can filter on newsletter slug', async function () { it('Can filter on newsletter slug', async function () {
await agent await agent
.get('/members/?filter=newsletters:daily-newsletter') .get('/members/?filter=newsletters:weekly-newsletter')
.expectStatus(200) .expectStatus(200)
.matchBodySnapshot({ .matchBodySnapshot({
members: new Array(1).fill(memberMatcherShallowIncludesForNewsletters) members: new Array(1).fill(memberMatcherShallowIncludesForNewsletters)

View File

@ -375,7 +375,7 @@ DataGenerator.Content = {
sender_email: 'jamie@example.com', sender_email: 'jamie@example.com',
sender_reply_to: 'newsletter', sender_reply_to: 'newsletter',
status: 'active', status: 'active',
subscribe_on_signup: true, subscribe_on_signup: false,
title_font_category: 'serif', title_font_category: 'serif',
body_font_category: 'serif', body_font_category: 'serif',
show_header_icon: true, show_header_icon: true,

View File

@ -2009,10 +2009,10 @@
"@tryghost/domain-events" "^0.1.9" "@tryghost/domain-events" "^0.1.9"
"@tryghost/member-events" "^0.4.1" "@tryghost/member-events" "^0.4.1"
"@tryghost/members-api@5.9.1": "@tryghost/members-api@5.9.2":
version "5.9.1" version "5.9.2"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-5.9.1.tgz#92d5015f1e5c8d0f1494207513a0ed1c6e5305db" resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-5.9.2.tgz#4d4d633798578f45266cfc0e51e9a8203719778d"
integrity sha512-hQOO/wxtzlnEOVSsc5dMJTkuD4w4PwOXoe/P1XouVWcUqDV2q21JCd1YVGMNEqtPNXDMkQE/wkdr7CozFgWmYw== integrity sha512-tLH0c8n2nCGJ2OazFPGg4iJuZ+pQMQ3n+iCuiQf28eQzDRZ3ly+5PHSRDLT8UDG578Ygkiz3uQz5P5WPCi/m6Q==
dependencies: dependencies:
"@nexes/nql" "^0.6.0" "@nexes/nql" "^0.6.0"
"@tryghost/debug" "^0.1.2" "@tryghost/debug" "^0.1.2"