Commit Graph

5844 Commits

Author SHA1 Message Date
Naz
92986b77e3 Renamed whitelist -> allowlist
no issue

- Renames to follow the naming convention from https://mysqlhighavailability.com/mysql-terminology-updates/
2021-11-08 16:09:30 +04:00
Naz
f0242baf9f Added static file limit handling in Files API
refs https://github.com/TryGhost/Toolbox/issues/114

- Just like with media files same limits apply and can be configured through the usual limit service's config
2021-11-08 16:09:30 +04:00
Naz
a099073fde Added Files API behind an alpha flag
refs https://github.com/TryGhost/Toolbox/issues/114

- Files API is meant to be used for non-executable file uploads of all sorts
- The files are stored and retrieved for download as-is
2021-11-08 11:40:17 +04:00
Naz
151ab6968c Added local file storage adapter
refs https://github.com/TryGhost/Toolbox/issues/114

- This adapter is meant to power Files API
- The files will be stored under `/files/` in the configured content path and under `/content/files/` URL.
2021-11-08 11:29:33 +04:00
Naz
f43eeacfd0 Changed thumbnail to be an optional parameter
refs https://github.com/TryGhost/Toolbox/issues/95

- With incoming support of audio media files thumbnail would not be a required parameter
2021-11-05 17:17:18 +04:00
Naz
ad2583530a Renamed getLocalFileStoragePath
refs https://github.com/TryGhost/Toolbox/issues/95

- getLocalImagesStoragePath makes a lot more sense in context of what the method really does
2021-11-05 17:17:18 +04:00
Naz
12cad62a53 Fixed up JSDoc
no issue

- The method description was a complete tautology
2021-11-05 17:17:18 +04:00
Naz
22ac28b250 Fixed ThemeStorage inheritance
refs https://github.com/TryGhost/Toolbox/issues/95

- The ThemeStorage was never supposed to inherit image specific mehods. The LocalStorageBase is all it needs, might be even too much
- Look mum no saveRaw!
2021-11-05 17:17:18 +04:00
Naz
c802097b72 Renamed LocalFileStorage to LocalImages store
refs https://github.com/TryGhost/Toolbox/issues/95

- This naming corresponds way better to what the actual adapter does
2021-11-05 17:17:18 +04:00
Naz
f3fc1bd5d4 Extracted local storage adapters' into a base class
refs https://github.com/TryGhost/Toolbox/issues/95

- The MediaStorage adapter and LocalFileStorage were almost identical, having a common base class makes sense here.
- Having a distinct class for the "LocalFileStorage" makes it easy to spot the implementation difference from the StorageBase - the "saveRaw" method, which is not present in the StorageBase
- The LocalFileStorage will become an LocalImageStorage in next commit as that name corresponds way better to what it does!
- Test files need a good cleanup
2021-11-05 17:17:18 +04:00
Naz
142eff22ee Fixed thumbnail file name
refs https://github.com/TryGhost/Toolbox/issues/95

