Commit Graph

700 Commits

Author SHA1 Message Date
Matt Hanley
09804244f5 Added newsletters table to default export
refs https://github.com/TryGhost/Team/issues/1629

- We want to export the default newsletter so that we don't lose the post<>newsletter relationship when exporting
- The newsletter_id is currently ignored in the post importer (https://github.com/TryGhost/Ghost/pull/14720) so imports won't work right now
- This change means that exports created in 5.0+ will work later on with no data loss once the importer supports it
- The counts displayed for the newsletters are a count of email records, not post records - and we don't export/import emails so the count will always be 0 after importing a newsletter
2022-05-16 17:49:25 +01:00
Hannah Wolfe
12aff14dff Removed oauth experiment
refs: https://github.com/TryGhost/Team/issues/1625

- this didn't work the way we wanted to
- removing this will free up the namespaces to start over
2022-05-16 17:37:13 +01:00
Hannah Wolfe
18cf73c3b3
Updated output logic to correctly use excerpt 2022-05-16 15:51:14 +01:00
Naz
0c097f6532 Fixed frontend rendering of page resource
refs https://github.com/TryGhost/Toolbox/issues/332

- After removing the concept of a boolean "page: true" from the page/post resources frontend resource rendering didn't have enough information to pick the correct template
- Resolved this issue through passing of additional "context" to the template picker. Something nicer should be worked on in the future, as context pattern feels dirty here.
2022-05-16 22:06:55 +08:00
Naz
44c72ddd81 Removed output of "page" filter in Admin/Content APIs
closes https://github.com/TryGhost/Toolbox/issues/332
refs https://github.com/TryGhost/Ghost/issues/10922

- The "page" attirbute has been deprecated long time ago and was kept around in the output for back compatibility reasons. With Ghost 5.0 there's no longer need to return this field or keep around any of the code supporting "page" attribute processing
2022-05-16 22:06:55 +08:00
Hannah Wolfe
9957c2a77c
Revert "Updated plaintext to be a partial doc"
This reverts commit 8f90ca949d.

- plaintext is used in search features so this is probably a bad idea
2022-05-16 10:20:26 +01:00
Hannah Wolfe
8f90ca949d Updated plaintext to be a partial doc
refs: https://github.com/TryGhost/Ghost/issues/11407

- there's no need for us to process the whole document as it's only used for excerpts
- emails need the whole document, but they're managed seprately now
- this is more efficient and means we could potentially do it on the fly 🤔
2022-05-16 09:38:16 +01:00
Hannah Wolfe
9d4d6688d8 Removed links and figcaptions from excerpts
refs: https://github.com/TryGhost/Team/issues/1609
refs: https://github.com/TryGhost/Ghost/issues/11532
refs: https://github.com/TryGhost/Ghost/issues/11407

- these don't read correctly in an excert context
2022-05-16 09:38:16 +01:00
Hannah Wolfe
338dc3ae6c Refactored html-to-plaintext to have two functions
refs: https://github.com/TryGhost/Team/issues/1609

- Split html-to-plaintext into a function for excerpts and emails
- Updated all usages so they use the correct function
- There's currently no difference between the two
2022-05-16 09:38:16 +01:00
Simon Backx
6b3a657f88
Renamed newsletter_id and email_recipient_filter options (#14798)
refs https://github.com/TryGhost/Team/issues/1596

- Renamed `newsletter_id` to `newsletter` option, the `newsletter` option expects a slug instead of an id
- Renamed `email_recipient_filter` to `email_segment` option
- Default `email_segment` to `all`. Ignored if no newsletter is set
- `email_segment` is ignored if no newsletter is set
- When reverting a post to a draft, both `newsletter` and `email_segment` are reset to their default values (null, all)
- Removed legacy mapping from old email_recipient_filter values 'paid' and 'free' (already a migration in place)
- Dropped legacy throwing errors when email_recipient_filter is paid or free in transformEmailRecipientFilter
- Reorganized transformEmailRecipientFilter parameters for the now required newsletter parameter
- Fixed an issue where the newsletter filter wasn't working because it wasn't in permittedoptions
- Fixed an issue where you could send to an archived newsletter
- Added an extra protection when scheduling to an active, and later archiving the newsletter
- Dropped support for `send_email_when_published` in API
- When importing posts we currently don't have a system in place to set the newsletter_id to map the `send_email_when_published` behaviour. Since this was already the case, I won't include a fix in this PR.
- Stripped `email_recipient_filter`/`email_segment` from Content API (https://ghost.slack.com/archives/C02G9E68C/p1652363211841359?thread_ts=1650623650.233229&cid=C02G9E68C)
- Updated `admin-api-schema` to 3.2.0, which includes the new email_segment property
- Contains a temporary fix for https://github.com/TryGhost/Team/issues/1626, where the `.related('newsletter').fetch` call fails when the newsletter relation is already loaded, because of the overridden `formatOnWrite` method.

Since the `email_recipient_filter` is no longer used without a newsletter, the `none` value is no longer used. A migration transforms all those values to `all`. This should be safe, because we only send an email now when newsletter_id is not null (scheduled posts should already have a newsletter_id, even if at the time of scheduling they didn't add the newsletter_id option, because at that time, we defaulted to the default newsletter).

Admin changes to make this work: https://github.com/TryGhost/Admin/pull/2380
2022-05-16 10:18:04 +02:00
Hannah Wolfe
37818a1b71
Removed settings that are no longer in use (#14802)
refs: TryGhost/Team#1625
refs: TryGhost/Team#1558

- none of these settings are actively used anymore

Co-authored-by: Daniel Lockyer <hi@daniellockyer.com>
2022-05-13 21:19:21 +01:00
Hannah Wolfe
dec6a4d72a Removed unused getPaymentConfig method
refs: https://github.com/TryGhost/Team/issues/1625

- this references unused stripe_product_name setting and defunct stripe_plans setting, but is not used anywhere
2022-05-12 20:05:10 +01:00
Hannah Wolfe
a58ac016be
Swapped setup to use tiers API endpoint
refs: https://github.com/TryGhost/Team/issues/1145

- the products endpoint is going away in favour of tiers
2022-05-12 19:48:27 +01:00
Hannah Wolfe
b6d9389124
🔥 Removed legacy product + price helpers from themes
refs: https://github.com/TryGhost/Team/issues/1145
refs: https://github.com/TryGhost/Ghost/issues/14446

- remove legacy members theme helpers @products @product @price and @members.products
- all of these have been replaced with new concepts with the introduction of tiers
2022-05-12 18:58:01 +01:00
Rishabh Garg
afd92813c8
Added subscribe_on_signup to newsletter content API data (#14808)
- portal needs this to show default newsletter subscription during signup
2022-05-12 21:31:50 +05:30
Hannah Wolfe
962971c436
🔥 Removed members/api/site
closes: https://github.com/TryGhost/Team/issues/1599

- remove the now unused members/api/site endpoint
- portal now talks to the content API instead
2022-05-12 16:21:47 +01:00
Matt Hanley
0d379a9264 Added permissions for Authors to read labels
refs https://github.com/TryGhost/Team/issues/1618

- Authors require access to labels as part of the publish + send workflow
2022-05-12 16:07:05 +01:00
Hannah Wolfe
de118b0b04
Renamed lang and session_secret default settings (#14791)
refs: https://github.com/TryGhost/Toolbox/issues/327

- lang / locale has had a lot of churn, but we decided this setting should always be locale
- session_secret is too generic as we have multiples of these
2022-05-12 15:07:05 +01:00
Matt Hanley
1fabd76391 Added newsletter permissions for Editors and Authors
refs https://github.com/TryGhost/Team/issues/1618

- Editors and Authors require read access to newsletters as part of the publish + send workflow
2022-05-12 14:46:55 +01:00
Matt Hanley
78d1132b13
Updated theme card asset default setting (#14789)
refs https://github.com/TryGhost/Team/issues/1611

- For Ghost 5.0 card assets will be included by default, including bookmark and gallery cards
2022-05-12 14:44:31 +01:00
Naz
7252f03824 Improved assertions
refs https://github.com/TryGhost/Toolbox/issues/283
2022-05-12 13:54:21 +08:00
Naz
a1e1feb125 Added 'Content-Version' header to outgoing webhook requests
refs https://github.com/TryGhost/Toolbox/issues/283

- The header is needed to signal to the webhook subscribers the content version they are being served. This should imrove API version compatibility and allow for the client to handle incoming data better
2022-05-12 13:54:21 +08:00
Naz
2a3be178ab Refactored trigger test to us assert instead of should
refs https://github.com/TryGhost/Toolbox/issues/283

- Should assertion library is outdated and it's preferred to use native assert to make assertions
2022-05-12 13:54:21 +08:00
Naz
21c2c5579b Refactored webhook triggering to be asyc
refs https://github.com/TryGhost/Toolbox/issues/283

- In tests we need assurance that the triggering of webhooks has been finished before making assertions. Doing this was impossible with a previous fire-and-forget style of the request call.
- The change also adds an optional "request" parameter to be able to override the request library used internally - this is purely for testing purposes.
2022-05-12 13:54:21 +08:00
Naz
67dca08df8 Refactored trigger module to be testable
refs https://github.com/TryGhost/Toolbox/issues/283

- Current trigger module handling webhook paypload delivery isn't testable! It sucks to add features to it without assurance things still work
- Apart from expanding the test suite this changeset also needs live testing - setting up webhooks etc.
2022-05-12 13:54:21 +08:00
Rishabh Garg
3836030950
Allowed tiers include and data for member endpoints (#14790)
refs https://github.com/TryGhost/Team/issues/1145

- allows members endpoint to accept `?include=tiers`
- allows members endpoint to return `tiers` data
2022-05-11 22:26:03 +05:30
Hannah Wolfe
409dc3b534
Added frontend key to ghost_head for portal (#14782)
refs: https://github.com/TryGhost/Team/issues/1599
refs: f3d5d9cf6b

- this commit adds the concept of a frontend data service, intended for passing data to the frontend from the server in a clean way. This is the start of a new & improved pattern, to hopefully reduce coupling
- the newly added internal frontend key is then exposed through this pattern so that the frontend can make use of it
- the first use case is so that portal can use it to talk to the content API instead of having weird endpoints for portal
- this key will also be used by other internal scripts in future, it's public and therefore safe to expose, but it's meant for internal use only and therefore is not exposed in a generic way e.g. as a helper
2022-05-11 17:34:31 +01:00
Rishabh Garg
9f85f7a4fe
Added newsletters endpoint to Content API (#14778)
refs https://github.com/TryGhost/Team/issues/1599

- allows active newsletters data to be fetched via content API
2022-05-11 21:36:43 +05:30
Hannah Wolfe
b29852b012
🔥 Removed support for http/https mixed mode (#14783)
closes: https://github.com/TryGhost/Toolbox/issues/324
refs: https://github.com/TryGhost/Ghost/issues/14446

- Currently, if url is configured to http but a request is marked secure, Ghost will handle upgrading all internal URLs to https so that there are no mixed content warnings
- From 5.0 that feature is going away, in favour of strictly honouring the configured URL
- Ghost will serve URLs exactly as configured and won't upgrade http to https anymore
- This use case was common when Ghost was first built, but in 2022 the web is mostly https.
- The code needed to support the feature creates a lot of additional complexity & maintenance overhead, so removing this gives us space to do more cool and useful stuff in 2022
2022-05-11 14:53:23 +01:00
Daniel Lockyer
84a10daebf
🏗 Dropped webhooks.status column (#14713)
refs https://github.com/TryGhost/Toolbox/issues/309

- this column is not used and I was going to add `validation` to it but
  it's better to clean it up and re-add the column if we need it again
2022-05-11 14:11:47 +01:00
Hannah Wolfe
c5ba27e2b5
Added initial concept of calculated settings (#14766)
refs: https://github.com/TryGhost/Team/issues/626

- calculated settings are simplified settings (booleans) that are based on other settings or data
- they make it easier for us to determine what state features are in elsewhere in ghost e.g. admin and themes
- this duplicates some of the members config concepts in the settings service
2022-05-10 21:49:38 +01:00
Aileen Nowak
56a1143e53 Fixed incorrect usage of limit config causing Ghost not to boot
no issue

- When applying an incorrect limits config, or missing expected values, Ghost would not boot as the errors would interrupt this process, which should not happen
- This commit catches the error thrown by the limit-service on boot sequence and transforms it into a warning if it's an `IncorectUsageError`. Other errors are handled as before
- Added a test for the limit-service service
2022-05-10 15:47:45 -04:00
Hannah Wolfe
ddb718f0bb
Fixed settingsCache returning falsy as null
refs: e68cb8b314

- a couple of months ago when improving the test coverage here I found some weird behaviour with falsey values
- turned out it didn't matter at the time because we didn't have any settings that are false
- with the introduction of calculated settings we will have: https://github.com/TryGhost/Ghost/pull/14766
- whilst building that, I found settings that should be returned as false were being returned as null
- fixing it in a separate commit to keep the work clean
2022-05-10 20:37:03 +01:00
Hannah Wolfe
b911c66bb6
Fixed legacyApiPathMatch not working with subdirs
- The recently refactored path matching code forgot to take into account that originalUrl can include the subdir
- Added more permutations to tests and ensured that all tests pass
- This means we don't have to worry about what sort of path we pass to the function, it'll figure out the version and api info
2022-05-10 13:57:06 +01:00
Hannah Wolfe
f3d5d9cf6b Added internal frontend integration
refs: https://github.com/TryGhost/Team/issues/1599

- add an internal integration for Ghost's frontend to talk to the content API
- this is so that portal and future features can access our APIs through the correct mechanism of an API key
2022-05-10 11:43:07 +01:00
Daniel Lockyer
98a8fa8b0d Dropped temp_member_analytic_events table
refs https://github.com/TryGhost/Toolbox/issues/309

- this table was used an an experiment for member analytics
- as we rethink the strategy, we can take the opportunity to clean the table up
2022-05-10 10:00:19 +01:00
Daniel Lockyer
c8d6024a0c Dropped subscribed column in members table
refs https://github.com/TryGhost/Toolbox/issues/309

- this column is now a calculated value based upon the relation of a
  member to a newsletter
- we should no longer need `subscribed`, so this migrations cleans up
  the column in the DB
2022-05-09 16:47:43 +01:00
Rishabh Garg
4d6b3568c5
Enabled Admin integration for newsletters API (#14714)
refs https://github.com/TryGhost/Team/issues/1546

- allows newsletters API to work with Admin API keys
- updates fixtures to add permissions to admin integration role for new sites
- adds migration to update existing sites to have correct permissions for role
- whitelists add/edit/read/browse on newsletters API for integrations
2022-05-09 20:46:34 +05:30
Daniel Lockyer
f48a668671 Removed unused defaults from text columns in schema
refs https://github.com/TryGhost/Toolbox/issues/309

- I originally started looking at this because I wanted to change the default of
  `emails.recipient_filter` for old DBs to `status:-free`
- we changed these columns to a `text` type, which doesn't support
  defaults
- the tables already have defaults set in the model, so the only change
  needed here is to delete the `defaultTo` in the schema to avoid
  confusion
- on the way, I ended up fixing 51498abb5c too
2022-05-09 14:31:35 +01:00
Daniel Lockyer
1c12557c46 🏗 Dropped oauth table
refs https://github.com/TryGhost/Toolbox/issues/309

- we're removing the OAuth prototype and the table was never used, so we
  should be good to drop it
- this commit adds a migration to drop the table
2022-05-09 14:18:01 +01:00
Naz
d804366b44 Removed outdated comment
refs https://github.com/TryGhost/Toolbox/issues/230

- The author_id column has been removed, it should not appear across the codebase in post context any longer
2022-05-09 20:34:06 +08:00
Naz
945345d990 Removed permissions handling of "author_id"
refs https://github.com/TryGhost/Toolbox/issues/230

- Single author logic can be removed as we dropped `author_id` column from the post model
2022-05-09 20:34:06 +08:00
Naz
d4f10e8fa3 Added test coverage for fixture manager
refs https://github.com/TryGhost/Toolbox/issues/230
2022-05-09 20:34:06 +08:00
Naz
9821c3785e Fixed multiple author fixture initializaion
refs https://github.com/TryGhost/Toolbox/issues/230

 - The fixture manager has to initialize User/Roles fixtures first to be able to insert multiple authors as a relation in post fixtures. Otherwise the posts could not find correct authors and were failing trying to assign default "owner user" to each post
- The order of running fixtures matters, and till now the order wasn't taken into account at all when populating the db
2022-05-09 20:34:06 +08:00
Naz
6a42c1fa3b Fixed validator test as author_id does not exist anymore
refs https://github.com/TryGhost/Toolbox/issues/230

 - No column - no validation!
2022-05-09 20:34:06 +08:00
Matt Hanley
62164ecdf2
Added gravatar URL to config to make it configurable (#14490)
refs https://github.com/TryGhost/Toolbox/issues/288

- Allows switching out the Gravatar URL to use placeholder images when working with mocked demo data
2022-05-09 12:44:04 +01:00
Matt Hanley
a43ab8445d 🐛 Fixed importing posts with a newsletter assigned
refs https://github.com/TryGhost/Team/issues/1595

- Since adding multiple newsletters, posts may be linked to a related newsletter
- We don't export newsletters, so the related newsletter_id doesn't exist and fails the FK check on import
2022-05-06 16:36:35 +01:00
Rishabh Garg
0694e016e0
Excluded newsletter's sender email value when importing (#14706)
refs https://github.com/TryGhost/Team/issues/1529

- the sender email addresses for newsletters require verification to set.
- this ensures there isn't a way around that by modifying an export file then importing it by setting it to null on import.

This pattern is similar to the current `members_from_address` setting which is excluded when importing.
2022-05-06 12:45:10 +05:30
Hannah Wolfe
6dc3f1bf56
Removed versioning from api-key/admin auth
refs: https://github.com/TryGhost/Toolbox/issues/229

- our api-key audience handling code is still relying on internal api version config
- the regex used is also buggy (it expects 3 parts, which isn't true without versions) and doesn't always match, in which case it can cause the tests to hang
- we already had some very similar code in the version-rewrite middleware which is also validates exact values for version and api type
- moved this code into a util inside api-version-compatibility-service
- using this code, all the tests still pass as is, but when I start to adjust them to cover more cases, none hang (test changes coming in a separate commit)
2022-05-06 08:09:54 +01:00
Hannah Wolfe
829261f04f
Added tests for version-rewrites
- Now that the code is split out it's super easy to unit test.
- I was being lazy before :)
2022-05-05 19:13:51 +01:00