Commit Graph

3106 Commits

Author SHA1 Message Date
Renovate Bot
9e5de91dc1 Update dependency @tryghost/limit-service to v0.6.5 2021-10-22 15:43:14 +02:00
Renovate Bot
742b5f7dd3 Update dependency @tryghost/package-json to v1.0.6 2021-10-22 15:41:53 +02:00
Renovate Bot
2208ae1655 Update dependency @tryghost/security to v0.2.13 2021-10-22 15:41:43 +02:00
Renovate Bot
0e4be5a390 Update dependency @tryghost/job-manager to v0.8.11 2021-10-22 15:39:15 +02:00
Renovate Bot
cceda95ba0 Update dependency @tryghost/bootstrap-socket to v0.2.13 2021-10-22 15:21:54 +02:00
Renovate Bot
7b43e30d8e Update dependency @tryghost/adapter-manager to v0.2.18 2021-10-22 15:04:47 +02:00
Renovate Bot
d842259f22 Update dependency @tryghost/errors to v0.2.17 2021-10-22 15:04:38 +02:00
Renovate Bot
da6a66c777 Update dependency @tryghost/constants to v0.1.12 2021-10-22 15:04:30 +02:00
Renovate Bot
ff09230382 Update dependency @tryghost/promise to v0.1.13 2021-10-22 15:04:10 +02:00
Renovate Bot
51d6cf3922 Update dependency @tryghost/session-service to v0.1.28 2021-10-22 15:03:59 +02:00
Renovate Bot
b57dcf9a98 Update dependency @tryghost/vhost-middleware to v1.0.19 2021-10-22 15:03:47 +02:00
Fabien O'Carroll
70f7039539 Handled empty Offer titles
no-issue

