Commit Graph

1086 Commits

Author SHA1 Message Date
Fabien O'Carroll
a072d19385 Published new versions
- @tryghost/members-api@1.32.0
2021-09-07 18:26:36 +02:00
Fabien O'Carroll
67d2104190 Deleted webhooks when disconnecting from Stripe
refs https://github.com/TryGhost/Team/issues/1006

When disconnecting from Stripe, we currently do not remove the webhooks,
this will result in the webhooks from Stripe failing, and tending toward
a 100% error rate, which will ultimately result in emails from Stripe
about the failing webhook.

In order to stop all of that from happening, we should make sure that we
actively remove the webhook from Stripe when disconnecting.
2021-09-07 18:02:35 +02:00
Fabien O'Carroll
2d394b3a2e Published new versions
- @tryghost/members-api@1.31.0
2021-09-07 16:51:25 +02:00
Fabien O'Carroll
8476e7cbd7 Added disconnectStripe method to handle cleaning up
refs https://github.com/TryGhost/Team/issues/1006

As part of the work to handle cleaning up webhooks when we disconnect
from Stripe, I'm moving the logic to clear out the Stripe related data
from the database into a disconnectStripe method. This then allows us to
start handling the cleanup of webhooks via the Stripe API.
2021-09-07 16:34:08 +02:00
Fabien O'Carroll
ae1f905766 Published new versions
- @tryghost/members-api@1.29.3
2021-09-06 13:10:42 +02:00
Fabien O'Carroll
b6e4eae272 Fixed comped members having a status of 'paid'
refs https://github.com/TryGhost/Team/issues/995

Since we reintroduced the comped status, we did not update the
subscription handling to correctly set members to a status of comped
when they were on a 'Complimentary' plan.
2021-09-06 13:06:30 +02:00
Fabien O'Carroll
dbae9f3233 Published new versions
- @tryghost/members-api@1.29.2
2021-09-06 12:50:25 +02:00
Fabien O'Carroll
66143dbb7c Updated options parameter to be optional
no-issue

Since updating the product repository to force transactions, the options
parameter was used in every call, meaning it wasn't optional any more,
which broke usage. This updates the parameter to have a default so that
existing usage still works.
2021-09-06 12:47:19 +02:00
Fabien O'Carroll
537c9cb02d Published new versions
- @tryghost/magic-link@1.0.11
 - @tryghost/members-api@1.29.1
 - @tryghost/members-csv@1.1.6
 - @tryghost/members-importer@0.3.2
 - @tryghost/members-ssr@1.0.12
2021-09-01 19:12:44 +02:00
Fabien O'Carroll
3b94ba7dce Fixed update method not using transaction for reads
no-issue

Since we run our product repository methods in transactions now we must
ensure that all database interations in the method use the transaction.
This adds the missing options to the reading of existing prices so that
they happen inside of the transaction.
2021-09-01 19:10:12 +02:00
Renovate Bot
b0133b3c2e Update dependency mocha to v9.1.1 2021-08-31 07:43:26 +00:00
Fabien O'Carroll
c782b3d2c9 Published new versions
- @tryghost/members-api@1.29.0
2021-08-26 20:07:08 +02:00
Fabien O'Carroll
82506e1599 Passed transaction to all model methods
refs https://github.com/TryGhost/Team/issues/982

These calls to the edit method were missing the transaction option from
the parent which meant that they ran outside of the transaction and
would cause the method to timeout.
2021-08-26 20:04:06 +02:00
Fabien O'Carroll
dd4d6aeae5 Wrapped product repo methods in transactions
refs https://github.com/TryGhost/Team/issues/982

This ensures that we will not commit any rows to the database if
something is to go wrong with a Stripe API request.
2021-08-26 20:03:16 +02:00
Fabien O'Carroll
dc79f04989 Published new versions
- @tryghost/members-api@1.28.0
2021-08-26 16:16:00 +02:00
Fabien O'Carroll
ec8dbf2890 Added products as default relation when fetching members
no-issue

As subscriptions are a default relation, and we now require products to
populate subscriptions for comped members, we need to include products
by default when reading members.
2021-08-26 16:10:13 +02:00
Fabien O'Carroll
0f4e97eae7 Updated getMemberIdentityData to use BREAD Service
refs https://github.com/TryGhost/Team/issues/986