- The uploaded media thumbnail name should have a "_thumb" postfix to be able to distinguish thumbnails from other files. This can be handy if we decide to store them in a different location in the future.
2021-11-04 19:03:45 +04:00
Rishabh Garg
3b90b1f335
Moved launchComplete user setting as global editor setting (#13703)
refs https://github.com/TryGhost/Team/issues/807

The launch wizard completed flag was previously stored at per user level in accessibility column of user table, so an administrator still got the option to complete the launch wizard even if the owner had completed it previously, which is not expected pattern. This change moves the launch complete flag for Admin to common settings from per user level so a site only needs to complete the launch wizard once irrespective of which user completes it

- adds new `editor_is_launch_complete` setting to track if a site launch steps are completed in Admin
- adds new migration util to easily allow adding new setting 
- adds migration to introduce new `editor_is_launch_complete` setting
- adds migration to update launch complete flag for a site if any of the users have already completed the launch steps
2021-11-04 18:03:51 +05:30
Naz
df5c87fae3 🐛 Fixed a 500 error when uploading invalid routes.yaml
closes https://github.com/TryGhost/Toolbox/issues/111

- Just like with invalid JSON redirects files we should return a BadRequestError instead of throwing a generic 500 when the redirects.yaml file fails parsing
2021-11-04 11:52:52 +04:00
Naz
2dac3d489f Added "mediaAPI" labs flag
refs https://github.com/TryGhost/Toolbox/issues/95

- A flag go control the Media API alpha feature
2021-11-04 10:48:53 +04:00
Naz
091240db48 Added thumbnail upload support to Media API
refs https://github.com/TryGhost/Toolbox/issues/95

- Each media file quires a thumbnail and these changes provide a capability to upload them along with media files.
- The thumbnail file is always required and has to be the format of already supported image formats
- The thumbnail should be uploaded as a part of "thumbnail" attachment in the request
- The regression tests added with this changeset will be claened up and moved to unit-tests (this is a dirty-but-working version!)
- The thumbnail always gets a name of the uploaded media file and keeps it's own extension.
- The thumbnails is accessible under the url present in the "thumbnail_url" reponse field
2021-11-04 10:23:29 +04:00
Fabien O'Carroll
6e53527666 Fixed init method for Offers service
refs https://github.com/TryGhost/Ghost/commit/da152a0a1

The cleanup of the Offers labs flag inadvertently removed this logic.
2021-11-03 17:17:33 +02:00
Fabien 'egg' O'Carroll
da152a0a13
Removed references to Offers labs flag (#13709)
refs https://github.com/TryGhost/Team/issues/1115

This feature is now GA, and the flag has been hardcoded to `true`, here we clean up the
remaining references as they're no longer needed.
2021-11-03 17:11:48 +02:00
Sanne de Vries
6c487ca2c9 Fixed links overflowing in mobile email preview in Chrome 2021-11-03 11:12:32 +01:00
Naz
0ccf31cdb5 Fixed error message when booting with no redirects
refs 91efa4605c

- When the instance is booted without any redirects files configured it's not supposed to error but rather default to an "empty" [] redirects configuration.
- Ideally the logic shoudl not contain try/catch block at all and fail as soon as there's any error during the initialization. This wasn't changed at this time due to possible break of existing Ghost instances
2021-11-03 13:50:24 +04:00
Naz
e1d16a55e1 Fixed DynamicRedirectManager initialization
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- After a bump of the '@tryghost/express-dynamic-redirects' the constructor has changed it's signature, so this needed an adjustment
2021-11-03 07:41:55 +13:00
Naz
c3edd4b3d4 Fixed redirects regression tests
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- The problem this change is addressing is inability to override config values once the code is extracted into a class+DI pattern
- The work around is restarting the instance with the configuration testing expected behavior - in this case missing or existing types of redirects files
2021-11-03 07:41:55 +13:00
Fabien O'Carroll
91efa4605c Used DynamicRedirectManager for Custom Redirects
refs https://github.com/TryGhost/Members/commit/9e59f5a9

Since we have a DynamicRedirectManager for handling adding/removing
redirects at runtime, we no longer need the custom-redirects middleware.
The redirects service does however need an init method now to add the
custom redirects at Ghost boot, so it's been refactored into our Class &
DI pattern.
2021-11-03 07:41:55 +13:00
Naz
d657432531 Cleaned up use of 'content/media' magic string
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- `content/media` path is now a part of the constants package and should've been used instead of a magic-string.
2021-11-03 00:33:28 +13:00
Naz
d20732ce34 Imroved media validation middleware
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Error messages are now more specific when uploaded media files fail the validation check
2021-11-03 00:33:28 +13:00
Naz
02da62ee48 Added limit service check for uploaded media filesize
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Uploading large files is costly and might cause DDoS. Limits would allow fair use of the site instance.
- The configureation in hostSettings to enable an "uploads" limit would look like following:
```
"hostSettings": {
    "limits": {
            "uploads": {
                "max": 5,
                "error": "Your plan supports uploads of max size up to {{max}}MB. Please upgrade to reenable uploading."
            }
    }
}
```
- Read more at ba37890be4/packages/limit-service (usage)
2021-11-03 00:33:28 +13:00
Naz
d5b1552dc9 Simlified limit service initialization
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Init function for the limits service initialization is never called with parameters, so it doesn't make sense to keep that option around and have unnecessary logic handling it
2021-11-03 00:33:28 +13:00
Naz
f9a8edb1a0 Refactored upload middleware
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Using a wrapping object to store enableClear/multer instances didn't make any sense
2021-11-03 00:33:28 +13:00
Naz
4a551661d9 Implemented '/media/upload' API endpoint
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- This is an experimental implementation of video file upload support
- Also the output serializer skipped use of url utils in favor of inline implementatoin - this should almost certainly be it's own package
2021-11-03 00:33:28 +13:00
Naz
5242566252 Added local media storage adapter
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- This is an experimental implementation of video file upload support (audio is yet to follow)
- The storage adapter still needs more thinking as it's almost the same as the "LocalStorgeAdapter" that stores images.
- Also the output serializer skipped use of url utils in favor of inline implementatoin - this should almost certainly be it's own package
2021-11-03 00:33:28 +13:00
Fabien O'Carroll
c45afc7f26 🐛 Fixed email type when creating Members via API
refs https://github.com/TryGhost/Team/issues/1197

We were always sending the 'signin' email, rather than respecting the
email_type param passed to the API. This updates our email sending when
creating members to force the requested type if it's present.
2021-11-02 12:56:00 +02:00
Rishabh
1a9705b824 🐛 Fixed error in setting page access to tiers
closes https://github.com/TryGhost/Ghost/issues/13704
closes https://github.com/TryGhost/Team/issues/1186

- updates page serializer to handle new `visibility_filter` property for filtering access on specific tier
- this change was already added for `posts` but was missed on `pages`, so parsing filter on `visibility` filter was failing
2021-11-02 13:36:32 +05:30
Fabien 'egg' O'Carroll
b36d0cc1c4
🐛 Fixed idempotentcy of addPermissionToRole util (#13685)
refs https://github.com/TryGhost/Team/issues/1178

The "up" migration that this util generates correctly throws if the
pre-requisite data cannot be found in the database. The "down" migration
however was incorrectly mirroring this behaviour of throwing - which
meant that it wasn't idempotent, as it does not require a permission or
role to existing if it wants to move relations between them.
2021-11-01 09:27:50 +00:00
Thibaut Patel
d0933c51ad Revert "Switched AMP to be 'off' by default in all new Ghost instances"
This reverts commit 98fd48cb32.
2021-10-28 18:52:31 +02:00
Thibaut Patel
98fd48cb32 Switched AMP to be 'off' by default in all new Ghost instances
refs https://github.com/TryGhost/Team/issues/1189

- The world & internet is slowly moving away from AMP
2021-10-28 18:13:25 +02:00
Naz
d89b8448ab Added a not to the Images API ref field
refs https://github.com/TryGhost/Ghost/pull/10534

- The original PR has no explanation around the purpose of the ref field and it's easy to forget without knowing a wider context. Documented it to remember next time we come around working on this part of the codebase!
2021-10-28 16:05:54 +04:00
John O'Nolan
297e173544 Updated member signup email copy 2021-10-26 17:53:35 -04:00
Fabien O'Carroll
bccc8790f0 Fixed max-complexity-warnings for stripe_connect API
no-issue

This removes the logic to check if stripe connect is allowed into the
stripe connect service, which makes the feature easier to maintain, as
well as fixes the v3 API - which previously did not have this check.
2021-10-25 14:06:28 +02:00
Fabien O'Carroll
a68b96001c Fixed max-complexity-warnings for members API
no-issue

This removes logic from the Members API controller, and into the Members
BREAD service, this allows our controllers to be simpler and easier to
maintain, as well as keeping the important logic all together.
2021-10-25 14:06:12 +02:00
Kevin Ansfield
a485509a2f
🐛 Fixed GA labs flags not appearing enabled in settings API (#13681)
no issue

The way GA flags were introduced means that they stop existing in the `'labs'` setting in the db and are instead forced to always return `true` when checking the flag in the labs service. However, Admin which uses the flags fetches them via the `/settings/` API endpoint which was only returning the raw labs setting db value meaning GA flags appeared to be disabled unless the flag had previously been enabled and no settings save had occured.

- updated the settings bread service to replace the labs setting value with the JSON stringified output of `labs.getAll()` which is the ultimate source-of-truth for a feature being enabled/disabled
  - extracted `browse()` behaviour to an internal `_formatBrowse()` method so we can apply the same filtering/modification for output of `browse()` and `edit()`

Co-authored-by: Fabien O'Carroll <fabien@allou.is>
2021-10-22 19:59:13 +01:00
Fabien O'Carroll
f3bb6b43a5 Added Offers feature to Ghost
refs https://github.com/TryGhost/Team/issues/1115

This allows users to create Offers for Tier/Cadence pairs in order to
provide discounted subscriptions to Members! We have support for
percentage based discounts & fixed price discounts, either for the first
payment, all payments, or a number of monthly payments.

Offers also have a code, which can be used as an easy way to share them,
as visiting https://site.com/offer-code will automatically open Portal
with the Offer prepopulated.
2021-10-22 17:55:34 +02:00
Fabien O'Carroll
696d8e3c49 Added 404 handling for edit Offer
no-issue

This was also missing as part of the Offers API.
2021-10-22 16:16:39 +02:00
Kevin Ansfield
0c6cd37679 Fixed missing space between authors in emails
no issue

- author line was appearing as "Author One,Author Two,..." with no space
- fixed the generation of `post.authors` when serializing a post before it's rendered for email
2021-10-22 14:41:15 +01:00
Daniel Lockyer
e834904125
Fixed verification threshold when set to 0
no issue

- if the verification threshold is 0, `_.get(..)` becomes falsy so we
  fallback to Infinity
- this is not correct - we only want to default to Infinity if the value
  is not set
- this commit explicitly compares the config value to `undefined` and sets
  the fallback accordingly
2021-10-22 15:33:59 +02:00
Kevin Ansfield
d7fbf94d91
Fixed ETag header for admin templates not changing between versions (#13680)
refs https://github.com/TryGhost/Team/issues/1175

We found the ETag header sent when serving the Admin template for /ghost/ was not changing between versions which after an upgrade could result in out of date cached content being served containing links to JS/CSS files that no longer existed.

The culprit is weak etags served by Node's `send` package, coupled with Admin template filesize not changing between versions and `npm pack` setting a fixed modification date for every file. See https://github.com/pillarjs/send/issues/176 for more details.

- updated the Admin app's controller to read the template and generate an md5 hash of the contents so we can serve a strong ETag header value when serving the `/ghost/` html
2021-10-22 14:25:58 +01:00
Fabien O'Carroll
363eb94aee Handled 404 for Offer not found
no-issue

This was missing handling! We need to throw a NotFoundError so we
return with the correct response.
2021-10-22 14:22:33 +02:00
Fabien 'egg' O'Carroll
d962f0e18e
Removed NOT NULL constraint from portal_title (#13659)
refs https://github.com/TryGhost/Team/issues/1163

We want to make the title for Offers optional, our nullable validation
means that we cannot store an empty string, so we must remove the NOT
NULL constraint from the column if we want to store either an empty
value or null.

There is a bug with editing columns in SQLite with `knex` which strips all
the indexes, so we have to manually add them afterwards.
2021-10-22 14:14:49 +02:00
Daniel Lockyer
ed6a8dca76 Inlined package requires to save boot time and memory
no issue

- following on from f4fb0fcbaa,
  this commit moves around some package requires in Ghost
- these are often niche packages that do something in a subsystem of
  Ghost, and are not necessarily be needed to boot the application
- these packages use non-negligible CPU and memory when they are
  required, so it makes sense to lazy-require them
- the concern here is that we obscure the code too much by moving
  random requires further into code, but the changes are small and the
  improvements big
- this commit bring the boot time since 4.19.0 down ~31% and initial
  memory usage down by a total of ~12%
2021-10-22 09:57:59 +02:00
Hannah Wolfe
faea2da596
Moved server/web/site to frontend/web
- we're slowly trying to draw the lines between the backend and the frontend correctly
- these files deal only with serving the frontend so they should live there
- there are lots of mixed requires in these files, so having them in the right place makes that clear
2021-10-21 19:28:18 +01:00
Fabien O'Carroll
8c9b4d18bf Fixed error when enabling Offers via labs
no-issue

The listOffers method requires an options object. This was missed during
the update.
2021-10-21 20:05:42 +02:00
Hannah Wolfe
2777093c76
Refactored model init to be implicit
- no more need to explictly add a model file to be loaded!
- this makes building Ghost just the tiniest smidge easier
2021-10-21 17:01:26 +01:00
Hannah Wolfe
99fde5154f
Fixed dependency on the order of models
- this has been a niggle for ages, we shouldn't need to care what order our models are loaded in
- this is stopping us from having a built-in model loader and "frameworkizing" models
2021-10-21 16:57:36 +01:00
Kevin Ansfield
1708f0c3a4 Fixed custom theme settings not being available when expected
closes https://github.com/TryGhost/Team/issues/1172

Custom theme settings sync and cache population had been left to complete in the background as it wasn't essential for it to be complete for the front-end to start. However that was causing problems for the API where theme activation and custom theme settings list requests happen very close together, with the latter often not containing the theme settings data when it is expected to.

- changed `activationBridge.*` methods to `async` so they can `await` the completion of custom theme settings sync before activating a theme
2021-10-21 15:02:52 +01:00
Fabien O'Carroll
39160fc794 Passed Offer model to MembersAPI
refs https://github.com/TryGhost/Team/issues/1166

The MembersAPI needs access to the Offer model so that we can remove all
the Stripe related data when Stripe is disconnected.
2021-10-21 15:39:26 +02:00
Fabien O'Carroll
03d4561a5f Added relation between Member & OfferRedemption
refs https://github.com/TryGhost/Team/issues/1135

This will allow us to fetch the OfferRedemptions for a Member so that we
can display them on the Member details page.
2021-10-21 15:39:26 +02:00
Iuri Mendes
7debc28832
Removed "The team at X" from member emails (#13615)
closes: https://github.com/TryGhost/Ghost/issues/13613

- The language "The team at X" didn't suit all Ghost users. The language is more appropriate without it.
2021-10-21 13:58:34 +01:00
Hannah Wolfe
a1ad9f2870
Reworked init migrations to use async/await (#13635)
- use async/await and fat arrow syntax
- makes it easier to refactor later as "this" context is then reliable
2021-10-21 11:19:59 +01:00
Naz
07afb08875 Made storage calls related to images use "images" feature
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- Having this preemptive change allows to separate implementation of "image" storage from future usecases like "videos", "audios" etc. Even if the "image" adapter is not configured the default behavior will fallback to use the "active" storage adapter. If there's a need to handle "images" differently through a custom apapter that'll work out of the box ;)
2021-10-21 20:22:45 +13:00
Naz
f890d8d4cd Enabled passing through a feature name to utilize with a storage adapter
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- When the storage is requested the caller can now specify a "feature" they want to use the storage for. For example there could be different configurations for "images" or "vidoes" storages and the caller would not necessarily have to know about the details of how the feature is implemented.
2021-10-21 20:22:45 +13:00
Naz
98c27b5555 Added multiple adapters capability to adapter manager
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- There's a need to support multiple adapter variations per given adapter type (storage, sso, etc.)
- With the introduced changes we can specify a version of an adapter that should be fetched based on `:feature` postfix. For example:

`adapterManager.getAdapter('storage')` -  would return the default adapter listed under "active" configuration
`adapterManager.getAdapter('storage:videos') - would return an adapter configured for videos *feature*

- Here's an example configuration for a custom video storage:
```
"storage": {
    "active": "LocalFileStorage",
    "videos": "ghost-storage-custom-video",
    "ghost-storage-custom-video": {
        "custom": "configHere"
    }
}
```
2021-10-21 20:22:45 +13:00
Naz
e90c4217e5 Added a doc to adapter service coinfig mapper 2021-10-21 20:22:45 +13:00
Hannah Wolfe
360f7490dd
Refactored fixture utils scout style
- This is a minor refactor to reorder functions, use async/await & fat arrows
- It will make the coming bigger refactor slightly easier to read :D
- This should not make any functional changes
2021-10-20 19:54:14 +01:00
Kevin Ansfield
256f16a01f
🐛 Fixed URLs not being correctly transformed during insert operations (#13618)
closes https://github.com/TryGhost/Team/issues/1150

Our override of the base Bookshelf `insert` operation so that our own `formatOnWrite()` method is called on attributes was working on a false assumption that an `attrs` attribute is passed in as it is for the `update` operation. Instead Bookshelf's base update uses the `model.attributes` values to create an `attrs` object that is then passed through the usual `.format()` method meaning that our `insert` override was not actually doing anything.

- added a failing regression test for the `formatOnWrite()` override behaviour
- adjusted our insert/update overrides to set an internal `_isWriting` property on the model, then if that property is true our `.format()` override (which is called by Bookshelf on a generated `attrs` object during inserts) we manually call our `.formatOnWrite()` method
  - updated both overrides even though `update` was working for consistency and less cognitive overhead for reasoning between two different approaches
2021-10-20 15:22:46 +01: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
Fabien 'egg' O'Carroll
4e326123d3
Updated Offers related tables (#13609)
no-issue

* Removed NOT_NULL constraint from stripe_coupon_id

When handling disconnecting from Stripe - we remove all Stripe data from
our database to ensure we do not have bad/invalid data stored. Removing
this constraint will allow us to set the value to NULL.

* Added created_at column to offer_redemptions

Offer Redemptions are not just a joining table, but an event. A created_at
date allows them to be ordered

Because this is in alpha it is simpler to just drop the tables and
re-add them, due to offer_redemptions depending on offers, we also drop
this table and re-add it.
2021-10-20 14:22:37 +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
Naz
393280b6ae Reworked LocalFileStore methods to use async syntax
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- While digging around this area refactored the code to use more readable async/await syntax instead of chaining then's
- Dropped unneeded "catch" block in save method as all it was doing was rethrowing an error with out additional handling
2021-10-20 10:29:46 +04:00
Naz
51b78211c5 Renamed bootstrap to routerManager
refs https://linear.app/tryghost/issue/CORE-104/decouple-frontend-routing-events-from-urlserver-events

- A follow up rename after bootstrap module was transformed into class
2021-10-19 07:29:09 +13:00
Naz
6e075c78bf Moved URL service to backend
refs https://linear.app/tryghost/issue/CORE-104/decouple-frontend-routing-events-from-urlserver-events

- URL module is part of the backend heavily dependent on the model and fits perfectly here. Frontend should get the data it needs by passing a URL manager instance to it
2021-10-19 07:29:09 +13:00
Hannah Wolfe
ae33c89707
Moved public folder to frontend
- The files in the public folder are all specific to the frontend:
  - ghost.css / ghost.min.css contains styles for default templates like unsubscribe, private and error
  - favicon is the default for the frontend
  - robots.txt is the default robots.txt for the frontend
  - sitemap.xsl is the stylesheet for the sitemap
- Therefore, they should live in the frontend!
2021-10-16 19:27:34 +01:00
Hannah Wolfe
17e4d89a79
Removed unused public assets
refs: a482c547ae

- This image hasn't been used for a very long time!
2021-10-16 13:58:29 +01: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
Fabien O'Carroll
0210b329cb Passed OfferRedemption to members
refs https://github.com/TryGhost/Team/issues/1132

In order for the members module to create redemptions for members, it
needs access to the OfferRedemption model.
2021-10-15 16:56:04 +02:00
Fabien O'Carroll
a41c3cae1f Passed OfferRedemptionModel to offers
refs https://github.com/TryGhost/Team/issues/1132

In order for the offers modules to read the redemption count it needs
access to the OfferRedemption model.
2021-10-15 16:56:04 +02:00
Fabien O'Carroll
e2b243040e Added OfferRedemption model
refs https://github.com/TryGhost/Team/issues/1132

A model is needed for reading and writing Offer Redemptions to the
database.
2021-10-15 16:56:04 +02:00
Hannah Wolfe
67821a7bc7
Removed remaining usage of i18n & translation file
refs https://github.com/TryGhost/Ghost/issues/13380

- Now that i18n.t has been removed everywhere, we can cleanup the final usages
- Still TODO: merge the i18n logic into themeI18n, and get rid of shared/i18n entirely
2021-10-15 11:39:07 +01:00
Rishabh Garg
7270baa99c
Added new offers endpoint on members API
refs https://github.com/TryGhost/Team/issues/1138

Portal offer urls use offer id to load offer details UI and stripe checkout in frontend. This endpoint allows portal to fetch offer details from offer id to create Portal UI with relevant details for potential members.
2021-10-15 11:46:27 +05:30
Hannah Wolfe
b286142a6b
Removed errant console.log
refs: d7ae6e0138

- removed a debugging console log accidentally committed to main
2021-10-14 20:38:02 +01:00
Kevin Ansfield
d7ae6e0138 Added image as an allowed custom theme setting type
refs https://github.com/TryGhost/Team/issues/1107

- updated schema validation to allow `'image'` through as a known setting type now that Admin has support
- added transformation of setting values for `'image'` types because they will be URLs and should be stored with `__GHOST_URL__`
2021-10-14 18:41:54 +01:00
Kevin Ansfield
41c21f501d Added text as an allowed setting type
refs https://github.com/TryGhost/Team/issues/1107

- updated schema validation to allow `'color'` through as a known setting type now that Admin has support
2021-10-14 15:45:47 +01:00
Kevin Ansfield
adb176f5b2 Added color as an allowed setting type
refs https://github.com/TryGhost/Team/issues/1107

- updated schema validation to allow `'color'` through as a known setting type now
2021-10-14 10:37:28 +01:00
Naz
add30f3d5b Decoupled frontend routing from url service
refs https://linear.app/tryghost/issue/CORE-103/decouple-internal-frontend-code-from-url-module

- By becoming a parameter in the routing bootstrap process URL is Service no longer a "require" inside the frontend controllers but rather becomes a part of the "internal API" of the bootstrapper. This is not the end form of it, rather a step closer to decouplint routing from the URL serivce.
- The bootstrap module needs a facelift to have cleaner distinction between init/start methods. This is left for another time
2021-10-14 05:55:49 +13:00
Kevin Ansfield
7cb93be60b Added boolean as allowed custom theme setting type
refs https://github.com/TryGhost/Team/issues/1106

- updated schema validation to add `'boolean'` as an allowed `type` value
- added `format()` and `parse()` methods to `CustomThemeSetting` model to match `Settings` model behaviour for boolean-type settings
2021-10-13 17:25:32 +01:00
Fabien O'Carroll
f3dcf578a9 Prefixed migration with 01
refs https://github.com/TryGhost/Ghost/commit/b48c16c1

This was missed in the initial commit. We require numbers so that we can
easily see the order in which migrations will run.
2021-10-13 17:37:39 +02:00
Fabien O'Carroll
b93e7d7f7c Added offer_redemptions table to database
refs https://github.com/TryGhost/Team/issues/1132

This will be used to store Offer Redemptions, which will be used to list
the Offers which a Member has redeemed, as well as the number of times
an Offer has been redeemed.
2021-10-13 17:37:39 +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
Hannah Wolfe
00bcaeeb8c
Fixed duplicate message due to bad merge
- sadly git is not always detecting conflicts properly
2021-10-13 09:17:01 +01:00
PJ
4943c97ecb
Replace i18n with tpl in api/v2/utils/validators/input/users.js (#13589)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:08:57 +01:00
PJ
d362d8c8bd
Replace i18n with tpl in core/server/api/v3/invites.js (#13587)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:07:57 +01:00
PJ
09a9a9844f
Replace i18n with tpl in api/v3/pages-public.js (#13586)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:07:42 +01:00
PJ
f8033596c0
Replace i18n with tpl in api/v3/pages.js (#13585)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:06:53 +01:00
PJ
6e14047a2a
Replace i18n with tpl in core/server/api/v3/memberSigninUrls.js (#13584)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:05:38 +01: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
PJ
57ce743d98
Replace i18n with tpl in output/authentication.js (#13581)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:00:19 +01:00
Tomás Castillo
2c659ea447
Replaced i18n.t w/ tpl helper in v3/posts.js file (#13580)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:58:34 +01:00
IncredibleZuess
dd5a96d37c
Replaced i18n.t w/ tpl in api/v2/utils/validators/input/setup.js (#13579)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:54:22 +01:00
IncredibleZuess
b2e4145bd9
Replaced i18n.t w/ tpl in api/v2/utils/validators/input/settings.js (#13578)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:53:57 +01:00
IncredibleZuess
0cbc813f28
Replaced i18n.t w/ tpl in core/server/api/v2/utils/validators/input/passwordreset.js (#13577)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package
2021-10-13 08:52:39 +01:00
IncredibleZuess
e0c0022cb7
Replaced i18n.t w/ tpl in core/server/api/v2/utils/validators/input/invites.js (#13576)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:52:19 +01:00
IncredibleZuess
6d4b682b95
Replaced i18n.t w/ tpl in api/v2/utils/validators/input/images.js (#13575)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:50:15 +01:00
Levi Richardson
6421f60852
Switch i18n.t to tpl in users.js (#13574)
refs: #13380

- i18n is deprecated and is being replaced with tpl
2021-10-13 08:44:04 +01: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
ItsMeSatan
af7fe99127
Replaced i18n.t with tpl in memberSigninUrls.js and oembed.js (#13564)
refs: #13380

- i18n is deprecated and is being replaced with tpl
2021-10-12 14:47:53 +01:00
PakkuDon
0fe62e3aee
Replaced i18n.t with tpl in core/server/services/bulk-email and core/server/services/permissions (#13562)
refs: #13380

- i18n is deprecated and is being replaced with tpl
2021-10-12 14:46:35 +01:00
Fabien 'egg' O'Carroll
b48c16c118
Added active column to offers table (#13592)
refs https://github.com/TryGhost/Team/issues/1131

This will be used as a flag to determine whether or not an Offer is
archived or active.
2021-10-12 15:20:45 +02:00
Fabien O'Carroll
1bb9c3a9ac Invalidated site cache when adding & editing Offers
no-issue

Because adding and editing Offers can update the redirects for Ghost, we
should ensure that any site cache is cleared so as to not conflict with
Offer redirects.
2021-10-12 15:20:31 +02:00
Fabien O'Carroll
37deda3587 Fixed handling of labs flag for Offers
no-issue

Because we only called `init` if the labs flag is enabled, when starting
up a site without the flag enabled - the listener for adding redirects
wasn't active. So new Offers would not have their redirects setup.
2021-10-12 15:20:31 +02:00
Marco F
ed6045d82c
Replaced i18n.t() with tpl() in v2/utils/validators/input/invitations.js (#13560)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 09:12:04 +01:00
PJ
9ccf590ddc
Replaced i18n with tpl in GhostMailer.js (#13555)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 09:10:50 +01:00
Indrakant Dana
e2aeca56e9
Replaced i18n.t w/ tpl in v3/utils/serializers (#13552)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 08:39:15 +01:00
Indrakant Dana
8029d1ce6a
Replaced i18n.t w/ tpl in v3/settings.js (#13551)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 08:36:11 +01:00
Shadman Ahmed Khan
c1789a3a03
Replaced i18n with tpl in core/server/api/v3 (#13548)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Shadman Khan <shadmankhan@ShadmanMac.local>
2021-10-12 08:33:33 +01:00
Jack Wu
65d5b8d671
replaced i18n with tpl in mega of core services (#13546)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: jack.wu <jack.wu@wemoscooter.com>
2021-10-12 08:29:34 +01:00
Indrakant Dana
4f0999b6db
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/setup.js (#13534)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 21:28:01 +01:00
Indrakant Dana
91dd9eae4e
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/webhooks.js (#13536)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 20:54:06 +01:00
Indrakant Dana
7c14ff903b
Replaced i18n.t w/ tpl in api/v3/utils/validators/input/settings.js (#13533)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 19:57:40 +01:00
Indrakant Dana
cef32dd1fe
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/passwordreset.js (#13532)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 19:56:23 +01:00
Indrakant Dana
a73459d904
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/invitations.js (#13531)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 19:45:29 +01:00
Indrakant Dana
9fe0b3df1a
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/images.js (#13530)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 19:36:36 +01:00
Hannah Wolfe
0bdaa216e5
Refactored tpl to never be used in DI
- Ghost has a set of core packages that it is safe to require directly in any file - tpl is one of them!
- This keeps the DI signature smaller and easier to reason about
2021-10-11 15:19:54 +01:00
Naz
1530cb28a5 Simplified Notification's service constructor
refs https://linear.app/tryghost/issue/CORE-64/resolve-undissmissable-update-notification-banners

- There's no need to pass a whole "version object" when all we need it a string in a full version format inside the module
2021-10-11 16:04:48 +02:00
Naz
c0d59db5be Added filtering of outdated custom notifications
refs https://linear.app/tryghost/issue/CORE-64/resolve-undissmissable-update-notification-banners
refs https://github.com/TryGhost/Team/issues/754
refs https://github.com/TryGhost/Team/issues/204
refs https://github.com/TryGhost/Ghost/issues/10236

- Custom notifications coming form the update check service should not be shown beyond instance's update. Once the notification is received it's marked with the current version number. With an instance upgrade all notification with older version should be hidden.
- This improvement should also resolve the problem of major version notifications with next major update (the code associated with https://github.com/TryGhost/Ghost/issues/10236 can then be removed after 5.0.1)
2021-10-11 16:04:48 +02:00
Ayoub BERDEDDOUCH
1249254a68
Replaced i18n w/ tpl in /core/server/api/v3/posts-public.js (#13527)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 14:40:01 +01:00
Ayoub BERDEDDOUCH
8102a316d5
Replaced i18n w/ tpl in /core/server/api/v3/preview.js (#13526)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 14:39:36 +01:00
Ayoub BERDEDDOUCH
8961785dfa
Replaced i18n w/ tpl in /core/server/api/v3/session.js (#13525)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 14:39:19 +01:00
Ayoub BERDEDDOUCH
887caa299f
Replaced i18n with tpl in /core/server/api/v3/slugs.js (#13524)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 14:37:44 +01:00
homersimpsons
3bb7813613
Replaced i18n.t w/ tpl helper in core/server/api/canary/* (#13521)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 14:35:43 +01:00
william chandra
311414ad48
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/users.js (#13517)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 14:30:05 +01:00
william chandra
a62c7acde2
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/oembed.js (#13516)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 13:59:40 +01:00
william chandra
e0b08c1ece
Replaced i18n.t w/ tpl in api/v3/utils/validators/input/invites.js (#13514)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-11 13:58:53 +01:00
Naz
8737ec8888 Added createdAtVersion property to newly created notifications
refs https://linear.app/tryghost/issue/CORE-64/resolve-undissmissable-update-notification-banners

- The property is meant to track Ghost instance version the notification was received and processed at.
- This information should be useful in the future to dismiss outdated notifications
2021-10-11 23:38:40 +13: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
Hannah Wolfe
8b7d0fc6a1
Fixed linting error from bad merge
refs: #13380

- one of the prs I merged was a duplicate and ended up with the same messages object declared twice
2021-10-08 15:49:27 +01:00
Aleksander Chromik
48ac52800b
Replaced i18n.t w/ tpl in core/server/lib/image (#13507)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-08 15:44:13 +01:00
Aleksander Chromik
36a2569370
Replaced i18n.t w/ tpl in class Invites (#13506)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-08 15:42:50 +01:00
LucasOe
1ceab9dea3
Replaced i18n.t w/ tpl in v2/slugs.js (#13505)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:41:10 +01:00
LucasOe
ace3ff033c
Replaced i18n.t w/ tpl in v2/settings.js (#13504)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:40:55 +01:00
LucasOe
5ec272a377
Replaced i18n.t w/ tpl in v2/preview.js (#13503)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:40:22 +01:00
LucasOe
649461ba2f
Replaced i18n.t w/ tpl in v2/posts.js (#13502)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:39:58 +01:00
LucasOe
ea346d5d22
Replaced i18n.t w/ tpl in v2/posts-public.js (#13501)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:39:15 +01:00
LucasOe
280bc6e6e1
Replaced i18n.t w/ tpl in v2/pages.js (#13500)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:38:40 +01:00
LucasOe
3303ce127c
Replaced i18n.t w/ tpl in v2/oembed.js (#13499)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:38:23 +01:00
LucasOe
e1bcd422f5
Replaced i18n.t w/ tpl in v2/invites.js (#13498)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:38:06 +01:00
LucasOe
4b742adafc
Replaced i18n.t w/ tpl in v2/integrations.js (#13497)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:35:54 +01:00
LucasOe
eca69da254
Replaced i18n.t w/ tpl in v2/authentication.js (#13496)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:35:22 +01:00
Brilliant Djaka
fc55089266
Replaced i18n.t w/ tpl helper in preview.js (#13494)
refs: #13380

The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:32:51 +01:00
Aleksander Chromik
df0d92f060
Replaced i18n.t w/ tpl in class OEmbed (#13492)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-08 15:32:16 +01:00
Aleksander Chromik
cadd63bc9c
Replaced i18n.t w/ tpl in core/server/data (#13491)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-08 15:31:17 +01:00
Antonino Bertulla
368b5e41db
Replaced i18n.t w/ tpl helper in webhooks (#13482)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:26:44 +01:00
Minna N
d02cd54cde
Replaced i18n.t w/ tpl helper in v3/members.js (#13480)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:25:06 +01:00
PJ
684721b1bd
Replaced i18n with tpl in accept.js (#13471)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:21:22 +01:00
PJ
940d10fc3b
Replaced i18n with tpl in oembed.js (#13472)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:20:41 +01:00
Ayoub BERDEDDOUCH
3255c806f8
Replaced i18n with tpl core/server/api/canary/session.js (#13487)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-08 15:11:26 +01:00
Peter Zimon
5f96512d30 Link color udpate in newsletter
- Updated newsletter emails template to use accent color as link in post content
2021-10-08 15:55:55 +02:00
Ayoub BERDEDDOUCH
41d03bd08b
replaced i18n with tpl (#13484)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-07 16:51:28 +01:00
Naz
84118068c8 Remove i18n dependency from notifications service
refs https://github.com/TryGhost/Ghost/issues/13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-07 17:36:13 +02:00
Alex Ward
9ca2e205a1 Replaced i18n.t w/ tpl helper in providers.js
refs: TryGhost#13380

The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-07 11:32:07 +01:00
Alex Ward
189b7bb97b Replaced i18n.t w/ tpl helper in import-manager.js
refs: TryGhost#13380

The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-07 11:31:44 +01:00
Naz
c65e62b7df Promoted email-only feature to general availability
closes https://github.com/TryGhost/Team/issues/1125
refs 3c822e0457

- Email-only is not considered a general availability feature and can be used without special flags.
- It allows to publish a new post type "email only" that only goes out as an email newletter and is available through an undescoverable URL (does not appear anywhere publicly similarly to preview posts) on the site.
2021-10-07 12:08:56 +02:00
Deeksha Agrawal
e8ad189511
Replace i18n with tpl in email-preview.js (#13475)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-07 09:22:32 +01:00
Deeksha Agrawal
e9c01d6ebe Replace i18n with tpl in webhooks.js
refs: TryGhost#13380
Replace i18n with tpl in webhooks.js (v2, v3)
2021-10-07 09:18:40 +01:00
thick-hollins
fa7048c61b Replaced i18n with tpl in webhooks.js
refs: TryGhost#13380
2021-10-07 09:16:20 +01:00
Ania Kowalska
c38b4ef1f7 Replaced i18n.t w/ tpl helper in pages-public.js
refs: #13380
2021-10-07 09:14:15 +01:00
Ania Kowalska
1d534bcd65 Replaced i18n.t w/ tpl helper in pages.js
refs: #13380
2021-10-07 09:14:15 +01: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
Aleksander Chromik
e849167472
Replaced i18n.t w/ tpl in core/server/models (#13464)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-06 11:43:54 +01:00
Deeksha Agrawal
e49c4a48ad
Replaced i18n.t w/ tpl helper in slugs.js (#13463)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-06 11:42:33 +01:00
Deeksha Agrawal
f6d4d67bbd
Replaced i18n.t w/ tpl helper in memberSigninUrls.js (#13462)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-06 11:41:37 +01:00
LucasOe
c06c63b92b
Replaced i18n.t w/ tpl helper in members.js (#13456)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-06 11:40:32 +01:00
Fabien O'Carroll
ff0b1a61b3 Added initial Offers API
refs https://github.com/TryGhost/Team/issues/1083

This is a WIP for the Offers API so that Admin development can begin to
use it.
2021-10-06 12:33:19 +02:00
Fabien O'Carroll
561ef348c9 Wired up Offer redirects to the site app
refs https://github.com/TryGhost/Team/issues/1091

This piece of middleware will handle redirecting from offer codes to the
relavant portal URL.
2021-10-06 12:33:19 +02:00
Fabien O'Carroll
3742a4afb7 Added Offers service
refs https://github.com/TryGhost/Team/issues/1083

This adds the Offers service which will allow us to build out an Admin
API to communicate with it. As well as wiring up the redirects to the
site app.
2021-10-06 12:33:19 +02:00
Ozan Uslan
68de391c98 Replaced i18n.t w/ tpl in invites.js for canary
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-06 10:19:47 +01:00
Ozan Uslan
027e25a47f Replaced i18n.t w/ tpl in invitations.js for canary
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-06 10:19:47 +01:00
Ozan Uslan
71bf5e5f19 Replaced i18n.t w/ tpl in images.js for canary
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
- Important Note: invalidFile error message does not have fields for variables, but it is being passed variables.
2021-10-06 10:19:47 +01:00
Alex Ward
4b6780f190
Replaced i18n.t w/ tpl helper in validators/input/ (#13460)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-06 10:17:42 +01:00
Aleksander Chromik
3c89921456
Replaced i18n.t w/ tpl in core/server/models/user (#13459)
refs: #13380

The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-06 10:16:57 +01:00
Ania Kowalska
dff788c64e
Replaced i18n.t w/ tpl helper in invites.js (#13433)
refs: #13380

* The i18n package is deprecated. It is being replaced with the tpl package.
* Replaced i18n.t w/ tpl helper in invites.js
* Replaced i18n.t w/ tpl helper in labels.js
2021-10-06 09:49:20 +01:00
Aleksander Chromik
6ff63dc220
Replaced i18n.t w/ tpl helper in core/server/services/auth (#13458)
refs #13380

The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-06 09:42:44 +01:00
Alex Nuttall
162502b19e
Replaced i18n.t w/ tpl helper in posts.js (#13455)
refs: #13380

The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: thick-hollins <alexnuttall@zoho.eu>
2021-10-06 08:59:21 +01:00
Naz
e3b56dd99f 🐛 Fixed immediately sent email when scheduling email-only post
closes https://linear.app/tryghost/issue/CORE-78/email-only-scheduling-should-work-the-same-way-as-regular-posts

- The email was going out at the moment of scheduling an email-only post instead of respecting the scheduled time.
2021-10-05 16:42:29 +02:00
ozanuslan
e2eef2a6d3 Replaced i18n.t w/ tpl in maintenance.js
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 14:37:46 +01:00
ozanuslan
ab86ffc349 Replaced i18n.t w/ tpl in uncapitalise.js
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 14:37:46 +01:00
Bruno Silva
fd678ddae6
Replace the deprecated dependency i18n with tpl in mail.js files (#13449)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
- The changed files are under `core/server/api/v2` and `core/server/api/v3`.
2021-10-05 10:40:00 +01:00
Bruno Silva
8338be3aca
Replace the dependency i18n with tpl in permissions.js files (#13448)
refs: #13380

The i18n package is deprecated. It is being replaced with the tpl package.

The files changed are under `core/server/api/v2` and `core/server/api/v3`.
2021-10-05 10:39:01 +01:00
Bruno Silva
22546d55e8
Replace the dependency i18n with tpl in all tags.js files (#13447)
refs: #13380 

The i18n dependency is deprecated, it's being replaced by the tpl one.

The `tags.js` files changed is under the following folders:

- core/server/api/canary/
- core/server/api/v2/
- core/server/api/v3/
2021-10-05 10:38:13 +01:00
Bruno Silva
c332d4e475
Replace the deprecated dependency i18n with tpl in users.js files (#13446)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

The files changed is under `core/server/api/v2` and `core/server/api/v3`.
2021-10-05 10:37:05 +01:00
Bruno Silva
bf4c5c861d
Replace i18n with tpl in some files under core/server/api/v2 (#13445)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Replace the deprecated dependency `i18n` with `tpl` in the following files under
`core/server/api/v2/`:

- authors-public.js
- pages-public.js
- session.js
2021-10-05 10:36:12 +01:00
Aleksander Chromik
b69c39ba13
Replaced i18n.t w/ tpl helper in authorize.js (#13442)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-05 10:34:07 +01:00
Aleksander Chromik
045ce4834c
Replaced i18n.t w/ tpl helper in passwordreset.js (#13441)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Aleksander Chromik <aleksander.chromik@footballco.com>
2021-10-05 10:32:32 +01:00
Hannah Wolfe
9d7049cd3f
Refactored helper registration code into a service
- The helper registration code is "framework" code and very specific
- At the moment the "theme engine" is full of lots of disparate theme related stuff
- I'm trying to make the frontend framework code clearer and also expand it to  make it more useful
- The helper system now also exposes 3 methods allowing you to register a directory, a helper or an alias
- I've updated the codebase to use these both for our core helpers and for "apps"
2021-10-05 10:04:02 +01:00
Gustavo Hernández
554f36de55
Replaced i18n.t w/ tpl helper in serve-public-file.js (#13429)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 10:00:28 +01:00
Gustavo Hernández
5438644a51
Replaced i18n.t w/ tpl in tags.js (#13428)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 10:00:00 +01:00
Ozan Uslan
8eeaae5dba Replaced i18n.t w/ tpl in middleware.js in api/v3/admin
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 09:58:58 +01:00
Ozan Uslan
12a839b29f Replaced i18n.t w/ tpl in middleware.js in api/v2/admin
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 09:58:58 +01:00
Ozan Uslan
cb4915aed1 Replaced i18n.t w/ tpl in middleware.js in api/canary/admin
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 09:58:58 +01:00
Guillaume
1cd1ae36bf Replaced i18n.t w/ tpl helper in mail.js
refs #13380
- this is a refactor to do everywhere
2021-10-05 09:43:47 +01:00
Daniel Lockyer
0ec6b425ee
Merged v4.17.1 into main
v4.17.1
2021-10-05 08:33:42 +01:00
Fabien O'Carroll
cda041d424 Moved StripeAPIService to its own service
refs https://github.com/TryGhost/Team/issues/1083

The Offers service is going to need access to the StripeAPIService too,
so we need to move it out of the @tryghost/members-api module and make
it accessible to both.
2021-10-04 19:28:19 +02:00
Naz
5066e65e03 Added validation to redirects config
refs https://linear.app/tryghost/issue/CORE-86/fix-failing-site-instance-when-redirects-file-is-invalid
refs 260a47da83

- Added validation logic to catch redirects files having invalid RegEx expressions when they are introduced into the system (on upload)
- This way the error happening in the refed commit would have not happened as the validator would not have passed it through
- Moved up the "Router" declaration in custom-redirects as it needs to happen before any other bit of logic has a chance to throw
2021-10-04 18:32:40 +02:00
Ozan Uslan
d1b7055af5 Replaced i18n.t w/ tpl in version-match middleware
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-04 15:32:53 +01:00
Ozan Uslan
b1395bbe20 Replaced i18n.t w/ tpl in upload middleware
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-04 15:32:53 +01:00
Naz
260a47da83 🐛 Fixed 500 when instance has an invalid redirects config
refs https://linear.app/tryghost/issue/CORE-86/fix-failing-site-instance-when-redirects-file-is-invalid

- The site was returning a 500 for all routes whenever an invalid redirects file was uploaded.
- The cause of this issue surfacing was this change - 0962b3ed45 (diff-10784969d51d9abb9d620625a14b31661ff3f98dbfb0ea17186186a8151bacfaL35) . Previously an instance always had some sort of a working router and when the configuration failed it still functioned as an empty redirects router. After the change no router was mounted resulting in a 500
- Test cases fixing the problem will folllow
2021-10-04 15:25:37 +02:00
Paul Cushing
fe2958eb73
Fixed typo "in" default About page. (#13271)
- added a missing word
2021-10-04 12:18:15 +01:00
Hannah Wolfe
e8c5a3bc26
Replaced i18n.t w/ tpl in error handler middleware
refs: #13380

- This is part of the ongoing push to get rid of the deprecated i18n.t calls
- In this case, it highlights just how little work we've done on API errors - we should have a full list of action messages, but there's just 1 :(
2021-10-04 11:52:10 +01:00
Hannah Wolfe
ec64ead47d
Added help & ghostErrorCode properties to API errors
- This is initial ground work to enable us to do a full error audit
- We want to prevent Ghost admin from ever showing any unhandled errors
- Additionally we want to ensure all handled errors are well worded & have context+help
2021-10-04 11:52:10 +01:00
Kevin Ansfield
25b0657784 Fixed inconsistent theme settings state after toggling customThemeSettings labs flag
no issue

If Ghost was booted or a theme activated with the `customThemeSettings` flag disabled but with a theme that has custom settings, enabling the flag later on wouldn't show the settings in Admin or make the settings available in the front-end. Similarly, disabling `customThemeSettings` when Ghost had been booted/or theme activated with it enabled meant that settings were still available on the front-end.

- added an event listener for `settings.labs.edited` that fully re-activates a theme so that it's passed through gscan again and the custom theme settings passed back are included/excluded based on the flag value and any required settings sync with the database is performed
2021-10-04 11:23:46 +01:00
Fabien O'Carroll
d07fc708ab Exported Offer model from models
refs https://github.com/TryGhost/Team/issues/1088
refs https://github.com/TryGhost/Ghost/commit/78d0644d

This was forgotten in the references commit and is required to be able
to use the model
2021-10-04 11:05:42 +02:00
Ozan Uslan
b97aadd840
Replaced i18n.t w/ tpl helper in spam-prevention (#13425)
refs: TryGhost#13380

The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-04 10:03:21 +01:00
Ozan Uslan
acf4a4b227
Replaced i18n.t w/ tpl helper in email and integrations (#13424)
refs: #13380

The i18n package is deprecated. It is being replaced with the tpl
package.

* Replaced i18n.t w/ tpl helper in email
* Replaced i18n.t w/ tpl helper in integrations
2021-10-04 10:02:27 +01:00
Kenneth Fitzgerald
31b998e1e1
Replaced i18n.t w/ tpl helper in permissions (#13419)
refs: #13380

The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Kenneth Fitzgerald <fitzgeraldkd@gmail.com>
2021-10-04 09:58:42 +01:00
Megharth Lakhataria
1e73f0b07a
Replaced i18n.t w/ tpl helper in email-post.js and email-preview.js (#13418)
refs: #13380

- this is to replace i18n.t with tpl because i18n.t is deprecated
- Replaced i18n.t with tpl helper in email-post.js
- Replaced i18n.t with tpl helper in email-preview.js
2021-10-04 09:57:08 +01:00
Ania Kowalska
4e4d092988
Replaced i18n.t w/ tpl helper (#13403)
refs: #13380

* Replaced i18n.t w/ tpl helper in authentication.js
* Replaced i18n.t w/ tpl helper in authors-public
2021-10-04 09:55:30 +01:00
Ania Kowalska
506f26b5ce
Replaced i18n.t w/ tpl helper in authentication.js (#13402)
refs: #13380
2021-10-04 09:54:15 +01:00
Rishabh
78d0644d78 Added model for offers table
refs https://github.com/TryGhost/Team/issues/1088

- adds basic model definition for `offers` table
2021-10-04 12:03:36 +05:30
Kenneth Fitzgerald
548e83d665
Replaced i18n.t w/ tpl helper in serializers/output (#13401)
* Replaced i18n.t w/ tpl helper in users

refs: #13380
The i18n package is deprecated. It is being replaced with the tpl package.

* Replaced i18n.t w/ tpl helper in authentication

refs: #13380
The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Kenneth Fitzgerald <fitzgeraldkd@gmail.com>
2021-10-01 19:00:03 +01:00
Fabien O'Carroll
da76a6ebf9 Removed labs gating from bulk action endpoint
no-issue

This allows the new filtering feature to perform bulk actions without
using the labs flag.
2021-10-01 14:17:52 +02:00
Fabien O'Carroll
7a7d037176 Updated Members bulk endpoint req body format
refs https://github.com/TryGhost/Team/issues/1077
2021-10-01 14:14:13 +02:00
Rishabh Garg
c4cfd1839a
Added offers table (#13381)
refs https://github.com/TryGhost/Team/issues/1088

- adds schema for new offers table
- adds permission fixtures for new offers table
- adds migrations for new table and permissions

Co-authored-by: Fabien O'Carroll <fabien@allou.is>
2021-10-01 12:18:33 +02:00
Kenneth Fitzgerald
5fb93535f0
Replaced i18n.t w/ tpl helper in scheduler-intergation (#13399)
refs: #13380
The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Kenneth Fitzgerald <fitzgeraldkd@gmail.com>
2021-10-01 10:38:13 +01:00
Hannah Wolfe
ca149f2c0e
Replaced i18n.t w/ tpl helper in LocalFileStorage
refs: https://github.com/TryGhost/Ghost/issues/13380

- this is a refactor we are looking to do everywhere
- this commit is a reference for how to do the refactor: in small minimal pieces
2021-09-30 17:50:41 +01:00
Naz
94050d37cd Fixed comma dangle
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Stray comma was introduced in previous commit
2021-09-30 18:22:32 +02:00
Naz
298a88ef40 Reshuffled yaml parser messages
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- The previous messages structure wasn't making any sense
2021-09-30 18:18:19 +02:00
Naz
7619ad31d4 Extracted yaml parsing into DI for settings loader
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- When the yaml parser is injected through a DI it's easier to test and later on the redirects service initialization would use same pattern with exactly the same yamlParse funciton
- Next step is getting yaml parser into an outside module
- Also simplified getSettingFilePath method while swapping to an updated yaml parser implementation. Now this method function is exactly like the one used in redirects
2021-09-30 17:33:17 +02:00
Naz
99a2f12cb7 Simplified yaml parser to have fewer dependencies
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs 5715aa2155 (diff-48644be82a9b957e5e627bf7b0f2f73cdb1d63851ffad68c7c178c5886495bb8R52-R57)

- Simplified the yaml parser implementation to take in a single parameter, this move will allove to simplify the logic in the route settings + opens a door to unify handling with redirects yaml parsing!
- We loose the "filename" from the error information but that was a generic "routes.yaml" anyway and would be thrown only when somebody uploaded a routes.yaml file (no real added value).
- The debug statement should be moved to contain related filepath+other info to the calling module instead
- An additional error handler was borrowed from the redirects yaml parsing logic that was introduced in a referenced commit - it still makes sense to keep it for routes.yaml configuration
2021-09-30 17:29:43 +02:00
Naz
2649f32dd2 Removed unnecessary parameter
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- The content path parameter was passed around without really giving much additional value - the "filePath" gives big enough picture for the error to tell about what has happened
2021-09-30 17:29:42 +02:00
Naz
1ac0ba07de Extracted yarml persed dep out of settings loader
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Moving internal dependencies to be injected through constructor DI for better testability. This is first step of few more to follow. Not doing it all at once as there's too many thing failing when doing a bulk refactor
2021-09-30 17:29:42 +02:00
Naz
96d075c47d Refactored settings loader to class
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- It's a step to making the module follow class+DI pattern before fully extracting it into an external libarary
- Reminder, doing in Ghost repo instead of substituting big chunks all at once to have clear history of how the service evolved prior to the extraction into external lib!
2021-09-30 17:29:42 +02:00
Naz
a00b994e9e Renamed route loader module to settings-loader
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- The rename was needed to make it something more generic to later fit both routes and redirects setting purposes
2021-09-30 17:29:42 +02:00
Naz
d4cd1bb865 Refactored ensure settings module into a class with DI
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Ensure settings had only one method but would benefit from class+DI pattern before extracting it into an outside module.
- The logic is now also less coupled with "routes" and single source/destination paths. It's all configureable instead and might be reused if similar pattern is needed for example with redirect settings defaults.
2021-09-29 20:56:55 +02:00
Naz
0962b3ed45 Made custom-redirects middleware testable
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs 7528ec8c3b

- The way the custom redirects middleware was organized made it extremely hard to unit test it (had to stub the redirects service methods etc). With a new organization it's possible to provide needed redirects configs to the method which makes the actual redirects Router logic testable and the code less coupled with redirects services
- This was meant to be an attempt to extract more of the slow redirects regression tests, which failed. Instead found this weak spot that could be improved and gained:
- shaved 4s of time as two slow regression test cases are now gone
- there's now a base to build upon when getting more coverage for the custom redirects middleware
2021-09-28 22:00:32 +02:00
Kevin Ansfield
59adb9a9cb Added route for updating custom theme settings
refs https://github.com/TryGhost/Team/issues/1070

- bumped `@tryghost/custom-theme-settings-service` for access to `.updateSettings()`
- added `PUT /custom_theme_settings` route that delegates to `customThemeSettingsService.updateSettings()` to perform the db and cache updates
- invalidates the cache in Ghost because a theme setting change will mean the front-end output will change
2021-09-28 16:09:39 +01:00
Naz
dc051eb21a Refactored i18n out of custom redirects middleware
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- i18n is an old pattern we are getting rid of
2021-09-28 15:28:10 +02:00
Fabien O'Carroll
3965e8051b Added hacked redirect for Offers
refs https://github.com/TryGhost/Team/issues/1091

This is a hack version of adding a redirect for the one-day version of
Offers.
2021-09-28 15:10:27 +02:00
Fabien O'Carroll
b22050c037 Added initial support for Offers 1-day version
refs https://github.com/TryGhost/Team/issues/1090

This updates the members-api to allow passing an Offer ID when creating
a Stripe Checkout Session. This will be used for the 1-day version of
Offers.
2021-09-28 15:10:27 +02:00
Hannah Wolfe
0db7ef849c
Removed remaining use of i18n from core/frontend
- i18n is an old pattern we are getting rid of in favour of tpl
- after removing i18n from helpers, there wasn't many usages of i18n left in the frontend, this removes whats left!
- this was done on a branch at the same time as Naz's commits removing i18n from the settings-related files
- hence some of these changes are minor amends to add additional messages/change names, rather than just straightup i18n->tpl
- it's a merge of both our refactors :)
2021-09-28 11:58:29 +01:00
Naz
1c8c55992a Simplified route settings module api
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Made clear distinction around the methods that are exposed for the API use and for the internal use. Same pattern can be found in themese's and redirects module APIs
2021-09-28 09:47:42 +02:00
Naz
8b6a2bb87f Simplified redirects module api
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Made clear distinction around the methods that are exposed for the API use and for the internal use. Same pattern can be found in themese's module API
2021-09-27 19:39:47 +02:00
Naz
8bda544411 Moved redirects modules to backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- These modules should be colocated on the backend side as the frontend should know nothing about "where the config comes from" in terms of file system or any other source.
2021-09-27 19:12:24 +02:00
Naz
2fc26bd80a Removed unnecessary async statements
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- These methods are completely sync, there's no need to complicate it with artificial "async" method signatures. Even if used in then chains or with await these methods should still work!
2021-09-28 04:59:41 +13:00
Naz
dd042d69c9 Moved routing setting hash calculation to backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- These were the last bits that had to be moved out of the frontend doing route.yaml related operations
- Next steps will be refactoring a "bag of everything" into smaller modules and reducing dependencies where possible
2021-09-28 04:59:41 +13:00
Naz
95706aa37e Moved validate&yaml-parser modules to backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- These modules should be colocated along with the rest of routes.yaml related modules
- They will later be extracted into external modules
2021-09-28 04:59:41 +13:00
Naz
0586a73c6d Exposed async route settings loading method
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- There's no reason for the boot to block the event by loading route settings sychronously
- The only leftover use of a sync loader might also be refactored in some way to avoid blocking the event loo - for example by caching the value on the service layer.
2021-09-28 04:59:41 +13:00
Naz
85f18850a9 Cleaned up loader method docs
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- There were duplicate descriptions of the same thing in multiple places. Made the description a bit more accurate given the latest changes
2021-09-28 04:59:41 +13:00
Naz
ebc33180a1 Simplified route-settings module api signature
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- There's no additional logic, so wrapping with a function is unnecessary
2021-09-28 04:59:41 +13:00
Naz
7a91917424 Removed use of 'routes' parameter in route settings loader
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- The only allowed route settings name is 'routes.yaml', which removes a need to parameterize the function as the location is permanent anyway
- Simplifying the function in any possible way before extracting the common bits into an external lib
2021-09-28 04:59:41 +13:00
Naz
ba964c549f Moved route settings "getter" to the backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Frontend is not meant to know about the underlying source of the "routes" configuration, so any reads/edits/validations are being moved into a backend service. This should also simplify the coupling of the backend with the frontend where the latter will get a JSON blob with all needed configuration during the boot
- Nother problem the "get" method had was hiding an underlying function it was doing - reading the file from the filesystem SYNCRONOUSLY. It might be a thing we need to do during the "web" app initialization, but there's no clear need to do this in a sync fassion during the bootup for example. Also having a more explicit name should help :)
2021-09-28 04:59:41 +13:00
Naz
484bb2eea2 Moved default-routes.yaml file to backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs c1c9bf0866

- Actions logic related to file system operations (like ensuring files exist) should be done on the backend. Now the route settings initialization logic lives on the backend it makes sense to keep the file closer to the source.
- The move is the opposite to the one refed in the commit with a
difference that the file now lives in "route-settings"
2021-09-28 04:59:41 +13:00
Naz
4b80fe1ab3 Reworked routeSettings service public API
refs 4da7e7f0cb
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- This rework is mean to give cleaner separation over methods used by the API and internal methods
2021-09-28 04:59:41 +13:00
Naz
31e9434466 Moved route settings initialization to backend
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Actions logic related to file system operations (like ensuring files exist) should be done on the backend. The frontend will be receiving a unified JSON blob config without needing to know about filesystem
2021-09-28 04:59:41 +13:00
Naz
58ba14c188 Removed use of 'routes' parameter for getCurrentHash function
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- With a single possible value for setting ('routes') there's no need to pass the parameter around
2021-09-28 04:59:41 +13:00
Naz
93af11bdec Simplified knowSettings usage
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- 'knowSettings' was based on a "configurable" array of settings that might be configured in Ghost. The multitude never happened! The only setting the frontend takes care of is routes.yaml file (redirects is also kind of a setting but is a separate concept for now).
- Having just one type of file to deal with allows to simplify implementation significantly, which helps before a big refactor
2021-09-28 04:59:41 +13:00
Kevin Ansfield
2947db0e6b
Added API endpoint for browsing custom theme settings (#13362)
refs https://github.com/TryGhost/Team/issues/1070

- bumped `@tryghost/custom-theme-settings-service` to get access to `.listSettings()` method
- added GET `/api/canary/admin/theme_settings/` route behind `'customThemeSettings'` feature flag that uses the custom theme settings service to return settings resources that are a combination of the theme-provided definition and the saved value
2021-09-27 11:31:47 +01:00
Kevin Ansfield
cb53dd338e Moved theme settings permissions migration to correct Ghost version
refs b6d9bad6dc

- 4.16 has already been released, moved to 4.17 so the migrations will run correctly
2021-09-27 10:56:23 +01:00
Kevin Ansfield
b6d9bad6dc
Added custom theme settings browse/edit permissions for Administrators (#13361)
refs https://github.com/TryGhost/Team/issues/1070TryGhost/Team#1070

- initial implementation will only allow browse+edit via the API
2021-09-27 09:59:09 +01:00
Naz
035ad01f24 Swapped to American English spellings
refs 16728a3ef1

- initialised -> initialized
2021-09-23 18:36:38 +02:00
Matt Hanley
a9ea792d65
Updated OAuth middleware to use the correct URL helpers
no-ref

Hardcoded redirect URLs were breaking when admin and site URLs were
different, or when Ghost is configured with a subdirectory.
2021-09-23 17:26:29 +01:00
Kevin Ansfield
04dd409243
Added syncing and theme exposure of custom theme settings (#13354)
refs https://github.com/TryGhost/Team/issues/1070

- added `@tryghost/custom-theme-settings-service` as a dependency
- `core/server/services/custom-theme-settings` creates an instance of the new service passing in the model used for storing the setting keys/values and a cache instance
- requiring `core/shared/services/custom-theme-settings-cache` creates a cache instance, it has no dependencies so can be required anywhere and the first require will initialize the shared instance
- updated the theme activation bridge to trigger the theme settings service to sync the newly activated theme settings and populate the cache
- updated theme validation to pass `labs` through as an option so that we get custom theme settings back as part of the checked theme as that's what is passed to the custom theme settings service
2021-09-23 12:44:39 +01:00
Kevin Ansfield
57effd9585
Added custom_theme_settings table/model (#13327)
refs https://github.com/TryGhost/Team/issues/1070

- stores values of custom theme settings
  - will be merged with full settings data parsed from themes for API output
  - will be cached and made available for lookup in themes to avoid db roundtrips
- stores type of custom theme settings so we can coerce values and know if the type has changed when syncing
- records will be synced with themes upon activation
2021-09-23 11:51:18 +01:00
Daniel Lockyer
57664696a4 v4.15.1
-----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQTqYa7kNs8D7Oo9dgLSEYbwtHKVrQUCYUxOIgAKCRDSEYbwtHKV
 reO6AQCL2mFdVLBwRbpVQa2Zs9RlYKk88ivLRMpAZPPiElNblQEAqt710wrVbMwm
 hOOWbWdFpPOWCrop9zhO8GJSPeNpJw0=
 =Ff3M
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQTqYa7kNs8D7Oo9dgLSEYbwtHKVrQUCYUxTawAKCRDSEYbwtHKV
 ra28AQCcambctLCH70Sc7SJmexojA5k6Ti0p3pwOktWY/WygZQEAlMEHSDw89wdY
 3U8R8zY1d1MeXqj51Op95sTYwiDAjg8=
 =HoUL
 -----END PGP SIGNATURE-----

Merged v4.15.1 into main

v4.15.1
2021-09-23 11:13:56 +01:00
Fabien O'Carroll
944c2cc9af
🔒 Fixed member email change vulnerability
refs https://github.com/TryGhost/Ghost/security/advisories/GHSA-65p7-pjj8-ggmr

This updates the signup/signin flow for members to no longer support the
email address change flow - which had missing authentication. It has
been replaced with a dedicated email change flow, and Portal has been
updated to use it.
2021-09-23 10:49:30 +01:00
Naz
f13ee0e4fb Corrected type declarations in ThemeStorage
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- Type declarations were incorrect, co changed them to something more suitable based on the implementation to reduce the error output.
2021-09-22 14:16:39 +02:00
Naz
7589218abc Converted import-manager module to a class
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-16/tackle-importersdataindexjs

- The codebase uses class syntax instead of extending/instantiating a native function (this is a very old of doing pseudo OOP in JS). Updated the old syntax in a very one-to-one brainless way with intention to improve the file again when touched again
2021-09-22 20:10:23 +12:00
Naz
c39d1996a4 Brought back importer index.js file exposing a single thing
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-16/tackle-importersdataindexjs

- This extra step was done to keep the git history cleaner (previous commit was a clean rename). This new index file exposes just one thing.
- The next step here should be refactoring of the "importer-manager" module into a class following a DI pattern.
2021-09-22 20:10:23 +12:00
Naz
0d32552d7a Renamed imports indexjs to import-manager
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-16/tackle-importersdataindexjs

- The index file should contain an API index that the module/folder exposes. In this instance it is a full blown class-like set of data and functions that don't belong to index.js
2021-09-22 20:10:23 +12:00
Rishabh
1e239de039 Added new ingress endpoint for client-side events
res https://github.com/TryGhost/Team/issues/1064

- adds new events endpoint on members app to capture client side events for member analytics behind the `membersActivity` flag
2021-09-21 23:37:25 +05:30
Naz
90e9e473ad Brought back index.js file exposing a single thing
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-16/tackle-importersdataindexjs

- This extra step was done to keep the git history cleaner (previous commit was a clean rename). This new index file exposes just one thing.
- The next step here should probably be refactoring of the data-importer module into a class following a DI pattern.
2021-09-22 03:23:12 +12:00
Naz
208dd49971 Renamed imports/data indexjs to data-importer
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-16/tackle-importersdataindexjs

- The index file should contain an API index that the module/folder exposes. In this instance it is a full blown class-like set of data and functions that don't belong to index.js
2021-09-22 03:23:12 +12:00
Fabien O'Carroll
9183c3fa11 Exported MemberAnalyticEvent from models/index.js
refs https://github.com/TryGhost/Team/issues/1053

In order to use the model we must exports it from the index.js file.
This was missing from the commit which added the models.
2021-09-21 13:22:40 +02:00
Naz
74c15c7b02 Refactored secret settings util functions
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-13

- The index file in services/settings was containning logic and started throwing an additional lint warning due to module length.
- The extracted secret settings utils were used in multiple places and were a good candidate to live in it's own small module
2021-09-21 23:05:57 +12:00
Naz
ed56239523 Moved browse method from settings API controllers
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-13

- The browse method didn't throw a complexity warning but was a clear target to get extracted into settings bread service. This way we get rid of a settings cache dependency and reduce code duplication.
2021-09-21 23:05:57 +12:00
Naz
d76ba2852e Removed method complexity in settings API v3 controller
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-13

- The controller code is not meant to contain complex business logic. Removed complexity in settings.edit method
- Have brought up to sync v3 controller code to the changes that were done in v4. Didn't touch v2 controller as it had slight API differences, so avoided going on another trip into the unknown
- Migrating v3 controller was pretty straigh forward as it's an exact copy of the v4 one (at least for the methods that were extracted)
2021-09-21 23:05:57 +12:00
Naz
ae3b2fad7c Removed method complexity in settings API controller
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-13

- The controller code is not meant to contain complex business logic. Removed complexity in settings.edit method
- The code causing the complexity warning clearly belonged in the validation layer, so has been moved to it's propper location
2021-09-21 23:05:57 +12:00
Naz
e7ec197da1 Removed duplicate logic from settings edit permissions stage
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-13

- The removed logic is done more thoroughly on the settings BREAD
service layer.
2021-09-21 23:05:57 +12:00
Naz
6b25b91fa4 Removed method complexity in settings API controller
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-13

- The controller code is not meant to contain complex business logic. Removed complexity in settings.edit method
- Have separated the regular editing from "Stripe Data" editing to keep the dependency on the members service still in the controller reducing coupling of the settings BREAD service to the minimum.
- The stripeConnectData passed into `edit` method still feels out of place (maybe it should be passed as an array already that's ready to be merged with the rest of settings, but that was left for another refactor in the future)
2021-09-21 23:05:57 +12:00
Naz
85ee721157 Removed method complexity in settings API controller
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-13

- The controller code is not meant to contain complex business logic.
Reduced complexity in the settings.read method
- Broke the usual "xxxService" naming pattern here in favor of "xxxBREADService" pattern that members package has been experimenting with recently (0469707f2e/packages/members-api/lib/services/member-bread.js (L25)). This naming choice was made because we already had a "SettingsService" and it would've become quite convoluted distinguishing the naming or doing renames for the sake of having a new temporary location for read/edit/add methods
- Also duplicated `hideValueIfSecret` method code with an intention to move it fully into the BREAD service once the refactoring is completed
2021-09-21 23:05:57 +12:00
Fabien O'Carroll
c1c969238f Passed MemberAnalyticEvent to @tryghost/members-api
refs https://github.com/TryGhost/Team/issues/1055

We use the models defined in Ghost as our database connection to store
the analytic events. So we must pass this down to the Members module so
that we can store the events
2021-09-21 11:42:05 +02:00
Daniel Lockyer
8590376795
Fixed linting issue
no issue

- I removed the use of Promises but didn't clean up the import
2021-09-17 16:51:52 +01:00
Daniel Lockyer
93e4b2eafd 🔒 Fixed remote command injection when using sendmail email transport
refs https://github.com/TryGhost/Ghost/security/advisories/GHSA-wfrj-qqc2-83cm
refs https://github.com/advisories/GHSA-48ww-j4fc-435p

- a vulnerability in `nodemailer` means that the `sendmail` transport is
  vulnerable to command injection for flags passed to the `sendmail`
  binary
- updating to the latest version of Nodemailer required creating
  `@tryghost/nodemailer`, which is a wrapper around Nodemailer and
  several plugins that used to be in the core
- this commit switches to using that package, and fixes up some small
  code + test changes
2021-09-17 16:46:51 +01:00
Fabien O'Carroll
61058fb0a4 fixup! Refactored migration to run faster 2021-09-17 16:33:14 +01:00
Fabien O'Carroll
3165315f84 fixup! Refactored migration to run faster 2021-09-17 16:33:14 +01:00
Fabien O'Carroll
484e0c1e05 Refactored migration to run faster
no-issue

We're seeing problems with large sites taking a long time to run this
migration. The aim here is to refactor it so that it is faster to run.

We've achieved that by reducing the number of database queries needed,
firstly by selecting members with a join to their events (rather than
fetching the events on a member-by-member basis) we also batch the
necessary updates to further reduce db query time.
2021-09-17 16:33:14 +01:00
Fabien 'egg' O'Carroll
2dca63eae2
Added temporary database table for analytic events (#13312)
refs https://github.com/TryGhost/Team/issues/1053

This table is going to be completely deleted at some point in the
future. It serves as a persistent datastore for a spike into collection
analytic events for members. We've opted for a generic table, rather
than a table for each event, so that we can push the DB to the limit in
terms of the length of the table, and find out performance issues A$AP
2021-09-17 11:15:21 +02:00
Kevin Ansfield
02347aa788
🐛 Fixed Outlook incorrect text styling and &apos; appearing in email content (#13313)
refs https://github.com/TryGhost/Team/issues/1047

Rendering segmented emails uses `cheerio` to parse and re-render the html but this had a side-effect of converting the `$#39;` char code to the more modern `$apos;` code resulting in Outlook not understanding quotes inside inlined CSS and showing the raw char code if it appeared in the email contents.

- extracted our handling of the unsupported char codes from the main email html generation into a function so that it can be re-used when generating segmented html
2021-09-17 08:39:29 +01:00
Naz
191b313271 Removed method complexity in webhooks API controller
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-14/tackle-webhooksjs

- The controller code is not meant to contain complex business logic.
2021-09-17 10:11:23 +03:00
Naz
cff0c483af Updated v3 Webhook API to match v4 implementation
refs 70627d84a7
refs 44035fd591
refs https://github.com/TryGhost/Team/issues/477

- When v4 Webhook API was changed removing redundant code v3 API code should've been updated as well. Making this change before extracting logic out into a WebhooksService to have clear chain of why the code that doesn't look the same has been substituted
2021-09-17 09:58:44 +03:00
Naz
4744349381 Removed method complexity in integrations API controller
refs https://github.com/TryGhost/Team/issues/694
refs https://linear.app/tryghost/issue/CORE-10/tackle-integrationsjs

- The controller code is not meant to contain complex business logic.
- Added a test case checking 'PUT' endpoint for integrations to ensure
proper 'NotFound' handling. Found that previous implemenation was
buggy - threw a 500 as 'models.Integration.NotFoundError' that was removed
in previous commit didn't catch a needed error.
2021-09-16 14:23:48 +03:00
Daniel Lockyer
d4adae775e v4.14.0
-----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQTqYa7kNs8D7Oo9dgLSEYbwtHKVrQUCYUB7mgAKCRDSEYbwtHKV
 rYTGAP9dggMBUTq6+2yLyYHChVMqLez2WS/XmgTdC4mc2tsZzgD+J2/zhRObGYX0
 d54Y39pAw7rPV8Z8md9nCm9olPpE4AM=
 =w206
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQTqYa7kNs8D7Oo9dgLSEYbwtHKVrQUCYUB8kwAKCRDSEYbwtHKV
 rTGVAP4wqFwWwQUFUXX4tLbvcLKQalvHQI3soLFneAzZT1M3DQEAtWO+crkH2auN
 Agt8ND2ndlIzsyGxYywliajBfbQVZwM=
 =nFhH
 -----END PGP SIGNATURE-----

Merged v4.14.0 into main

v4.14.0
2021-09-14 11:42:21 +01:00
Kevin Ansfield
6875796417 Blocked 0.* IP addresses when making oembed requests
no issue

It was possible for authenticated/trusted admin users to make GET requests to localhost via the oembed service by crafting a redirect that used 0.0.0.0.

- added the 0.* default route/routing block to the private IP regex used to block requests when we're contacting external sites
- added an additional IP or localhost check in the oembed service when fetching bookmark card data
2021-09-14 11:35:14 +01:00
Daniel Lockyer
2d639ad4a1 Replaced removed Bookshelf findWhere function
- as per https://github.com/bookshelf/bookshelf/wiki/Migrating-from-0.15.1-to-1.0.0#collectionfindwhere, the `findWhere` function was removed
- `find` can be used in combination with `matchFunc` and then checking
  the values against each other to keep the same functionality
- also updates the tests to reflect the change in number of function calls
2021-09-10 16:59:11 +01:00
Daniel Lockyer
23c207cefc Updated signature of Bookshelf model listeners
- as per https://github.com/bookshelf/bookshelf/wiki/Migrating-from-0.15.1-to-1.0.0#different-arguments-on-after-save-event-listeners-saved-created-and-updated, the signature of saved, created and updated listeners has changed to remove the second argument
- this commits updates our signatures too
2021-09-10 16:59:11 +01:00
Daniel Lockyer
80fa1d903e Removed explicit loading of Bookshelf registry plugin
- as per 5a5a5d162e, the Bookshelf registry plugin is now in core
- we no longer need to explicitly load the plugin, and it displays a
  warning if you do
- this change also turns `._models` into `.registry.models`, so our code has
  been updated to reflect that
2021-09-10 16:59:11 +01:00
Daniel Lockyer
8fcb57bd6a Disabled new Bookshelf fetch behaviour across models
- as per https://github.com/bookshelf/bookshelf/wiki/Migrating-from-0.15.1-to-1.0.0#default-to-require-true-on-modelfetch-and-collectionfetchone, models will now default to `{require:true}` during a fetch, which changes how Bookshelf will respond when a models yields no results
- instead of passing a `null` result, it will reject with an error, so we'd need to switch to `.catch`ing everything
- our code is set up to handle all these null results and switching style is not currently on the cards so we want to use the existing behaviour for now
- to enable this, the `requireFetch` option needs to be added to the model definitions
2021-09-10 16:59:11 +01:00
Fabien O'Carroll
c9325aa2cc Fixed Complimentary subscriptions being created twice
refs https://github.com/TryGhost/Team/issues/1030

The usage of `setComplimentarySubscription` is for pre-Tiers enabled
sites only. We didn't see this issue before because the `comped` flag
was incorrectly being set to `false` by default. Since it was fixed in
https://github.com/TryGhost/Ghost/commit/ae844db60 the `comped` flag was
then getting sent up, and creating the subscription.

We've moved the usage of `setComplimentarySubscription` to behind the
feature flag so that we do not use old behaviour when Tiers are enabled
2021-09-10 14:29:20 +02:00
Kevin Ansfield
864e4583d4 Fixed segmented email content being sent to all members
refs https://github.com/TryGhost/Ghost/pull/13276

- when removing the labs flag a conditional in the email processor checking for the labs flag being enabled was replaced with a check for a member segment being present. This meant that email batches with `member_segment: null` representing all members that didn't have content specifically aimed at them were not having the segmented content stripped before sending
2021-09-10 11:36:42 +01:00
Peter Zimon
60d6d36c5e Updated sign up email copy
- Updated the copy of the confirm button in the signup email to make the use case (sign up vs. sign in) clearer.
2021-09-09 12:33:56 +02:00
Fabien O'Carroll
519757faec Cleaned up webhook settings on Stripe disconnect
refs https://github.com/TryGhost/Team/issues/1006

These should have been cleaned up previously as they are no longer used
or valid without a Stripe connection.
2021-09-07 18:58:25 +02:00
Fabien 'egg' O'Carroll
cd89c7e427
Used @tryghost/members-api Stripe disconnect logic (#13290)
refs https://github.com/TryGhost/Team/issues/1006

Moving the logic of disconnecting Stripe into the members-api module
decouples the Ghost API from the Members API internals. This method can
now be updated independently of Ghost, to implement the deletion of
webhooks from Stripe.
2021-09-07 18:25:53 +02:00
Fabien 'egg' O'Carroll
647f1f8f61
Fixed MemberStatusEvents for free members (#13287)
refs https://github.com/TryGhost/Team/issues/1000

Some free members were created with a status of 'comped', this resulted
in MemberStatusEvents being created with a `to_status` of 'comped'.

In 4.12 we fixed the status for all free members, but we did not update
the associated member_status_event.
2021-09-07 15:02:59 +02:00
Fabien 'egg' O'Carroll
ae844db60b
Fixed handling of Complimentary Stripe subscriptions (#13289)
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. This meant that 'comped' members
had a status of 'paid'. The changes to @tryghost/members-api ensure that
handling subscriptions going forward will not result in this error.

Since we handle the Complimentary plan correctly now, we do not need to
manually check for the existence of one, we can instead rely on the
status to set the `comped` flag.
2021-09-07 11:31:47 +01:00
Fabien 'egg' O'Carroll
a0a35df13b
Migrated members comped status to reflect subscriptions (#13285)
* Migrated members comped status to reflect subscriptions

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

Due to a bug in subscription handling, members with Complimentary stripe
subscriptions were incorrectly given a status of 'paid'.

The goal of this migration is to fix existing broken members, and it
will be accompanied by a fix which prevents the bug for future members.

Since we are updating the status properties for members, we must ensure
that we also update the relevant member_status_events entries too, so
that we do not have incompatible sums between events and statuses.

For example, if we were to use events to graph comped members over time,
we would want the current count to match the query on statuses:

`SELECT COUNT(*) FROM members WHERE status='comped';`
2021-09-06 18:56:44 +02:00