Commit Graph

5725 Commits

Author SHA1 Message Date
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
Fabien 'egg' O'Carroll
62bb031bab
Fixed usage of linkStripeCustomer for v3 API (#13288)
refs https://github.com/TryGhost/Ghost/issues/12942

The function signature of this method has changed, and was only updated
in the canary API, this meant that API requests attempting to link a
stripe customer to a member would error for the v3 API.
2021-09-06 14:18:11 +01:00
Fabien 'egg' O'Carroll
90a4d369db
Fixed imports for files missing the email_only key (#13284)
closes https://github.com/TryGhost/Team/issues/1024

Our importer would set the default value of all posts_meta keys to
`null`. This is an invalid value for the `email_only` key which only
accepts booleans.

Since we are already looping over the schema to create the default
values, we can use the `defaultTo` property in the schema to use the
intended default, and fall back to `null` if it doesn't exist.

We've used the `Reflect.has` function to determine if the `defaultTo`
key exists, as opposed to a truthy check, because it's possible that a
falsy value (e.g. false, in the case of email_only) can be used as the
default.
2021-09-06 11:51:42 +01:00
Naz
6c75de6464 Removed i18t dependency from post scheduling service
refs https://github.com/TryGhost/Team/issues/694

- The i18t pattern has been deprecated. Quick clean up to keep the number of dependencies in the new module to the minimum
2021-09-04 07:49:11 +12:00
Naz
db2ef7dbca Migrated schedules v2/v3 APIs to match refactor in canary
refs https://github.com/TryGhost/Team/issues/694

- The canary schedules controller was refactored to use newly introduced post-scheduling service in a previous commit. This is a follow up to match v2/v3 controllers as they had identical code to the canary one.
2021-09-04 07:49:11 +12:00
Naz
7b53a61b73 Removed method complexity in schedules API controller
refs https://github.com/TryGhost/Team/issues/694

- The controller code is not meant to contain complex business logic.
2021-09-04 07:49:11 +12:00
Naz
00460c96f4 Removed i18t dependency from installer module
refs https://github.com/TryGhost/Team/issues/694

- The i18t pattern has been deprecated. Quick clean up to keep the number of dependencies in the new module to the minimum
2021-09-03 20:33:28 +04:00
Naz
84c88683ba Removed method complexity in themes API controller
refs https://github.com/TryGhost/Team/issues/694

- The controller code is not meant to contain complex business logic.
- Kept the pattern used in all modules under services/themes. The install module shold be refactored into a class with DI pattern when touched next.
2021-09-03 20:33:28 +04:00
Naz
8d36ebeb3c Refactored Labels API add method back to promises
refs https://github.com/TryGhost/Team/issues/694

- Additional try/catch block needed in async/await implementation increased method complexity  and broke the complexity linting rule. This is a dirty way to fix the warning. Ideally the implementation should stay with async/await syntax and instead move the custom error handling logic into some different layer. For example we could introduce a separate "stage" in the API framework's "pipeline" where we'd catch and handle in a generic way all of the "unique" types of errors. It would make sense to have a generic handler because this same code happens in labels, member and few more places.
2021-09-03 20:33:28 +04:00
Kevin Ansfield
020acb643e
Removed emailCardSegments labs flag (#13276)
refs https://github.com/TryGhost/Team/issues/993
reqs https://github.com/TryGhost/Admin/pull/2080

- removed labs flag
- removed labs flag usage in conditionals
- moved labs email template changes into main template
2021-09-02 13:11:11 +01:00
Naz
cea2facfe8 Updated mega's sendTestEmail JSDoc
no issue

- The "memberSegment" parameter is optional, marked it as such to remove type check errors
2021-09-02 13:11:10 +04:00
Naz
26f419f085 Reduced method complexity for sendTestEmail method
refs baccbb4942
refs https://github.com/TryGhost/Team/issues/694

- The change is here to remove yet another ESLint method complexity error
- The custom error handling complexity was introduced here in a referenced commit without an obvious reason. The specifics of how the "sendTestEmail" method handles errors should not leak out from the method, if there are errors in the response they should be handled internally and the method would uniformly reject with a single error.
2021-09-02 13:11:10 +04:00
Naz
807322dccb Extracted email preview service
refs https://github.com/TryGhost/Team/issues/694

- The code complexity in the email preview's read controller method was breaking the complexity rule in ESLint. To reduce the complexity extracted common parts into mega service
2021-09-02 13:11:10 +04:00
Naz
9a9866cf59 Refactored email-preview ctrl to use async/await
refs https://github.com/TryGhost/Team/issues/694

- async/await has been a standard way to handle async code throughout the codebase. Refactoring it before moving code makes it way easier to reason about similarities between multiple controllers
2021-09-02 10:59:00 +04:00
Naz
35e23636ae Fixed 'sent' status setting when publishing a post
refs https://github.com/TryGhost/Team/issues/947

- During the work of the UI and moving `email_only` flag to publish menu it created the situation where the publishing of the post was at the same time as adding `email_only` flag, resulted in not picking up teh `sent` status as the `posts_meta` model and record were's available during save.
- Adding the incoming attribute check for email_only flag covers this situation
2021-08-26 22:25:45 +04:00
Fabien 'egg' O'Carroll
bee1d4793d
Added static transaction method to base model (#13260)
no-issue

Writing code outside of Ghost which deals with the models is currently
done by passing the models which are needed to the external module,
rather than the instance of ghostBookshelf. This does not give us a way
to create transaction to run queries in. This method is designed as a
simple way to give all models the power to create a transaction for
themselves.

This will be used in @tryghost/members-api for example to ensure that
failures in communication with the Stripe API will rollback the related
inserts in the database.
2021-08-26 19:01:42 +01:00
Fabien O'Carroll
76311484df Added dummy subscription to comped members
refs https://github.com/TryGhost/Team/issues/873

This includes the update to @tryghost/members-api which includes the new
MemberBREADService which is used to handle the logic for controller
methods outside of the controller.

With it, we've introduced the concept of a dummy subscription for comped
members. This gives API consumers a way to get the created_at date for a
comped members access to a product.
2021-08-26 15:28:55 +02:00
Fabien O'Carroll
4e47c63e73 Updated members serializer to handle POJO
no-issue

The @tryghost/members-api module is being updated to export a BREAD
service which will be used to move the logic from the controller into.
This service is currently designed to returns objects rather than
models, as it has to do manipulation of the returned data at the object
level. This update to the serializer will allow a seamless transition to
the use of the BREAD service and allow us to pull out the logic from the
controller sooner!
2021-08-26 15:28:55 +02:00
Daniel Lockyer
51d602d5b3
Removed unused internal request lib
refs 3f0bab4389

- the internal `request` lib we had was replaced with `@tryghost/request` in
  the referenced commit
- this lib was not deleted, so it's still lingering around
- this commit deletes that file to clean it up
2021-08-26 14:21:27 +02:00
Fabien 'egg' O'Carroll
c7a7828b57
Gave Administrators permission to connect to Stripe (#13228)
refs https://github.com/TryGhost/Team/issues/994

This adds the permission required to connect to Stripe to the
Administrator role, as required by the linked issue.
2021-08-26 11:00:40 +01:00