The getMemberIdentityData is a relic of time past. Originally it was
used before we had anything like the member repository or bread
controller as a way for things inside of the Members ecosystem to get
access to member data.

This updates it to use the same interface as everything else for
fetching members so that we can rely on the shape of the data that we
consider a member.

This update will ensure that themes have access to the dummy
subscriptions created by the `read` method of the MemberBREADService.
2021-08-26 16:07:06 +02:00
Fabien O'Carroll
fa73786c92 Published new versions
- @tryghost/members-api@1.27.3
2021-08-26 15:54:13 +02:00
Fabien O'Carroll
d3b1283241 Removed old product when subscription is updated
refs https://github.com/TryGhost/Team/issues/979

This correctly handles updates to subscriptions so that if the product a
subscription is for has changed, we will remove the previous product, if
and only if there is not another subscription which gives access to it.
2021-08-26 15:53:38 +02:00
Fabien O'Carroll
16d67203cf Published new versions
- @tryghost/members-api@1.27.2
2021-08-26 13:03:41 +02:00
Fabien O'Carroll
83d4b5f834 Handled missing data in read method bread service
refs https://github.com/TryGhost/Team/issues/873

The `get` method of the member repository will return null when no
member is found - we must ensure that we don't attempt to call toJSON!

It is also possible for a member to not have any products, in which case
we should not attempt to iterate over them, and we can return early.
2021-08-26 12:58:39 +02:00
Fabien O'Carroll
58c06bce2e Published new versions
- @tryghost/members-api@1.27.1
2021-08-26 11:54:51 +02:00
Fabien O'Carroll
3a91687b08 Used current time for created_at for missing events
refs https://github.com/TryGhost/Team/issues/873

This is an unexpected state, but possible if the alpha version of tier
has been enabled previous to the events being added.
2021-08-26 11:52:53 +02:00
Fabien O'Carroll
40699893ba Published new versions
- @tryghost/members-api@1.27.0
2021-08-25 23:27:47 +02:00
Fabien O'Carroll
86f5879432 Added dummy subscriptions for comped members
refs https://github.com/TryGhost/Team/issues/873

This adds a dummy subscription for each product that a member has
without an associated stripe subscription. It allows clients to deal
with things like a created date for comped members.
2021-08-25 21:26:04 +02:00
Fabien O'Carroll
c17442cf4b Added memberService to members-api
no-issue

The idea of this service is to sit infront of the repository and handle
application logic which does not belong at the data layer. The exact
naming and structure is TBC but this gives us a place to start pulling
logic out of the controllers, without having to mash it all into the
repository.

Also important to note is that is does not return instances of bookshelf
models, but a JSON representation of the model, this allows us to not
leak internal implementation to consumers.
2021-08-25 21:25:19 +02:00
Fabien O'Carroll
a2120fc2d6 Published new versions
- @tryghost/members-api@1.26.0
2021-08-24 15:12:48 +02:00
Fabien O'Carroll
d55e828b34 Wired up MemberProductEvents to MemberRepository
refs https://github.com/TryGhost/Team/issues/873

This handles the creation of product events when a members access to
products is changed. This can happen on creation, update, and any
changes to stripe subscriptions.

We manually workout the difference between the current products and the
new products, and add the events accordingly.
2021-08-24 14:57:04 +02:00
Fabien O'Carroll
df753df87a Published new versions
- @tryghost/magic-link@1.0.10
 - @tryghost/members-api@1.25.2
 - @tryghost/members-csv@1.1.5
 - @tryghost/members-importer@0.3.1
 - @tryghost/members-ssr@1.0.11
2021-08-23 14:49:21 +02:00
Fabien O'Carroll
4b219626eb Fixed usage of bson-objectid
no-issue

Calling ObjectId doesn't return a string a but an ObjectId object.
Whilst this object is cast to a string via the toJSON and toString
methods, this is not enough for MySQL. Instead we should explicitly cast
this to a string ourselves and the application level.
2021-08-23 14:46:53 +02:00
Renovate Bot
2b15530e82 Update dependency mocha to v9.1.0 2021-08-23 02:56:38 +00:00
Naz
fe25f02d86 Published new versions
- @tryghost/magic-link@1.0.9
 - @tryghost/members-api@1.25.1
 - @tryghost/members-csv@1.1.4
 - @tryghost/members-importer@0.3.0
 - @tryghost/members-ssr@1.0.10