We want to allow for Offers titles to be blank/empty. This updates the
API to handle both null & empty strings for the Offer title.
2021-10-22 14:18:01 +02:00
Renovate Bot
4d56e9a7af Update dependency @tryghost/version to v0.1.7 2021-10-22 13:22:24 +02:00
Renovate Bot
8a6640d00f Update dependency @tryghost/request to v0.1.8 2021-10-22 13:08:36 +02:00
Renovate Bot
6d2de5b369 Update dependency @tryghost/debug to v0.1.9 2021-10-22 13:08:28 +02:00
Renovate Bot
2deb396291 Update dependency @tryghost/metrics to v0.2.5 2021-10-22 13:00:59 +02:00
Renovate Bot
f82f52a9e7 Update dependency @tryghost/bookshelf-plugins to v0.3.4 2021-10-22 13:00:17 +02:00
Renovate Bot
2ea8c5ee5b Update dependency @tryghost/validator to v0.1.8 2021-10-22 12:59:45 +02:00
Renovate Bot
842c850534 Update dependency @tryghost/nodemailer to v0.3.6 2021-10-22 12:27:45 +02:00
Renovate Bot
fe191a0f96 Update dependency @tryghost/root-utils to v0.3.7 2021-10-22 12:25:56 +02:00
Renovate Bot
113e01c2c4 Update dependency @tryghost/tpl to v0.1.8 2021-10-22 12:25:42 +02:00
renovate[bot]
c95ce4c685
Update dependency @tryghost/members-csv to v1.1.8 (#13642)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 12:03:56 +02:00
renovate[bot]
967f34f4e0
Update dependency @tryghost/express-dynamic-redirects to v0.2.1 (#13640)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 11:18:24 +02:00
renovate[bot]
be100d24ce
Update dependency @tryghost/magic-link to v1.0.14 (#13641)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 11:18:11 +02:00
renovate[bot]
cafbd01611
Update dependency @tryghost/members-importer to v0.3.4 (#13643)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-22 11:17:53 +02:00
Renovate Bot
a2b4ccb0ad Update dependency @tryghost/email-analytics-provider-mailgun to v1.0.4 2021-10-22 08:54:28 +02:00
Renovate Bot
1be8d30f44
Update dependency eslint-plugin-ghost to v2.7.0 2021-10-21 21:06:14 +00:00
Fabien O'Carroll
c10e76aa2c Included Offers on Member Subscriptions
refs https://github.com/TryGhost/Team/issues/1135

This adds Offer information to Subscriptions for which the Offer is
valid. This means that if a Subscription has changed its Tier/Cadence
from the what the Offers supports - it will not be attached. The data
however is still stored in the db.

This also fixes a bug with creating Stripe Checkout Sessions without an
Offer.
2021-10-21 18:12:32 +02:00
renovate[bot]
28283b54ac
Update dependency @tryghost/members-ssr to v1.0.15 (#13644)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-21 17:00:10 +02:00
Renovate Bot
39706126c0 Update dependency postcss to v8.3.11 2021-10-21 16:50:51 +02:00
Fabien 'egg' O'Carroll
21ec444139
Handled Stripe Disconnect for Offers (#13638)
refs https://github.com/TryGhost/Team/issues/1166

This updates the Members & Offers modules to correctly handle
disconnecting from Stripe, this includes:

 - Deleting Stripe data on disconnect (coupons for Offers)
 - Recreating missing Stripe Coupons after disconnect/reconnect
2021-10-21 16:25:35 +02:00
Renovate Bot
8709da36e9 Update dependency @tryghost/email-analytics-service to v1.0.3 2021-10-21 15:25:51 +02:00
Renovate Bot
8dc31438b3 Update dependency analytics-node to v5.1.2 2021-10-21 12:08:00 +02:00
Renovate Bot
87b0af1de7 Update dependency postcss to v8.3.10 2021-10-21 12:07:45 +02:00
Daniel Lockyer
32b325eb4c Added codecov.io coverage uploader to CI
refs linear.app/tryghost/issue/CORE-74/improve-the-test-situation

- this commit adds the codecov GitHub Action into CI so we can upload
  coverage reports
- the coverage files need to be in XML for them to work with
  codecov, so this commit also adds cobertura (XML) as a reporter
2021-10-20 15:12:07 +02:00
Kevin Ansfield
59a6f040d2 Fixed custom theme settings being clobbered with duplicate-named themes
refs https://github.com/TryGhost/Team/issues/1149

Ghost allows different themes to have the same `name` value in `package.json` but gives them a custom name based on the zip file used to upload it. The custom theme settings service however was always using the package.json name meaning that when syncing a theme with a duplicate name it was overwriting the settings for all other themes.

- bumped `@tryghost/custom-theme-settings-service` which changes the `.activateTheme()` signature to accept a theme name as the first argument
- updated our calls to `.activateTheme()` to pass Ghost's known theme name as the first argument so we're always syncing with the correct `theme` field value in the `custom_theme_settings` table
2021-10-20 13:25:02 +01:00
Thibaut Patel
c273727b5f Added api validation for custom settings
refs https://github.com/TryGhost/Team/issues/1107 https://github.com/TryGhost/Team/issues/1106

- Replicates the gscan custom theme settings validation in the admin api.
2021-10-20 13:36:41 +02:00
Renovate Bot
5524509274 Update dependency nock to v13.1.4 2021-10-20 10:22:32 +02:00
Daniel Lockyer
1fd980ee9b Set global Luxon timezone override to UTC
refs https://linear.app/tryghost/issue/CORE-113/start-off-luxon-refactor

- we're planning on switching to Luxon for our date/timezone library,
  eventually replacing `moment` and `moment-timezone`
- the first step is to set the global timezone override to UTC, which is
  done in `core/server/overrides.js`
- also adds a test to ensure we're setting the timezone correctly
- this was mostly pulled from https://moment.github.io/luxon/#/zones?id=changing-the-default-zone
2021-10-20 09:19:29 +02:00
Fabien O'Carroll
d303c40248 Fixed editing Offer description via API
no-issue

We were only updating the Offer description if it was truthy - rather
than if it existing, this resulting in empty strings or null not working
correctly.
2021-10-19 11:11:02 +02:00
Thibaut Patel
2891898f94 Added a rule to forbid the custom theme setting image type to have a default
refs https://github.com/TryGhost/Team/issues/1108

- The default is something that the theme developpers should be coding in the template rather than using a default value
2021-10-19 09:41:35 +02:00
Fabien O'Carroll
c5856d04e4 Added support for redemption_count to Offers API
refs https://github.com/TryGhost/Team/issues/1132

This adds redemption_count to the Offers API so that we can display how
many times an Offer has been used. This also adds the storage mechanism
for Offer Redemptions - which ensure that everytime a Checkout Session
is completed - we will create the Offer Redemption in the database.

This means that manual usage of the underlying will not count toward the
Offer redemption count, this is considered an edge case.
2021-10-18 17:40:05 +02:00
Daniel Lockyer
f9f0fb34f2
Merged v4.19.1 into main
v4.19.1
2021-10-18 15:10:22 +02:00
Daniel Lockyer
5c5233afc0 v4.19.1 2021-10-18 14:09:17 +01:00
Fabien O'Carroll
67b517e1fb 🐛 Fixed handling of "incomplete" subscriptions
refs https://github.com/TryGhost/Team/issues/1156

When a payment fails but Stripe Checkout succeeds, a subscription is
created in the "incomplete" status. This would result in a Member not
being linked to the Product. When the subscription was later updated to
"active" or trialing - the Product would still not be added!

This updates the members-api to always link the Product to the Member
for active subscriptions - regardless of if they're new or not.
2021-10-18 14:39:28 +02:00
Renovate Bot
5d60b564af
Fixed double logging library initialization
- we have the `@tryghost/logging` library to manage logging across all
  our code
- this package is intended to be a singleton, otherwise we have multiple
  versions of logging loaded
- we sometimes have problems where dependencies also use
  `@tryghost/logging` but Ghost's yarn.lock is not regenerated to update
  this
- this means we have multiple versions of `@tryghost/logging` running
- this commit updates the dependency @tryghost/update-check-service to
  v0.2.4 to clean up the yarn.lock of multiple versions
2021-10-18 14:28:26 +02:00
Renovate Bot
c768133357 Update dependency jwks-rsa to v2.0.5 2021-10-18 08:29:43 +02:00
Daniel Lockyer
f4fb0fcbaa Improved Ghost boot time and memory usage by lazy loading routes
no issue

- right now, we mount all API endpoints (v2, v3 and canary), alongside some
  other routes, when Ghost is booting. This is wasteful because we don't
  necessarily need any of the endpoints to get Ghost up and running
- even when Admin is used, it uses `canary` so `v2` and `v3` sit in memory
- the better approach here is to lazy load these endpoints, so they only
  get mounted when needed
- this commit adds the `lazyUse` function into our Express lib,
  which takes a mount path and a module function to execute down the
  line. This gets passed to the wonderful `express-lazy-router` lib which
  detects when we're calling an unmounted module and will mount it for
  us
- from local testing, this speeds up boot time by about 18% and reduces
  initial memory usage by about 6% 🚀
2021-10-15 17:52:07 +02:00
Daniel Lockyer
cea17cfb31 v4.19.0 2021-10-15 16:23:19 +01:00
Renovate Bot
d44666fe11
Update dependency mocha to v9.1.3 2021-10-15 12:26:03 +00:00
Thibaut Patel
3d57ac4464 Moved the match helper to GA in gscan. Updated the custom theme select gscan rule to work with the updated match behavior.
refs 50134193be
refs c3b346bb1a
2021-10-14 18:45:00 +02:00
Renovate Bot
565ced555c Update dependency @tryghost/custom-theme-settings-service to v0.1.2 2021-10-14 17:11:58 +02:00
Renovate Bot
c8082c9c43 Update dependency @tryghost/metrics to v0.2.4 2021-10-14 17:11:27 +02:00
Thibaut Patel
2748ed6d0a Fixed a gscan check to force custom theme setting of type color to always have a default value
ref e6a477b3b5
2021-10-14 14:51:44 +02:00
Renovate Bot
107f519310 Update dependency @tryghost/request to v0.1.7 2021-10-14 14:41:34 +02:00
Renovate Bot
aa67e2d463 Pin dependency gscan to 4.7.0 2021-10-14 14:17:57 +02:00
Fabien O'Carroll
d3e291eea6 Fixed Offer usage with Stripe Checkout
no-issue

An update in the MembersAPI meant that coupons were not correctly being
passed to Stripe Checkout. This bump contains the fix to ensure they
are.
2021-10-14 12:09:58 +02:00
Thibaut Patel
a9be1d41c3 Added two gscan rules to validate defaults for custom theme settings of type boolean and color
ref f67fbdf2b4
2021-10-14 11:55:32 +02:00
Renovate Bot
78d322b935 Update dependency @tryghost/bookshelf-plugins to v0.3.3 2021-10-14 11:11:13 +02:00
Renovate Bot
edc12ea128 Update dependency @tryghost/version to v0.1.6 2021-10-14 11:11:01 +02:00
Renovate Bot
cfdd379ddd Update dependency @tryghost/metrics to v0.2.3 2021-10-14 10:04:49 +02:00
Renovate Bot
5438b32155 Update dependency @tryghost/debug to v0.1.8 2021-10-14 10:04:38 +02:00
Renovate Bot
7c4963b579 Update dependency @tryghost/tpl to v0.1.7 2021-10-14 10:04:08 +02:00
Renovate Bot
60adebd815 Update dependency @tryghost/validator to v0.1.7 2021-10-14 10:03:57 +02:00
Renovate Bot
3f9278943c Update dependency @tryghost/root-utils to v0.3.6 2021-10-14 10:03:34 +02:00
Renovate Bot
a3d202fee1 Update dependency @tryghost/logging to v0.2.2 2021-10-14 10:03:26 +02:00
Renovate Bot
2a58e72d10 Update dependency @tryghost/nodemailer to v0.3.5 2021-10-14 10:03:12 +02:00
Renovate Bot
7499641843
Update dependency sanitize-html to v2.5.2 2021-10-13 19:23:34 +00:00
Thibaut Patel
dc4694d8d3 Added a gscan check to prevent the declaration of unused custom theme setting
ref 136e02adfd
ref https://github.com/TryGhost/Team/issues/1105

- Custom theme settings are defined in package.json, this rule triggers an error if a defined rule doesn't appear in any handlebars templates.
2021-10-13 18:30:58 +02:00
Daniel Lockyer
64f2aa2af5
Updated @tryghost/metrics dependency
no issue

- this adds in some missing dependencies of `@tryghost/metrics`
2021-10-13 14:48:05 +02:00
Fabien O'Carroll
7722780539 Restricted archived Offers from being used for Checkout
refs https://github.com/TryGhost/Team/issues/1133

This updates the MembersAPI Checkout Session handling to 403 if an
attempt is made to create a Checkout Session using an archived Offer.
2021-10-13 11:23:05 +02:00
Fabien O'Carroll
a441825c3f Passed MembersAPI the OffersAPI over OfferRepository
no-issue

The MembersAPI using the OfferRepository coupled it to the internals of
the Offers Module - instead we pass the "external" API - so that we can
change the internals, and not have to update the MembersAPI's usage.
2021-10-13 11:17:32 +02:00
Naz
dbdf7160bf Simplified DynamicRedirectManager's constructor
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- This simplification allows to make the test for dependent services a lot more readable without a need to stub urlUtils
2021-10-13 10:04:55 +02:00
Fabien O'Carroll
b1914758b8 Added support for filter Offers by status
refs https://github.com/TryGhost/Team/issues/1131

This will allow Ghost Admin to display separate lists of active and
archived Offers! We must pass the options through so that the
OffersService is able to handle the filter passed in the request.
2021-10-12 18:39:25 +02:00
Thibaut Patel
836b5b4a0e Added a gscan check to make sure the match helper on custom settings of type select is used against specified options
refs 056928f7b9
refs https://github.com/TryGhost/Team/issues/1105
2021-10-12 18:35:02 +02:00
Fabien O'Carroll
dc3dad4524 Added initial support for Offer status
refs https://github.com/TryGhost/Team/issues/1131

This updates the Offers Service to include the `status` of an Offer,
which will be either 'active' or 'archived'. It also allows setting the
`status` of an Offer to one of these two values when adding & editing
Offers.
2021-10-12 17:15:26 +02:00
Sam Lord
a535cfdf16 Added metric-shipping to monitor boot-time
no issue
Boot-time metrics are really valuable for understanding how releases affect the performance of Ghost. The new @tryghost/metrics package lets us ship these metrics to different sources using the same configuration framework as @tryghost/logging introduced.
2021-10-12 15:01:50 +01:00
Thibaut Patel
f8b19f286a Added gscan checks for custom themes settings
refs https://github.com/TryGhost/Team/issues/1105

- checks package.json for the config.custom object shape
- checks for unknown custom theme settings
2021-10-12 14:52:50 +02:00
Renovate Bot
c5459db52e
Update dependency keypair to v1.0.4 2021-10-11 21:11:01 +00:00
Naz
421c71d4db Added debug output to the email analytics jobs
closes https://linear.app/tryghost/issue/CORE-91/add-email-analytics-job-unstalling-mechanism

- Additional debug stagements should give better visibility into what's going on with the internal services fetching email events.
- To see all email analytics related outputs use following DEBUG value:

DEBUG=@tryghost/email-analytics-provider-mailgun:email-analytics*
2021-10-11 19:11:23 +02:00
Renovate Bot
6dcad04dcc Update dependency @lodder/grunt-postcss to v3.1.0 2021-10-11 14:31:54 +02:00
Renovate Bot
361184fc1c
Update metascraper to v5.24.9 2021-10-11 09:05:09 +00:00
Kevin Ansfield
c33b596e9c
Added API tests for custom theme settings (#13519)
refs https://github.com/TryGhost/Team/issues/1104

- bumped `@tryghost/custom-theme-settings-service` so it throws a more appropriate `ValidationError` when setting keys don't exist or a select value is not known
- changed the custom theme settings service to have a `.init()` method which creates an instance of the service under `.api` so that we're able to create the instance at a particular point in the boot process when we know the models have been initialised
  - there were problems in tests because the service was being initialised through the require chain before models were initialised through the boot process
- fixed incorrect `camelCase` of resource name in API responses
2021-10-08 16:18:49 +01:00
Daniel Lockyer
7ad6dec0e0 v4.18.0 2021-10-08 16:00:26 +01:00
Daniel Lockyer
a6833077a7 Optimized database integrity check
refs 838fe54628

- see referenced commit for majority of context but in short,
  knex-migrator was doing a DB query per migration folder
- in Ghost, we currently have 79 folders, which results in 79
  queries during boot... owch
- the bump to knex-migrator in this commit uses a smarter method of
  grouping together the DB entries in 1 query, resulting in a drop of 79
  queries -> 1 query
2021-10-08 15:06:46 +01:00
Fabien O'Carroll
d9bcd4ec82 Fixed Stripe Checkout for Offers with monthly Cadence
no-issue

We were incorrectly checking the Offer Cadence and sending Members to
the yearly checkout.
2021-10-08 15:22:51 +02:00
Fabien O'Carroll
955621fa21 Removed requirement for Offer description field
refs https://github.com/TryGhost/Team/issues/1083

This field is not required but was previously causing API errors when
missing, the bump to members-offers removes this requirement.
2021-10-08 12:44:14 +02:00
Fabien O'Carroll
999cff35cf Supported repeating Offers for monthly Cadence
refs https://github.com/TryGhost/Team/issues/1083

Offers with a "repeating" duration will repeat for a number of months.
These offers are restricted to the monthly Cadence. This updates the
members-offers module to add support for them.
2021-10-08 12:15:11 +02:00
Fabien O'Carroll
817b2a3b0b Fixed Offers not sending back currency
refs https://github.com/TryGhost/Team/issues/1083

Offers should send back their currency when they are for a fixed amount
- this was missing that.
2021-10-08 11:43:40 +02:00
Renovate Bot
ff62a07142 Update dependency passport to v0.5.0 2021-10-08 10:32:41 +01:00
Renovate Bot
d9e426df0e Update dependency c8 to v7.10.0 2021-10-08 10:29:55 +01:00
renovate[bot]
47ffefe93e
Update dependency @tryghost/custom-theme-settings-service to v0.1.0 (#13512)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-07 23:07:20 +01:00
Fabien O'Carroll
15466b33ee Fixed durations for coupons created for Offers
refs https://github.com/TryGhost/Team/issues/1083

Previously we were not forwarding the Offer duration to Stripe.
2021-10-07 19:03:05 +02:00
renovate[bot]
ab9fc8e848
Supported fixed-amount & forever Offers
refs https://github.com/TryGhost/Team/issues/1083

The @tryghost/members-offers package has been updated to add support for 
more Offer durations and types

Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-07 18:57:54 +02:00
Renovate Bot
7555020a49 Pin dependency @tryghost/express-dynamic-redirects to 0.1.0 2021-10-07 16:52:23 +01:00
renovate[bot]
f8dd0b3d56
Ensured Offer codes are slugified
refs https://github.com/TryGhost/Team/issues/1083

As Offer codes are used in redirects we must ensure they're URL safe
2021-10-07 16:10:46 +02:00
Naz
10a24393d0 🐛 Fixed alert notifications being sent out to non-active users
refs https://linear.app/tryghost/issue/CORE-63/restrict-update-service-notifications-to-active-admins

- It only makes sense to notify active users about a notification of 'alert' or any other type really.
2021-10-06 22:34:25 +02:00
Renovate Bot
f3efd9834a
Update dependency @sentry/node to v6.13.3 2021-10-06 17:34:22 +00:00
Fabien O'Carroll
6220406716 Added support for Offers with Stripe Checkout
refs https://github.com/TryGhost/Team/issues/1090

This updates the Members & Offers modules to provide support for using
Offers in Stripe Checkout.

Members module now needs a handle to the Offers module repository, and
as such we have had to reorder the services boot order.
2021-10-06 17:24:39 +02:00
Hannah Wolfe
726db1c0ec
Added integration test config & moved db-driven tests
- some tests are necessarily driven from the db
- these are like unit tests, except they only make sense if using the db - else you have to stub too much to make them worthwhile
- for these rare but important cases, we have the clear concept of integration tests
2021-10-06 13:51:24 +01:00