Commit Graph

5776 Commits

Author SHA1 Message Date
Rishabh Garg
f3119cbf77
Handled default value in post for specific tier content visibility (#14121)
refs https://github.com/TryGhost/Team/issues/1071

Default visibility for a post when set to specific tiers needs special handling as data for specific tiers is stored as an array of tiers on a pivot table. This change handles the default visibility for a new post when set to specific tiers to generate the right default values in model.
2022-02-04 21:00:08 +05:30
Rishabh Garg
744e5e57a0
Fixed missing portal product data (#14115)
closes  https://github.com/TryGhost/Team/issues/1311

For some sites, the `portal_products` array was created without any value and due to a possible bug in older version of Ghost, it also didn't get filled on Stripe connect with default product. This causes a side-effect of sites not showing the prices in Portal when tiers beta is enabled or is out as GA. This change populates the missing product data in `portal_product` for sites that have a single tier (haven't enabled tiers beta), as they right now don't have an option to hide the tier.
2022-02-04 19:57:38 +05:30
Rishabh
c99ee980af Added migration to transform default tiers visibility from nql string
refs https://github.com/TryGhost/Team/issues/1071

Default content visiblity for specific tiers is now stored split between `default_content_visiblity` and `default_content_visibility_tiers` setting, with former storing the value as `tiers` and the latter stores the list of tiers that the visibility is restricted to. This migration transforms all existing sites that have default visibility stored as an NQL string from previous versions to follow the new model and store correctly on the new setting.
2022-02-04 19:56:11 +05:30
Rishabh
6f89ccf901 Added default_content_visibility_tiers setting for default tiers visibility
refs https://github.com/TryGhost/Team/issues/1071

Default content visibility for a post can be one of `public|members|paid|tiers`, where `tiers` denotes visibility restricted to specific tiers. This change adds a new setting to store the tier ids when default content visibility is set to `tiers`. This closely matches how the visibility is stored on `posts` table as well, with `visibility` stored as `tiers` and tiers data is stored on tiers pivot table.
2022-02-04 19:56:11 +05:30
Fabien 'egg' O'Carroll
d60d24e744
Migrated email filter columns from VARCHAR to TEXT (#14091)
refs https://github.com/TryGhost/Team/issues/1287

Currently we have a hard limit of how large an email filter can be,
which is very restrictive once a site starts using Tiers - by moving
toward a TEXT column, we essentially give the filters unlimited size.

This currently doesn't handle SQLite as there are no limits on VARCHARS
in SQLite.

The down migration is a loop so we don't have to handle values larger than
50 characters
2022-02-04 16:09:35 +02:00
Daniel Lockyer
a1166d575f
Updated migration logging string for correctness
no issue

- we check the presence of `members_free_signup_redirect` here but the
  log line said `members_paid_signup_redirect`
- this must have been missed in review but it's simple enough to fix
2022-02-04 12:54:11 +01:00
Sam Lord
92c3e8d7ca Added source to the verification trigger
no issue

Helps us to tell the difference between a verification trigger caused by import vs API
2022-02-03 16:20:37 +00:00
Daniel Lockyer
fd69899b9f
Merged v4.34.2 into main
v4.34.2
2022-02-01 16:08:47 +00:00
Sam Lord
c7e0cc0bf2
Fixed the TPL variable name used for verification trigger
no issue

- not nice but it get the job done for now
2022-02-01 15:20:20 +00:00
Daniel Lockyer
805bb0b87a
Fixed variable scoping issue with email verification
no issue

- `this` isn't referring to the correct `this` in this scope, and the
  library is an import of the file anyway, so this fixes the undefined
  function call as a result
2022-02-01 13:54:13 +00:00
Sam Lord
c3eb3cd567 Fix imports triggering verification when below threshold
no issue

Swapped the variable names for importSize and importThreshold
2022-02-01 12:07:37 +00:00
Sam Lord
77f2acaf65 Fix usage of "ghostMailer" in email verification trigger
no issue

Introduced bug when refactoring the verification trigger by referencing an undefined member.
2022-02-01 12:07:32 +00:00
Sam Lord
c9ac6deb9b Fix imports triggering verification when below threshold
no issue

Swapped the variable names for importSize and importThreshold
2022-02-01 12:04:39 +00:00
Sam Lord
6d38a66662 Fix usage of "ghostMailer" in email verification trigger
no issue

Introduced bug when refactoring the verification trigger by referencing an undefined member.
2022-02-01 12:00:01 +00:00
Nicholas Scalf
da799997c2
Added alt tag for logo image on emails (#13953)
fixes: https://github.com/TryGhost/Ghost/issues/12871

- This Ghost recommended email scanner, mail-tester.com, reports not having this alt as having an impact of -0.5 out of 10 on your email score.
2022-02-01 11:29:17 +00:00
Fabien 'egg' O'Carroll
155ee6055d
Migrated redirect settings to welcome_page_urls (#14083)
refs https://github.com/TryGhost/Team/issues/1168

This migrates the existing settings onto the Tier objects, so that users
with Tiers enabled can seamless move from global settings to Tier level
settings - without losing/modifying data/functionality.
2022-02-01 11:00:13 +02:00
Rishabh
b259bb2431 Updated content gating to use new tiers visibility
refs https://github.com/TryGhost/Team/issues/1071

- `tiers` are now attached as a list on post with restricted tiers access
2022-02-01 11:13:51 +05:30
Rishabh
d461525978 Updated validation for post/page
refs https://github.com/TryGhost/Team/issues/1071

- ignores `tiers` as its a valid visibility filter
2022-02-01 11:13:51 +05:30
Rishabh
bc5c00ba05 Updated post model to attach products relation
refs https://github.com/TryGhost/Team/issues/1071

- attaches products relation for post/pages to include tiers with access when applicable
2022-02-01 11:13:51 +05:30
Rishabh
7ab4c44475 Updated serialization for handling tiers visibility
refs https://github.com/TryGhost/Team/issues/1071

Going forward, if the visibility of a page/post is set for specific tiers, we send a `tiers` array in API response that contains list of tiers with access. This change -

- updates post/page mapper to transform existing data where `visibility` is a custom nql string to tiers array
- updates default include for post/pages to include `products`, which allows attaching relevant tiers from the pivot table
- cleans up usage of `visibility_filter` in serialization
2022-02-01 11:13:51 +05:30
Rishabh Garg
eeafc8603b
Added pivot table to store tiers on post (#14038)
refs https://github.com/TryGhost/Team/issues/1071

We used `posts.visibility` originally to store visibility as `free|paid` with a character limit of 50. This same field was repurposed to store an NQL filter when member tiers is enabled. The NQL filter uses the slug of the tier name, which can easily create a filter longer than 50 characters, adding an unwanted limitation on number of tiers that can be added to post's visibility.
Going forward, we'd like to store the visibility of posts for tiers in a separate pivot table and instead store the value of `visibility` as `tiers` when restricting post access to specific tiers. This change -

- adds a new pivot table fixture for storing relation between posts and tiers
- adds a migration for creating the new table
- updates tests
2022-01-31 15:33:58 +05:30
Fabien "egg" O'Carroll
3d9e4b4c6c Synced Tiers welcome_page_urls with Settings
refs https://github.com/TryGhost/Team/issues/1168

Because Tiers is still behind a flag - any users which are not using
Tiers will still be editing their settings, and when they switch to
Tiers - the redirects will not necessarily be correct, unless we keep
the Tier columns up to date with any settings changes.
2022-01-30 17:41:57 +02:00
Fabien "egg" O'Carroll
0e866aaa1e Updated redirect logic to handle tier based urls
refs https://github.com/TryGhost/Team/issues/1168

This makes the actual switch to use a Tiers redirect URL rather than the
settings when the Tiers feature is enabled.
2022-01-30 17:41:57 +02:00
Fabien "egg" O'Carroll
4f5257859d Added welcome_page_url to Products API
refs https://github.com/TryGhost/Team/issues/1168

This updates the JSON API Schema to allow for the welcome_page_url
property, as well as including the new column in API responses, so that
we can both read and write the value via the API.
2022-01-30 17:41:57 +02:00
Sam Lord
08829a6f0c
Trigger email verification workflow on API usage
refs: TryGhost/Toolbox#166

The new VerificationTrigger listens to events form the members repository, and will cause the verification workflow to be triggered if the number of events is greater than the configured threshold in a rolling 30 day window.

The importer also no longer depends on the import threshold, so the threshold testing is now done in the processImport method in Ghost - seems sensible since we already had this wrapper and the logic is now tiny, since it's just relying on @tryghost/verification-trigger to handle the real stuff.
2022-01-27 14:06:29 +00:00
Peter Zimon
5713dfe7f7
Updated support email address redirect (#14075)
refs. a488b93465

- Updates redirect to member settings page after changing the support email address
2022-01-27 12:43:01 +01:00
Fabien 'egg' O'Carroll
8393c1e90a
Added welcome_page_url column to products table
refs https://github.com/TryGhost/Team/issues/1168

Rather than using a single url for paid signup redirects, we want to
support setting a welcome page on a tier by tier basis. This column will
be used to store the URL. A text column of length 2000 is how we have
stored URL's elsewhere in the schema.
2022-01-26 11:44:40 +02:00
Fabien "egg" O'Carroll
60777ac7fb Cleaned up Products API add & edit
refs https://github.com/TryGhost/Team/issues/1291

This is cleanup from the initial implementation.
2022-01-25 15:45:20 +02:00
Daniel Lockyer
a2c44efa6a
Merged v4.33.1 into main
v4.33.1
2022-01-24 16:03:16 +00:00
Fabien "egg" O'Carroll
91df910dbb 🐛 Fixed crashing on boot with revoked Stripe keys
no-issue

The refactor of Stripe boot logic missed catching any errors from the
migrations running or the webhooks initialising. This adds try/catches
to the services so that we can log the errors.
2022-01-24 17:50:55 +02:00
Fabien 'egg' O'Carroll
01f30eb632
Included benefits with theme product data (#14051)
refs https://github.com/TryGhost/Team/issues/1079

These were missing when benefits were added to products, and will allow
theme developers to make more useful custom subscribe pages.
2022-01-24 13:55:25 +02:00
Thibaut Patel
817e556ea6 Updated the /members/event filtering logic
refs https://github.com/TryGhost/Team/issues/1277

- Enabled the `filter` attribute on the route.
- The events are now filtered in-memory instead of in the database.
- This fixes a wrong logic where the API user would have to know the internal event structure.
2022-01-21 18:35:02 +01:00
Fabien "egg" O'Carroll
26ef4afdb9 🐛 Fixed config API not returning boolean
no-issue

The mailgunIsConfigured config should be a boolean, rather than a string/undefined/null.
2022-01-20 18:25:41 +02:00
Fabien 'egg' O'Carroll
231a7b9bf4
Added active flag to products API (#14021)
refs https://github.com/TryGhost/Team/issues/1252

This flag is used to determine whether a Tier (currently product) as
active or archived
2022-01-20 17:46:53 +02:00
Fabien "egg" O'Carroll
1d73c17d5b Fixed unparsed booleans for "boolean" type columns
no-issue

Knex.js aliases "bool" -> "boolean" - this means that you can use either
one in our schema.json file and it'll correctly create the column. Our
model plugin however would only handle columns which used the "bool"
alias. This fixes the plugin to handle both strings.
2022-01-20 17:00:16 +02:00
Fabien 'egg' O'Carroll
534ebecc19
Added active column to products table (#14016)
refs https://github.com/TryGhost/Team/issues/1252

We need a way to signal whether or not a Tier is active or archived, and
we'll be using the active flag in the same way we do for Offers.
2022-01-20 15:50:18 +02:00
Thibaut Patel
a1af064f79 Added three email delivery events to the member/event endpoint
refs https://github.com/TryGhost/Team/issues/1277

- The new events types are: `email_delivered_event`, `email_opened_event` and `email_failed_event`.
- This makes existing data accessible to the admin dashboard
2022-01-19 14:43:29 +01:00
Fabien 'egg' O'Carroll
8a81cd0a36
Removed duplicate offer redemptions (#14011)
refs https://github.com/TryGhost/Team/issues/1257

As well as fixing the code so that we do not create duplicate offer
redemptions going forward, we need to clean up the existing database.

We loop in code because the query to find and delete duplicates is complicated,
and will introduce more risk
2022-01-19 14:36:30 +02:00
Fabien 'egg' O'Carroll
a565da06b2
🐛 Fixed Offer Redemptions being over counted (#13988)
refs https://github.com/TryGhost/Team/issues/1257

Offer Redemptions were being overcounted due to the way we were updating
Stripe configuration for the Members service. We would create a new
instance of the members-api, which would have event handlers for
creating Offer Redemptions - by creating a new instance each time Stripe
config changed, we would overcount them.

Here we've pulled out Stripe related logic into the Stripe service, and
updated it internally - rather than creating a new instance. This means
that we've been able to remove all of the logic for re-instantiating the
members-api.

- Bumped members-api & stripe-service
- Removed reinstantiation of members-api
- Used stripe service to execute migrations
- Updated Stripe Service to handle webhooks & migrations
- Used webhook controller from stripe service
- Used disconnect method from stripe service
- Removed unused stripe dependency
- Removed Stripe webhook config from members-api
2022-01-18 17:56:47 +02:00
Daniel Lockyer
eb68e8d339 Added library for extracting database information
refs https://github.com/TryGhost/Toolbox/issues/175

- we're going to be making some changes in v5 wrt supported databases
- we needed a way of detecting the difference between MySQL 5 + 8,
  MariaDB etc
- I've created `@tryghost/database-info`, which is a small wrapper
  around `knex`, which returns this information
- this commit:
  - adds the library to Ghost
  - initializes the DB info library upon boot
  - updates the Admin API /config/ endpoint and UpdateCheck to return
    the new string - `mysql5`, `mysql8` etc
2022-01-18 09:31:08 +00:00
Rishabh
62777d7f26 Handled default product to use first paid product
Since we now have 2 products by default for all ghost sites, free and default paid, the usage of default product which so far was using first product needs to be updated to use the first paid product.

- updates default product usage to use first paid tier
- updates tests
2022-01-17 22:59:34 +05:30
Rishabh
345eb5828c Added tier type in API response
refs https://github.com/TryGhost/Team/issues/1037

Tiers now have a `type` column to differentiate between `free` and `paid` tiers. This change allows `type` data for a tier in Admin and Portal API output.
2022-01-17 22:59:34 +05:30
Rishabh
e54395eab5 Added new default free tier
refs https://github.com/TryGhost/Team/issues/1037

Free tier is now setup the same way as other tiers, to allow custom description/benefits. This change:

- adds a migration to add a default free tier for all sites
- adds a default fixture to insert a free tier for all new sites
2022-01-17 22:59:34 +05:30
Rishabh
761a330e16 Added new type column for tiers
refs https://github.com/TryGhost/Team/issues/1037

- adds new `type` column for tiers to differentiate between free and paid tiers
- all existing tiers are updated to be `paid` tiers
2022-01-17 22:59:34 +05:30
Fabien 'egg' O'Carroll
10c214c148
Switched AMP to be 'off' by default in all new Ghost instances (#13907)
refs https://github.com/TryGhost/Team/issues/1189

Support for AMP is slowly in decline, and makes developing new cards trickier,
since AMP no longer has an effect of SEO we're going to disable it by default
as a first step toward moving away from it.

Co-authored-by: Thibaut Patel <thibaut@ghost.org>
2022-01-14 18:55:48 +02:00
Kevin Ansfield
96ec60e393
🐛 Fixed "Create Post" action error in Zapier when assigning new tags (#13972)
closes https://github.com/TryGhost/Zapier/issues/56

- fixes tag creation when creating posts with `tags: [{slug: 'new'}]` which should be supported
  - assigning tags with only `{slug: 'new'}` was triggering our validation for the required `name` property then bubbling up to the `bookshelf-relations` library resulting in a 500 error
  - the fix applied here is to set the `name` field to the same as the `slug` field if a name is not provided
2022-01-14 13:37:20 +00:00
Fabien "egg" O'Carroll
5d8f491823 Updated caching policy for /members/api/site
refs https://github.com/TryGhost/Team/issues/1240

As this endpoint is hit on every page load when Portal is enabled, it
can cause a lot of traffic to Ghost. The data does not change very
frequently so we've added a 30s cache policy to alleviate load on servers.
2022-01-14 14:04:23 +02:00
Fabien "egg" O'Carroll
76b33b6e77 Added JSDoc to cache control middleware
no-issue
2022-01-14 14:04:23 +02:00
Fabien 'egg' O'Carroll
68127cf4d4
Stopped reconfiguring MemberAPI on settings change (#13943)
refs https://github.com/TryGhost/Team/issues/1257
refs https://github.com/TryGhost/Team/issues/1261

Certain event listens are being added twice due to the way we "reload"
the MembersAPI which can cause duplicate counts of Offer Redemptions.

Rather than creating multiple instances of the MembersAPI we're moving
toward being able to reload the config in place or passing getters for
the config which will allows us to use the MembersAPI as a singleton,
and remove any bugs which come from creating multiple instances.

This also fixes a bug with the allowSelfSignup config not refreshing when
the portal_plans setting was changed.
2022-01-10 18:21:09 +02:00
Kevin Ansfield
9b210f9add Fixed linter error
refs https://github.com/TryGhost/Team/issues/1258

- all uses of `labs` service in canary routes have been removed but the require had been left in place
2022-01-04 15:26:17 +00:00