2021-08-20 17:31:40 +04:00
Naz
9cbe5efdf5 Removed checkEmailList flag check
refs https://github.com/TryGhost/Team/issues/906

- The feature is entering GA stage and the flag is no longer needed
2021-08-20 17:28:06 +04:00
Daniel Lockyer
6e4437c7e4 Added c8 test coverage
refs https://github.com/TryGhost/Team/issues/870

- using `c8` allows us to see test coverage for all packages in the repo
- this commit adds `c8` as a dev dependency and prepends the `mocha`
  command with `c8` so it runs on all tests
2021-08-20 10:28:07 +02:00
Naz
7ea1e28763 Published new versions
- @tryghost/members-importer@0.2.0
2021-08-18 16:11:05 +04:00
Naz
fd7f515055 Changed MembersCSVImporter constructor
refs https://github.com/TryGhost/Team/issues/958

- The import threshold has to become a dynamic number based on external parameters. Because of this it makes most sense to have it as an async function parameter
- There's a package API change for importThreshold constructor paramter becoming a fetchThreshold async funciton parameter
2021-08-18 16:09:33 +04:00
Fabien O'Carroll
df8136804d Published new versions
- @tryghost/members-api@1.25.0
2021-08-16 20:06:49 +02:00
Fabien 'egg' O'Carroll
4a8ec62317 Added bulkEdit method to MemberRepository
refs https://github.com/TryGhost/Team/issues/946

This adds the bulk edit method which handles bulk edit operations to members
to be used by the filtering feature. They have been combined into a single method
as that is how they are exposed to the API. This is definitely a candidate for a
refactor in the form of a service in front of the repository.
2021-08-16 19:05:48 +01:00
Fabien O'Carroll
be55c4e184 Published new versions
- @tryghost/members-api@1.24.1
2021-08-13 13:26:47 +02:00
Fabien O'Carroll
6540fd0cd0 Updated bulkDestroy method to handle model updates
refs https://github.com/TryGhost/Ghost/commit/1dd52075

- Fixes bulkDestroy being passed the context
- Fixes passing options.search to the model layer
- Updates return value since the changes in referenced commit
2021-08-13 13:23:01 +02:00
Fabien O'Carroll
7ee0df2ce6 Published new versions
- @tryghost/members-api@1.24.0
2021-08-12 13:58:53 +02:00
Fabien O'Carroll
6bb3407725 Added bulkDestroy method to Member Repository
no-issue

The logic for bulk destroy is currently incorrectly inside of the
members api controller in Ghost core. Moving it out to here allows us to
simplify the controller to rely on the service, rather than implement
the logic.
2021-08-12 13:57:45 +02:00
Fabien O'Carroll
daa3bb405d Published new versions
- @tryghost/members-api@1.23.3
2021-08-11 13:00:39 +02:00
Fabien O'Carroll
f4b7dfd08c Fixed status when subscriptions are canceled
refs https://github.com/TryGhost/Team/issues/959

Because we were using the pre-existing products to determine a members
status, instead of the products _after_ we have handled the updates to
subscriptions, members with a paid subscription which was later canceled
were changed to 'comped' rather than 'free'. This adds a final check to
set a member to 'free' if their new set of products is empty.
2021-08-11 11:59:32 +01:00
Naz
8fbd24626d Published new versions
- @tryghost/magic-link@1.0.8
 - @tryghost/members-api@1.23.2
 - @tryghost/members-csv@1.1.3
 - @tryghost/members-importer@0.1.2
 - @tryghost/members-ssr@1.0.9
2021-07-28 19:14:58 +04:00
Naz
96b3629280 Exposed originalImportSize from members importer
refs https://github.com/TryGhost/Team/issues/912

- The variable is needed as a datapoint in Ghost when sending stats about what the import size was used
2021-07-28 19:13:48 +04:00
Renovate Bot
e4109e38f3 Update dependency sinon to v11.1.2 2021-07-28 13:54:56 +00:00
Renovate Bot
102568a72a Update dependency mocha to v9.0.3 2021-07-27 04:36:33 +00:00
Naz
a4677deb29 Published new versions
- @tryghost/members-importer@0.1.1
2021-07-23 20:30:50 +04:00
Naz
a90d996f33 Added import threshold check to importer
refs https://github.com/TryGhost/Team/issues/912

- We need a way to check if the import threshold has been reached within the members importer. See more deets in refed issue
2021-07-23 20:29:19 +04:00