Commit Graph

15963 Commits

Author SHA1 Message Date
renovate[bot]
dec282345f
Update dependency @tryghost/members-importer to v0.5.8 (#14421)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-14 14:57:44 +01:00
renovate[bot]
11c495276d
Update dependency @tryghost/members-api to v5.9.1 (#14425)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-14 14:38:26 +01:00
renovate[bot]
fe5afb6196
Update dependency @tryghost/verification-trigger to v0.2.0 (#14477)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-04-14 14:37:41 +01:00
Rishabh Garg
5218cf194d
Updated newsletter sender name column as nullable (#14476)
refs TryGhost/Team#1513

- nullable `sender_name` allows us to use auto fallback of site title for sender name without setting any explicit value for it.
2022-04-14 17:42:20 +05:30
Renovate Bot
cc26c9aa9f Update dependency knex to v1.0.7 2022-04-14 12:55:04 +01:00
Naz
4dcb229b35 Removed models dependency from Webhook Service test
no issue

- There's no need to init whole models module in this test. Simplified mocks are easier to understand without any "magic" that's going on behind model's module "init()" call
2022-04-14 16:12:05 +08:00
Naz
0139c9c3ad Fixed failing test
refs fa82722b03
2022-04-14 15:33:24 +08:00
Naz
fa82722b03 Uppercased Content-Version header use
refs https://github.com/TryGhost/Toolbox/issues/227

- The convention across the codebase is to define headers with capitalized first letters. This change does not affect the output though as all headers are served lowercased anyway.
- Might be a good idea to make all headers lowercased one day to match the casing with the outputs
2022-04-14 15:21:35 +08:00
Thibaut Patel
bfbece948e Fixed the previous commit issue
refs 7a55e1a60a
2022-04-13 16:51:10 +02:00
Rishabh
00e5e87d4b Added newsletter preference selection to Portal signup flows
refs https://github.com/TryGhost/Team/issues/1490

- adds intermediary newsletter pref selection page to signup flows in case a site has multiple newsletters
  - for members signing up as free via magic link
  - for members signing up as paid via stripe checkout
  - for members signing up as paid via offer url
2022-04-13 20:06:27 +05:30
Rishabh Garg
c6da6afc9e
Handled members newsletter preference on signup (#14473)
refs https://github.com/TryGhost/Team/issues/1490

With multiple newsletters, members can choose their newsletter subscription preference in Portal while signing up. This change handles newsletter preference data for both free and paid members via magic link/stripe checkout and saves it for the newly created member.
2022-04-13 20:02:45 +05:30
Thibaut Patel
7a55e1a60a
Added the newsletter_id query string to the post edit API route (#14449)
refs https://github.com/TryGhost/Team/issues/1502

- Support the `newsletter_id` only when sending a newsletter
- Default to the default newsletter when `newsletter_id` isn't specified
- Ignore the `newsletter_id` parameter when passed in the post body
2022-04-13 15:27:43 +02:00
Simon Backx
cb1f0802d4
Added migration that fills the mrr column in members_stripe_customers_subscriptions (#14465)
refs https://github.com/TryGhost/Team/issues/1456

- Sets the MRR of active subscriptions
- Mirrors the behaviour of the getMRR method from MembersRepository in `members-api`
2022-04-13 14:07:34 +02:00
Renovate Bot
03045ca0f7 Update dependency semver to v7.3.7 2022-04-13 11:13:27 +01:00
Thibaut Patel
ffc57301f6
Fixed the newsletters api permissions (#14458)
refs https://github.com/TryGhost/Team/issues/1504

- The permissions were missing in the fixture file
- This caused some Ghost installs to not have the right permissions
- This is fixed by adding the missing permissions to the fixture file and creating a migration to resolve the missing permissions
2022-04-13 12:02:06 +02:00
Naz
4c2bcba5f0 Added example test case for a 404 vs 406
closes https://github.com/TryGhost/Toolbox/issues/291

- When a legit Resource 404 is returned by the API we want to make sure it's not shadowed by a 406. That would be confusing, eh?
2022-04-13 12:53:49 +08:00
Rishabh
9f7bb5b65b Updated snapshot members test
refs e6f96d4711
2022-04-12 21:07:47 +05:30
Renovate Bot
c1bc19c409 Update dependency grunt to v1.5.2 2022-04-12 16:34:43 +01:00
Rishabh Garg
e6f96d4711
Added filtering for members api on newsletter subscriptions (#14460)
refs https://github.com/TryGhost/Team/issues/1484

While sending a post to a specific newsletter, we'll need to get list/count of members eligible to receive the post. This change enables members admin API to filter list of members on specific newsletter by their slug.
2022-04-12 21:01:49 +05:30
Rishabh Garg
95670eed52
Handled default newsletter fixtures setup (#14459)
closes https://github.com/TryGhost/Team/issues/1491

With multiple newsletters feature, a site should always have at-least one newsletter by default. Also, as with the default product, the default newsletter also needs to be renamed to the site title during the setup flow.

- adds default newsletter to main and test fixtures
- updates setup flow to rename newsletter name and sender name to site title
- updates model to extend default value for fields
- updates test
2022-04-12 19:44:21 +05:30
Renovate Bot
89ea9de5a5
Update dependency knex to v1.0.6 2022-04-12 11:23:34 +00:00
Fabien 'egg' O'Carroll
baf9c1b61b
Updated MRR events & stored current subscription MRR
refs https://github.com/TryGhost/Team/issues/1456
refs https://github.com/TryGhost/Team/issues/1454
refs https://github.com/TryGhost/Team/issues/1302
refs https://github.com/TryGhost/Team/issues/1453

This includes changes to store MRR on subscriptions, as well as to store
events for both cancellation and expiration of subscriptions. Cancellation
events will cause a change in MRR when the `dashboardV5` flag is enabled.

Co-authored-by: Simon Backx <simon@ghost.org>
2022-04-12 12:22:26 +01:00
Naz
3381dae1e6 Added missing snapshots
refs eee8f364de

- Part of the snapshot file was not commited with a referenced commit
- Also while at it, had another look at naming used and have cleared up couple places
2022-04-12 17:03:23 +08:00
Simon Backx
2db746e559
Added mrr column to subscriptions (#14448)
refs https://github.com/TryGhost/Team/issues/1457

We want to save the MRR with a subscription to simplify the calculation of the total MRR once, in 5.0, we also take 'forever' offers into account into the MRR (so we can just SUM the MRR of all subscriptions).

- Sets the MRR to 0 for now.
- Separate commit will fill in all the values in a data migration, but this needs to get merged first because we need this new column in order to update the members-api package (so we already save the MRR before doing the data migration).
- Updated `test/e2e-api/admin/legacy-members.test.js` with improved body assertions.
2022-04-12 11:02:18 +02:00
Renovate Bot
c89a1b7d58
Update metascraper to v5.29.3 2022-04-11 20:47:04 +00:00
Renovate Bot
f1de0405e6 Update dependency grunt to v1.5.1 2022-04-11 18:33:44 +01:00
Fabien 'egg' O'Carroll
cf6eef60e3
Added migration to populate cancellation events (#14438)
refs https://github.com/TryGhost/Team/issues/1302

We do not want to update MRR calculations until 5.0 - so will be adding
a separate migration to populate the mrr_delta column for 5.0

We've only added events for non-expired subscriptions as this is simpler
and won't impact the mrr events when mrr_delta is updated
2022-04-11 15:18:12 +01:00
Daniel Lockyer
184dc861cb
Merged v4.43.1 into main
v4.43.1
2022-04-11 12:21:16 +01:00
Daniel Lockyer
c082a9c333 v4.43.1 2022-04-11 12:16:38 +01:00
Daniel Lockyer
10248f71e6 Updated Admin to v4.43.1 2022-04-11 12:16:38 +01:00
Naz
a9030536c0
🐛 Fixed false positive fatal error for {{tiers}}
closes https://github.com/TryGhost/Ghost/issues/14452

- When {{tiers}} helper was used with parameters in a Ghost theme, for example statement like this:  `{{tiers prefix="Access with:"}}`, the theme did not pass the gscan check and threw a false positive fatal error. {{tiers}} is fully valid and documented helper that should work in current version of Ghost
2022-04-11 11:54:17 +01:00
Fabien 'egg' O'Carroll
ee9190b912
Populated type column of existing events (#14437)
refs https://github.com/TryGhost/Team/issues/1302

Currently we only have three event types: created, updated & expired.

A created event always has a `from_plan` of null

An updated event will always have a different `to_plan` and `from_plan`
as the subscription has changed tier/cadence.

An expired event _should_ have a `to_plan` of null, but due to a bug we
have events with the same `from_plan` and `to_plan`.
2022-04-11 11:41:44 +01:00
Rishabh Garg
cb76b738ce
Fixed newsletter schema column validation (#14456)
refs https://github.com/TryGhost/Team/issues/1500

- newsletter schema columns were using incorrect syntax for `isIn` validations
- adds schema test to make sure schema `isIn` validations are in correct format
2022-04-11 15:05:02 +05:30
Naz
e5172facd6 🐛 Fixed false positive fatal error for {{tiers}}
closes https://github.com/TryGhost/Ghost/issues/14452

- When {{tiers}} helper was used with parameters in a Ghost theme, for example statement like this:  `{{tiers prefix="Access with:"}}`, the theme did not pass the gscan check and threw a false positive fatal error. {{tiers}} is fully valid and documented helper that should work in current version of Ghost
2022-04-11 17:19:47 +08:00
Renovate Bot
16437965f9 Update dependency grunt to v1.5.0 2022-04-11 06:40:53 +01:00
Renovate Bot
5e07160251 Update dependency nconf to v0.11.4 2022-04-11 06:40:21 +01:00
Renovate Bot
176a9679da
Update dependency eslint to v8.13.0 2022-04-08 23:55:41 +00:00
Renovate Bot
3a9d5392a2
Update metascraper to v5.29.1 2022-04-08 16:54:50 +00:00
Hannah Wolfe
95faf54e73
Moved route-settings tests to their own folder
- the route settings code was factored out into its own service, but the tests were not moved
- this moves them so it's clearer what tests are for what service
2022-04-08 16:53:11 +01:00
Daniel Lockyer
9b835f5823 v4.43.0 2022-04-08 16:00:32 +01:00
Daniel Lockyer
3df2158d23 Updated Admin to v4.43.0 2022-04-08 16:00:32 +01:00
Daniel Lockyer
57b6773e98 🎨 Updated Casper to v4.7.4 2022-04-08 16:00:32 +01:00
Thibaut Patel
1ba72edce6
Added the emails-newsletters relation (#14434)
refs https://github.com/TryGhost/Team/issues/1497

- This enables us to keep track of which newsletter an email was sent to even if the related post is deleted.
- Adds the `newsletter_id` property to the email API
2022-04-08 16:16:23 +02:00
Rishabh Garg
b0df387deb
Cleaned up newsletter schema migrations (#14441)
refs https://github.com/TryGhost/Team/issues/1500

The newsletter table schema has bunch of changes to go through for new and existing columns, this consolidates the schema changes into a single re-create table migration that drops and adds the newsletter table with correct schema. The table re-create migration needs to run before any of the tables using newsletter as foreign key. The changes include -

- new columns for design related fields
- new slug column for filtering
- unique constraint to `name` column
- remove `default` column (noops the existing default column migration)
- `sender_reply_to` has a default of newsletter and a validation of ['newsletter', 'support']
- updated default values for `subscribe_on_signup` and  `recipient_filter`
2022-04-08 19:06:30 +05:30
Fabien 'egg' O'Carroll
7ff0247e8d
Added subscription_id to MRR events (#14445)
* Added subscription_id to MRR events

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

As part of 5.0 we want to have cancelled evetns affect MRR. We are going
to backfill and begin populating cancelled events _before_ 5.0 however,
adding a migration to set the MRR deltas as part of 5.0

This migration will need to associate the cancelled events with a
subscription, so we are adding the subscription_id now. This will allow
us to guarantee that all cancelled events will have a subscription_id.

The column is missing a NOT NULL and REFERENCES constraint because
we have not populated the missing values. These will be added in the future
once we have populated the column for all rows
2022-04-08 14:04:40 +01:00
Daniel Lockyer
a26056d796
Updated all @tryghost packages
- these packages have only had small dependency or non-code updates so
  they can all be merged together
2022-04-08 13:48:31 +01:00
Fabien 'egg' O'Carroll
022c8c8e69
Added support for 'FOR UPDATE' lock (#14433)
refs https://github.com/TryGhost/Team/issues/1248

This is the underlying cause of the problems we've seen whilst handling
Stripe webhooks. A transaction ensures that the operations are atomic,
but not that they can run concurrently.

If you have some code which does this, concurrently:
1. Starts a transaction
2. Reads a value
3. Changes the values
4. Ends the transaction

Without applying the `FOR UPDATE` lock - you will have both sequenes
read the same value at step 2.

With the `FOR UPDATE` lock - one of the sequences will hang at step 2,
waiting for the other transaction to end, at which point it will resume
and read the _changed_ value.

Because the `edit` method explicitly does a read followed by a write, we
have also add the `FOR UPDATE` lock to this by default, to avoid any race
conditions. This does however require that `edit` is called within a
transaction. An issue here https://github.com/TryGhost/Team/issues/1503
considers running in a transaction by default.
2022-04-08 12:52:33 +01:00
Naz
eee8f364de Added test coverage for Content APIs versioning support
refs https://github.com/TryGhost/Toolbox/issues/280

- Some additional coverage showcasing the versioning support is universal across APIs
2022-04-08 17:30:10 +08:00
Naz
313ab2a13f Moved version test to shared folder
refs https://github.com/TryGhost/Toolbox/issues/280

- The Accept-Version/Content-Version header handling  is shared between all APIs and should not structurally belong to any of the admin/content/members folders
2022-04-08 17:28:46 +08:00
Naz
4959dd83b8 Added 406 errors when Accept-Version header is missmatched
refs https://github.com/TryGhost/Toolbox/issues/280

- This change covers two use cases:
  -  The accept-version > current version + the request cannot be served: ERROR CASE 1
    - The accept-version < current version + the request cannot be served: ERROR CASE 2
- Along with 406 status there's additional information about the probable cause and action to be taken by the Ghost site owner or an integration talking to the Ghost API.
- These errors is designed to allow introducing breaking API changes gradually and have meaningful information when the requests cannot be server any longer
2022-04-08 20:41:54 +12:00