Commit Graph

11383 Commits

Author SHA1 Message Date
Hannah Wolfe
b09504e7cc Moved bootstrap socket logic out of server
- this logic is a dependency rather than part of the server code
- moved it out ready to be moved elsewhere, doesn't need to be here
2020-08-07 16:27:45 +01:00
Hannah Wolfe
028d3fc88b Added missing debug info for IPC on start
refs 022a433e56

- noticed I missed adding debug info in one place (not that it's used, just for consistency)
- also made the SIGINT/TERM code slightly more readable
2020-08-06 20:39:49 +01:00
Kevin Ansfield
2efcf94645
Improved performance of sending newsletter emails (#12091)
no-issue

- switch from `membersService.api.members.list` to using bookshelf `Member.findPage()` with the `{paid: true}` filter to avoid per-member queries (N+1) to decorate members with subscriptions and a heavy post-fetch filter via `contentGating`
- add concurrency to the Mailgun API requests in `bulk-email` service to reduce overall time submitting API requests
- add debug statements with timing output for easier measurements
2020-08-06 15:19:39 +02:00
Kevin Ansfield
490f9787fa
Added migration to create indexes and constraints for member tables (#12108)
no issue

For large numbers of members we're unable to perform queries for free/paid members in a reasonable time without indexes. Bulk delete is also very slow when looping through bookshelf models and having bookshelf manage deletion of child records, adding `ON DELETE CASCADE` to the foreign key indexes moves child deletion to the DB level and allows for performant bulk delete queries.

- migrations only run on mysql because sqlite does not support altering tables
- adds foreign key indexes and constraints with 'ON DELETE CASCADE' for members_labels, members_stripe_customers, and members_stripe_customers_subscriptions
2020-08-06 14:57:05 +02:00
Fabien 'egg' O'Carroll
d3384975da
Cleaned up members_stripe_* tables on MySQL (#12103)
refs #12100

For performance reasons we want to add foreign key and unique constraints
to the members_stripe_* tables so we can utilised cascading deletes and 
joins across the tables when querying.

In order to do this we must first ensure that:
- There are no duplicate entries in the `subscription_id` or `customer_id` columns
- There are no orphaned rows in the subscription or customers tables

If the first is not true, the unique constraint will fail, and if the second is not true,
the foreign key constraint will fail.

As we are only adding the indexes to existing MySQL databases at this point, the
cleanup migrations will also only be done for existing MySQL databases too.

The migrations for removing orphaned rows splits the deletion into a `SELECT`
followed by a `WHERE IN` to avoid the database "optimising" the query into a
`JOIN` which ends up taking much longer due to the lack of indexes.
2020-08-06 11:13:41 +02:00
Fabien 'egg' O'Carroll
d15446593a
Added support for ON DELETE CASCADE to the schema (#12105)
no-issue

We are in the process of creating migrations to add foreign key constraints
and cascading deletes to the members_stripe_* tables to make listing members
and deleting members faster. As well as the migrations we need to update the
database schema so that new installations have the correct indexes and constraints.

Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
2020-08-05 13:20:30 +02:00
Renovate Bot
0eed0d8c88
Update dependency mocha to v8.1.1 2020-08-04 19:31:20 +00:00
Daniel Lockyer
0304280d96 v3.28.0 2020-08-04 11:23:41 +01:00
Daniel Lockyer
226fa76c51 Updated Ghost-Admin to v3.28.0 2020-08-04 11:23:40 +01:00
Daniel Lockyer
82f4b179fa Updated Casper to v3.1.0 2020-08-04 11:23:40 +01:00
Daniel Lockyer
9ff68dc3b0 Updated @tryghost/url-utils dependency to 0.6.19 2020-08-04 11:04:14 +01:00
Daniel Lockyer
bd14df328d Updated @tryghost/string dependency to 0.1.10 2020-08-04 11:03:34 +01:00
Renovate Bot
0e1708f220
Update dependency @tryghost/social-urls to v0.1.10 2020-08-04 07:59:42 +00:00
Renovate Bot
30fe92e3be Update dependency @tryghost/html-to-mobiledoc to v0.7.1 2020-08-04 07:58:49 +00:00
Renovate Bot
7239fdbe23
Update dependency @tryghost/helpers to v1.1.28 2020-08-04 06:01:45 +00:00
Nazar Gargol
60ae9e82f9 Fixed integration_id assignment for webhook when creating through API key auth
refs 173e3292fa

- The bug was initially introduced in referenced commit. When request is done with `api_key` context, there should always be an `integration` object associated with it - 71c17539d8/core/server/services/permissions/parse-context.js (L36) . An `id` from `context.integration` not `context.api_key` has to be assigned to newly created webhook!
- The webhooks API is about to be declared stable in upcoming release, so no migration will be done
2020-08-04 16:43:24 +12:00
CY Lim
71c17539d8
🐛 Fixed installation on windows #10890 (#12096)
closes #10890

- use platform agnostic `exit 0` to allow `yarn setup` to work on windows
- requires powershell to be run as admin
2020-08-03 20:15:58 +01:00
Gerardo Lopez Dueñas
275bf41ba3
Fixed bookmark card image size in fastmail (#11970)
closes #11907

The image in the bookmark card was being shown out of the bounds of
the card because of a general style `height: auto !important`.

I added a new `max-height` property to the image to avoid exceeding
parent height.
2020-08-03 18:38:45 +01:00
Hannah Wolfe
221f8c4a86
Update CONTRIBUTING.md
- commit messages = why
2020-08-03 16:10:22 +01:00
Rish
f770e9f2ad 🐛 Fixed incorrect member gating on custom static page routes
no issue

- Member gating on post/page content is done using member context on request's frame
- Custom static page route was incorrectly setting the member context as `members` instead of `member`, which caused logged-in members to still not able to see content while logged in as a member
- Fix corrects the member context for these routes to use `member` as expected
2020-08-03 17:28:55 +05:30
Nazar Gargol
2a4ad0e10f Updated stability index comments around Admin API v2 endpoints
refs 067d2eb614

- v2 API has been in maintenance mode since v3 has been released, updated comments accordingly
2020-08-03 23:46:23 +12:00
Nazar Gargol
067d2eb614 Moved canary/v3 webhooks API to "stable" group
no issue

- Webhooks API has been stabilized with latest changes and there are no breaking changes planned for v3. The change has strictly "informative" purpose
- Changed variable naming from "whitelisted" to "allowlisted" to follow updated naming convention (refs. https://mysqlhighavailability.com/mysql-terminology-updates/)
2020-08-03 23:40:15 +12:00
Nazar Gargol
b76a6a1eee Reduced error level to default for not found post error
refs #12064

- `critical` is meant to be something unpredictable like internal error, something worthy attention, as described in Ignition -3439456d94/README.md (list-of-errors)
- This error level was introduced with - this PR https://github.com/TryGhost/Ghost/pull/9426, but there is no context provided why this specific value was used. Assuming it's an outdated value as 'not found' is nowhere to be treated in any special way
2020-08-03 23:16:53 +12:00
Nazar Gargol
1b449f4f53 🐛 Fixed 500 error in webhooks API when modifying non-existing webhooks
closes #12064

- Handled permission check bug by returning 404, same way it is returned in other permissions related places when handling non-existing resource. Example - 60907a7ae4/core/server/models/relations/authors.js (L355-L358)
2020-08-03 23:08:47 +12:00
Renovate Bot
60907a7ae4
Update dependency eslint to v7.6.0 2020-08-03 00:06:23 +00:00
Renovate Bot
59f9b4345f
Update dependency mocha to v8.1.0 2020-07-30 20:37:56 +00:00
Kevin Ansfield
29d94e7814 Fixed mailgun config not allowing custom hosts with ports
no issue

- `mailgun()` expects the `host` option not to include a port but `url.host` will include the port, we instead want to use `url.hostname` which skips the port
2020-07-30 17:28:51 +01:00
Renovate Bot
56ceb1e312
Update dependency sanitize-html to v1.27.2 2020-07-29 15:18:07 +00:00
Kevin Ansfield
577a934f53
Removed DISTINCT from member labels association query (#12088)
no issue

- bookshelf adds `DISTINCT` to any relation query that does not have an explicit `columns` statement
- when measuring the impact of `DISTINCT` on the eager-loading association query when listing members using `{withRelated: 'labels'}`, it can be 2x slower with no index on the sort_order column or 4x slower with an index on sort_order
2020-07-29 12:50:22 +01:00
John O'Nolan
d9da01ea85
Added hiring link to readme 2020-07-29 15:24:59 +07:00
Kevin Ansfield
9f642c8107 Added moment package resolution to pin 2.24.0
refs 1a17f8069b

- sub-dependency update bumped moment versions to 2.27.0 which caused timezone problems again with dates not being written to the database in UTC
- added a resolution in package.json to pin all moment sub-dependencies to the same version we specify in our top-level dependencies
2020-07-28 17:55:23 +01:00
Nazar Gargol
ef6586bfdc Fixed failing members import with label associations
no issue

- When processing entries with new labels in parallel Bookshelf relations is trying to create them which caused unique key constraints to fail. To avoid the failure, all labels should be pre-created before proceeding with creating members
2020-07-28 22:37:48 +12:00
John O'Nolan
71e16bc6d2
Made readme install commands easier to copy/paste 2020-07-28 13:23:31 +07:00
John O'Nolan
cd2c710c9f
Updated GitHub sponsors credits 2020-07-28 13:21:55 +07:00
John O'Nolan
5ce1ea58a9
Update FUNDING.yml 2020-07-28 13:19:20 +07:00
Renovate Bot
fd64af5b78
Update dependency uuid to v8.3.0 2020-07-27 19:05:33 +00:00
Renovate Bot
f89e0d6e4b Update dependency nock to v13.0.3 2020-07-27 19:04:24 +00:00
renovate[bot]
1a17f8069b
Lock file maintenance (#11979)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-07-27 19:02:53 +01:00
Fabien O'Carroll
cd2e72542d v3.27.0 2020-07-27 18:38:26 +02:00
Fabien O'Carroll
5c9188b1e5 Updated Ghost-Admin to v3.27.0 2020-07-27 18:38:26 +02:00
Hannah Wolfe
436db4ec3b Updated host limit message to be clearer
- limits are based on total members not number of members that will be emailed
2020-07-26 20:49:30 +01:00
Hannah Wolfe
92446d85ea Changed member limit to be DRY & use raw query
- Member limit code was duplicated in 2 places unnecessarily
- Also used member api code that fetched members and subscriptions fully hyrated when we only need a count
- Using a raw query significantly improves performance here
2020-07-26 20:49:30 +01:00
Kevin Ansfield
0c5c7b32b8 Fixed members import regression tests
refs 14c6968388

- updates expected member labels length asserts to account for auto-generated import label being attached
2020-07-26 18:57:11 +01:00
Kevin Ansfield
14c6968388 Fixed auto-generated label not being attached to members during import
no issue

- label was being created and returned in the response OK but it was missing from the set of labels that get added to members during import
2020-07-26 18:30:58 +01:00
Renovate Bot
1f776e138f
Update dependency @sentry/node to v5.20.1 2020-07-24 17:47:22 +00:00
Renovate Bot
fdb04b086e
Update dependency @tryghost/members-ssr to v0.8.4 2020-07-24 14:02:00 +00:00
Fabien O'Carroll
8ac1e91d8b Bumbed @tryghost/members-api to 0.25.1
no-issue

This contains an update which ensures that we do not insert orphaned
rows into the database

Includes code from: https://github.com/TryGhost/Members/pull/190
2020-07-24 16:01:06 +02:00
Fabien O'Carroll
c46475f5be Supported optionally cancelling subscriptions on delete
no-issue

This updates the Admin API Member resource to *not* cancel subscriptions
by default, and adds a `cancel` option. This can be used over HTTP by
including a `cancel=true` query parameter.
2020-07-24 16:01:06 +02:00
Fabien O'Carroll
0ec28219f9 🐛 Fixed deleting members with deleted Stripe data
closes #11557

- Bumped @tryghost/members-api to 0.25.0
  - Fixed cancelling subscriptions which were already cancelled
  - Renamed exported subscriptions cancel fn from "destroy" -> "cancel"
2020-07-24 16:01:06 +02:00
Fabien O'Carroll
92151a7b5d Added default options to transactional model methods
no-issue

This protects against calling model methods without passing an options
object
2020-07-24 15:31:48 +02:00