Commit Graph

10696 Commits

Author SHA1 Message Date
Naz
f5f1221e14 Removed output of "page" attributes from APIs
refs 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
Kevin Ansfield
27337e5f00
Added newsletter param to email preview endpoint (#14820)
refs https://github.com/TryGhost/Team/issues/1621

We want to allow previewing emails based on the selected newsletter. The post model doesn't get a newsletter attached until a publish occurs so we can't use `post.newsletter` and need to give the option of specifying which newsletter to preview via query params.

- added support for `newsletter` query param on the `GET /email_previews/posts/:id/` endpoint where the value is a newsletter slug
- updated `generateEmailContent()` signature to use an options object because the order of memberSegment/newsletter arguments doesn't matter and is difficult to reason about if not named
- adjusted `generateEmailContent()` to fetch the newsletter matching the provided slug, falling back to the default newsletter if no slug is provided
2022-05-16 12:15:54 +01:00
Hannah Wolfe
3f0172e755 Removed backwards compatibility for slack setting
refs: https://github.com/TryGhost/Team/issues/1625

- we changed slack to be two separate settings some time ago
- this cleans up the compatibility code
2022-05-16 11:38:59 +01:00
Daniel Lockyer
93339b3e42
Removed unused code for logging in MySQL lib
- `mysql2` doesn't support this and we haven't had it enabled for a long time
- if we need this feature, we can re-add it with a working implementation
2022-05-16 10:53:08 +01: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
Hannah Wolfe
f73a84abac Update dependency html-to-text to v8
refs: https://github.com/TryGhost/Ghost/pull/13035
refs: https://github.com/TryGhost/Team/issues/1609

- Upgraded to the latest html-to-text
- Matched the options to what we had as close as we can
- The output changes slightly, but in most cases those are bugfixes
- We are going to tune this output more soon, so accept the changes for now
2022-05-16 09:38:16 +01:00
Hannah Wolfe
f436d23f87 Removed 80 char wordwrap in excerpts
refs: https://github.com/TryGhost/Team/issues/1609

- remove the 80 char wordwrap
- this makes the function the same as used in the post serializer
- updated references everywhere to use the same function
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
705a72431d
Removed GET settings/:key route
refs: https://github.com/TryGhost/Team/issues/1625

- there's not really a usecase for this route, so removing so we don't have to maintain it
2022-05-13 23:18:53 +01: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
Rishabh Garg
96bb441fb3
Removed unused frontend offer endpoint (#14816)
refs https://github.com/TryGhost/Team/issues/1599

- portal now uses offer content api to read offer details from id
2022-05-13 17:20:09 +05:30
Simon Backx
a95e9d0b7b
Fixed error in newsletter editing limit checks (#14817)
refs https://github.com/TryGhost/Team/issues/1583
refs https://ghost.slack.com/archives/C02G9E68C/p1652397268702749?thread_ts=1652397192.822389&cid=C02G9E68C

Used `model.status` instead of `model.get('status')`, resulting in undefined, resulting in `!== 'active'` to return true. Also added a test case for editing active newsletters.
2022-05-13 10:15:35 +02:00
Hannah Wolfe
ef79f4eae9
Fixed lint error
refs: 8d30eeb515
refs: https://github.com/TryGhost/Ghost/pull/14806

- somehow this didn't flag up in the PR...
2022-05-13 05:09:14 +01:00
Hannah Wolfe
8d30eeb515 Removed usage of members_paid/free_signup_redirect
refs: https://github.com/TryGhost/Team/issues/1625

- removed code using settings that are about to be removed
2022-05-12 20:05:10 +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
403b311f54 Removed unused getPublicPlans method
refs: https://github.com/TryGhost/Team/issues/1625

- this method makes use of defunct settings
2022-05-12 20:05:10 +01:00
Hannah Wolfe
cd20738d65 Removed support for editing members_from_address
refs: https://github.com/TryGhost/Team/issues/1625
refs: https://github.com/TryGhost/Team/issues/1558

- the members_from_address setting is no longer used, instead we use newsletters from address
2022-05-12 20:05:10 +01:00
Hannah Wolfe
5cc7a54edc
Replaced Products with Tiers API endpoints
ref: https://github.com/TryGhost/Team/issues/1145
ref: 8f8b7e7364

- The /products/ endpoint was replaced with /tiers/ some time ago but we didn't finish the switch
- The work is complete now, so can remove the endpoint entirely and cleanup remaining usages
2022-05-12 19:59:57 +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
ad9e916700
Removed @blog from theme globals
closes: https://github.com/TryGhost/Toolbox/issues/231
refs: https://github.com/TryGhost/Ghost/issues/14446

- @blog was deprecated before Ghost 3.0, but we're only just removing it now for 5.0
2022-05-12 16:00:00 +01:00
Rishabh Garg
e44d089dbe
Updated portal initilization and multiple newsletter handling (#14803)
- portal now uses content API to load site data
- handles auto unsubscribe for multiple newsletters
- design refinements
- more test coverage
- better fixtures
2022-05-12 20:26:31 +05:30
Rishabh Garg
f4066067e4
Extended public settings to include portal settings (#14801)
refs https://github.com/TryGhost/Team/issues/1599

- adds `portal_*` settings to public settings endpoint
- adds calculated `firstpromoter_account` setting for public settings endpoint
- also adds Ghost `version` information
2022-05-12 19:54:45 +05:30
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
Rishabh Garg
725c2673ea
Added offer read endpoint to content API (#14794)
refs TryGhost/Team#1599

- allows offer details to be fetched via content API directly
2022-05-12 18:16:10 +05:30
Simon Backx
3214186f98
Improved newsletter limit checking (#14780)
refs https://github.com/TryGhost/Team/issues/1583

- Check limits when unarchiving newsletters
- Added tests for more scenarios
- When editing/adding newsletters, the limit check happens in the same transaction.
- `limit-service` was bumped to add transactions support
- Added transaction support for edit in newsletter service
2022-05-12 14:28:45 +02:00
Matt Hanley
371f9996f5
Fixed filter mapping from subscribed to newsletters for bulk operations (#14787)
closes https://github.com/TryGhost/Team/issues/1606

- Fixed filter mapping from subscribed to newsletters for bulk operations
- Updated members-api package
2022-05-12 10:54:20 +01:00
Naz
d3f432f745 🔥 Removed versioning from json schema validation
refs https://github.com/TryGhost/Toolbox/issues/314

- With versioned API concept being dropped there's no need to rely on a specific version in validations either!
2022-05-12 16:08:23 +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
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
Matt Hanley
2c770c4455 Added Admin integration permissions for retrieving and managing newsletters
refs https://github.com/TryGhost/Toolbox/issues/238#issuecomment-1124024042

- Admin integrations require access to managing newsletters to prevent a regression in Zapier capability
2022-05-11 18:34:33 +01: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
2e8c66d93c Cleaned enforced filter logic for newsletters model
- removes ambiguity from the logic
2022-05-11 21:39:33 +05:30
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
Simon Backx
837e11b4d8
Fixed email preview using wrong newsletter (#14756)
refs https://github.com/TryGhost/Team/issues/1603

When previewing a scheduled/published post via Post editor menu > E-mail newsletter > Preview in browser. The e-mail template from the default newsletter was used instead of the newsletter that was selected when scheduling the post.
2022-05-11 17:52:24 +02:00
Simon Backx
23c88d250e
Readded notEnoughPermission message in post model (#14759)
no issue

The message was removed somewhere, but the git history looks to be modified so I couldn't find the reference to when and why it was removed (the message seems to be added and removed in the same commit).

Added in: e849167472
No reference to where it was removed. But after the same commit above, it wasn't present any longer.
2022-05-11 17:52:06 +02:00
Hannah Wolfe
196b8ad0da
Removed active_timezone, default_locale & locale compat (#14788)
- These settings no longer exist, having been renamed to timezone and lang
- As of 5.0 we no longer need any kind of backwards compatibility outside of the importer
- We making breaking changes and cleaning up as many old code paths as possible 
- We have not really exposed the admin Settings API, meaning backwards compatibility was more for internal use
- We will be changing lang back to locale, but that's a separate issue and won't need backwards compatibility
2022-05-11 16:22:25 +01:00
Matt Hanley
ae45579903 Promoted feature flags for v5 features to GA 2022-05-11 15:55:15 +01:00
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
412d290a30
Refactored async helpers to use async/await (#14781)
- async/await makes the code easier to read
- also means we can get rid of usages of Promise, and some unnecessary usages of Bluebird
- this refactor is done for the 4 async helpers and the code that wraps async helpers so the whole pipeline is async/await and more understandable
2022-05-11 09:51:38 +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
Hannah Wolfe
54b4a3c351
Renamed settings index.js to settings-service.js
- in line with our policy of not keeping logic in index.js files
- Note: callign all services service.js is no more helpful :D
2022-05-10 20:55:31 +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
Daniel Lockyer
1c7d4e49c5
Disabled model auto-refresh when processing email batches
- by default, the model will auto-refresh when you save
- in MySQL, which doesn't support RETURNING, this is implemented by
  doing a SELECT after your actual query
- `email_recipients` is a huge table and `processed_at` is not an
  indexed column, so the query times can become realllyyyyyyy big
- given we don't even need the result of the model save, we can just
  disable fetching all the affected records again
- Bookshelf gives us this ability in the form of `autoRefresh: false`
2022-05-10 18:11:15 +01:00
Daniel Lockyer
bb9a797283 Regenerated HTML for posts containing a product or video card
refs https://github.com/TryGhost/Toolbox/issues/309
refs https://github.com/TryGhost/Ghost/issues/14344

- this migration will regenerate the HTML for posts that contain a
  product or video card as we experiencing a bug in the card generation
- this migration is mostly ripped from c0d82122b0/core/server/data/migrations/versions/4.0/23-regenerate-posts-html.js
2022-05-10 18:05:27 +01:00
Daniel Lockyer
ada0e7975b fixup! Added validation to posts status column 2022-05-10 18:05:18 +01:00
Daniel Lockyer
66652b6ea9 Added validation to posts status column
refs https://github.com/TryGhost/Toolbox/issues/309

- this commit adds `isIn` validation to the `status` column on the
  `posts` table, with values pulled from the model: c0d82122b0/core/server/models/post.js (L28)
- this also adds a migration to update any posts with invalid statuses
  to `draft`
2022-05-10 18:05:18 +01:00
Daniel Lockyer
ca82914052 Removed client and subscriber permissions
refs https://github.com/TryGhost/Toolbox/issues/309

- these stopped being added to the DB in v3 but there was never a
  migration to clean up existing permissions and the role link in the DB
- we now have the utils to do this cleanly, so we can drop all the
  permissions in this migration
2022-05-10 18:05:06 +01:00
Daniel Lockyer
5384944fa4
Added log line before updating user statuses
- this makes it obvious where we are in the flow and its clear we're
  inside this migration if we see that log line
2022-05-10 16:46:33 +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
Daniel Lockyer
b7b4f8d1d1 Added migration utils for removing a permission
- this will drop the link between a role and a permission, and then
  delete the permission
- required minor refactoring to aid in creating migrations for dropping
  the links and permission
2022-05-10 13:21:26 +01:00
Daniel Lockyer
bf28721844 De-duped MIGRATION_USER constant across migration utils
- we shouldn't declare this in more than one place, even if it is a
  weird concept anyway
2022-05-10 13:05:47 +01:00
Daniel Lockyer
1c440e14b1 Split apart migration utils into separate files
- this should help organize the code a little better and frees us up to
  turn it into a separate package in the future
2022-05-10 13:05:47 +01:00
Daniel Lockyer
892408e1cd Moved migration utils.js to subfolder
- this helps makes way for splitting the file apart to make the utils
  easier to write
2022-05-10 13:05:47 +01:00
Daniel Lockyer
3b860c9b0d Switched use of migration utils to folder
- I'm refactoring the utils to make way for dropping permissions but the
  utils are in a real mess
- to aid my refactoring, I want to make the utils a folder, so the
  migrations that require utils as a file need updating
- this commit does that
2022-05-10 13:05:47 +01:00
Simon Backx
f732b0181d
Fixed last_seen updated for suspended users (#14715)
refs https://github.com/TryGhost/Team/issues/1461

- A suspended user was able to make it through the Express middlewares to the `updateUserLastSeen` middleware, until it was halted when checking the user permissions in the API pipeline. This was only the case for session logins, not for API keys.
- For API keys, the user status is checked:
6dc3f1bf56/core/server/services/auth/api-key/admin.js (L178-L181)
- In the session middleware, the `findUserById` in `getUserForSession` didn't filter on the active status of users:
be4146e324/core/server/services/auth/session/middleware.js (L22-L27)
- This has been fixed now by updating the sessionService's `findUserById` method.
2022-05-10 13:34:12 +02: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
b794c6885e Deleted membersActivity flag
refs https://github.com/TryGhost/Toolbox/issues/325

- this was used for an alpha proof-of-concept for member activity data
  collection but we're rethinking the strategy so this is the easiest
  way to ensure it can't be enabled when the database table has been deleted
2022-05-10 11:19:58 +01:00
Naz
6934595053 Added Integration Name in version mismatch emails
refs https://github.com/TryGhost/Toolbox/issues/292

- Providing user-defined Integration name instead of API client's UserAgent gives a lot more control to instance administrators identifying which integration is being used incorrectly.
- It's best practice to create an Integration with a set of API keys per API client - which should be enough to identify an outdated one.
2022-05-10 17:55:18 +08:00
Naz
6cca515eae Fixed typo 2022-05-10 17:44:58 +08: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
Fabien "egg" O'Carroll
6d48846f15 Fixed ESLint warnings 2022-05-09 17:13:07 +01:00
Daniel Lockyer
aed7ef0cae
Altered wording in migration utils
- if the table doesn't exist, it's not necessarily a failure that we
  should be informing the user about
- this brings the message wording in line with other log lines of
  similar operations
2022-05-09 16:49:28 +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
Simon Backx
5657019e47
Fixed wrong newsletter used when sending scheduled post (#14734)
refs https://ghost.slack.com/archives/C02G9E68C/p1651939076681719

Cause:
- When a scheduled post was published via the post scheduler, no `newsletter_id` option is passed when editing the post.
- When editing a post via the posts service, without the `newsletter_id` option, the `newsletter_id` option is automatically set to the default newsletter's id.
- Inside the post model, this new `newsletter_id` was not saved, because it was already set, and changing it is prevented.
- The `mega` service wasn't using the (unchanged) post's newsletter_id, but used the option instead, which contained the default newsletter's id.

Fix:
- Always using the newsletter_id from the post and requiring the newsletter associated with a post to exist.
- This behaviour can be/is tested by publishing a scheduled post without any option.

Also cleaned up some `Object.assign` usages.
2022-05-09 17:30:50 +02: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
e10f33e30f Added users.status validation to the schema
refs https://github.com/TryGhost/Toolbox/issues/309

- this commit adds a validation array of valid user `status` values to
  the schema
- this also includes a migration to update users with invalid statuses
  to `inactive`, which I've seen with `invited` and `invited-pending`
  statuses that pre-dated proper invitations
- this also deletes tests that were wrong and written 7 years ago before
  invites was added
2022-05-09 16:13:44 +01:00
Daniel Lockyer
fce17d714e
Removed subscribed from email recipient filter validity check
- `subscribed` will soon cease to be a column on a member and I get errors
  in tests that stem from this block of code because it no longer exists
- AFAICT this block of code is only used to verify the filter is valid
  to filter on, which we should be able to do even if we remove
  `subscribed`
- this commit removes `subscribed` from the filter
2022-05-09 15:46:22 +01:00
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
Daniel Lockyer
63f62c3302 Migrated old recipient filters to NQL string format
refs https://github.com/TryGhost/Toolbox/issues/309

- we started off with "free" and "paid" in these columns but since moved
  to NQL strings
- there is code in Ghost to rewrite these values to NQL strings, but we
  still have posts/emails in the DB with these old values so they need
  to be updated
- once this migration is merged, we can probably clean a lot of that
  aliasing up
- this commit migrates values in `posts.email_recipient_filter` and
  `emails.recipient_filter` from `free` to `status:free` and `paid` to
  `status:-free`
- I've left the down as a no-op because we don't want to translate
  values back, and we don't know which ones we originally migrated in
  the first place
2022-05-09 13:43:46 +01: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
36e54656b6 Removed unnecessary model handling of single authors
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
69bf4ba92b Removed a comment about single author usecase
refs https://github.com/TryGhost/Toolbox/issues/230

- We no longer have/support `author_id` in the code, so the usecase was outdated
2022-05-09 20:34:06 +08:00
Naz
15951aa1d5 Removed unneeded author_id cleanup
refs https://github.com/TryGhost/Toolbox/issues/230

- As the `author_id` column is gone there's no need to cleanup the posts table when reassigning user's posts
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
e8f20e5f12 Removed creation of single author on post creation
refs https://github.com/TryGhost/Toolbox/issues/230
2022-05-09 20:34:06 +08:00
Naz
efc443a8d1 Removed author_id as a default fetched column for posts
refs https://github.com/TryGhost/Toolbox/issues/230

- The column has been dropped from schema and would not be necessary in the post's model
2022-05-09 20:34:06 +08:00
Naz
2f98ad68ba Removed author_id useage form fixtures
refs https://github.com/TryGhost/Toolbox/issues/230

 - The column has been dropped form shema, so should not be used in fixtures either
2022-05-09 20:34:06 +08:00
Naz
6d17d28d1a 🏗 Removed author_id column from the posts table
refs https://github.com/TryGhost/Toolbox/issues/230

- This is a first step to removal of `author_id` concept from the codebase. The aim is to see what parts break down from this changes an work backwards from there
2022-05-09 20:34:06 +08:00
Naz
b2db80c9fe Fixed missing failed request URL if version emails
refs https://github.com/TryGhost/Toolbox/issues/292

- The version mismatch notification emails were missing a URL of the endpoint that was being accessed by an outdated integraton
- Also squeezed in a refactor simplifying APIVersionCompatibilityService initialization
2022-05-09 20:11:25 +08:00
Matt Hanley
e5c5661701
Assigned existing email records and related posts to the default newsletter (#14695)
refs https://github.com/TryGhost/Team/issues/1571

- With the addition of multiple newsletters, all emails sent previously should be assigned to the default newsletter
- This will make sure that the sent count for the default newsletter displays correctly
2022-05-09 12:48:24 +01:00
Fabien 'egg' O'Carroll
895ffee90b
Added Dashboard 5.0 migrations (#14716)
refs https://github.com/TryGhost/Team/issues/1515
refs https://github.com/TryGhost/Team/issues/1516
refs https://github.com/TryGhost/Team/issues/1455

The updates the `mrr` column for subscriptions and the `mrr_deltas` for events
so that both Offers and canceled Subscriptions are correctly handled.

We must apply the canceled Subscription changes after the Offers, so that they
interact correctly, and that the `mrr` column has the necessary data for each migration.

Co-authored-by: Simon Backx <simon@ghost.org>
2022-05-09 12:46:46 +01: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
Daniel Lockyer
d8e58b53d0
Altered migration utility to always use algorithm=copy for MySQL (#14699)
refs https://github.com/TryGhost/Toolbox/issues/309
refs 2bfd8f8b7e

- we've previously had issues when dropping a column on `posts`
  because it's a large table and it can take a veeeeeeery long time with
  the default SQL produced by Knex
- we found a magic incantation that makes it super speedy (context in
  commit above) => `, algorithm=copy`
- for that migration, we did it all manually but we can now change the
  utility to always append this to the generated SQL so we don't have to
  think about the specific table size when adding or dropping columns
- this changes the `addColumn` and `dropColumn` utilities to append the
  string to SQL in MySQL, or just executes the SQL for SQLite
2022-05-09 10:16:36 +01:00
Simon Backx
21d9d20e3e
Included newsletter relation by default in posts (#14723)
refs https://github.com/TryGhost/Team/issues/1569

**Changes in admin-api-schema:**
- https://github.com/TryGhost/SDK/compare/%40tryghost/admin-api-schema%402.14.1...%40tryghost/admin-api-schema%402.15.0
- Ignore `newsletter` when used in input

**Changes**
- Added the `newsletter` relation as a default include for posts
- Removed the newsletter_id from the API output

**Tests**
- Test the newsletter relation is always loaded for browse, read, add and edit, unless the include option is added explicitly

Co-authored-by: Matt Hanley <git@matthanley.co.uk>
2022-05-09 11:06:59 +02:00
Simon Backx
96e7187e8d
Fixed members CSV export not filtering on subscribed (#14721)
refs https://ghost.slack.com/archives/C02G9E68C/p1651851268912299?thread_ts=1651848216.832419&cid=C02G9E68C

- When exporting members to CSV the subscribed filter was not working correctly
- Fixed by also applying the NQL mapping to the export endpoint
- This also changes the order of the members in the CSV export to match the order in admin/browse endpoint
2022-05-09 10:56:36 +02:00
Rishabh
95fc22e6fe Refined newsletter import sanitisation
refs https://github.com/TryGhost/Team/issues/1529

- simplifies the sanitisation method to delete ignored columns
2022-05-09 12:32:25 +05:30
renovate[bot]
abd90be910
Update dependency @tryghost/mw-error-handler to v1 (#14719)
- Replaced usage of handleJSONResponseV2 with the newly renamed handleJSONResponse

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
2022-05-07 15:28:28 +01:00
renovate[bot]
e0ce8995a7
Update dependency @tryghost/security to v0.3.0 (#14718)
- Swapped instances of createSecret for security.secret.create

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
2022-05-06 17:53:10 +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
Hannah Wolfe
401fe46380
Changed webhooks to store safe version
refs: https://github.com/TryGhost/Toolbox/issues/229

- We're getting rid of the concept of api versions inside of Ghost
- Instead of storing the supposed api version a webhook was created with, store the current ghost version
- This way we can determine if anything signicant changes in future and we need to update webhooks or something
2022-05-06 12:43:14 +01:00
Hannah Wolfe
865d57c4be
Removed api:versions from config
refs: https://github.com/TryGhost/Toolbox/issues/229

- Removed the final usage (logging only) of config.get('api:versions') and removed the config
- This is one of the last references to API versioning in the codebase & we don't need it anymore
- Cleaned up a random comment whilst searching for refs
2022-05-06 08:22:05 +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
renovate[bot]
9aa8e3e7ff
Update dependency @tryghost/url-utils to v3 (#14705)
- updated usage of url-utils.urlFor to work with v3

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
2022-05-05 16:10:18 +01:00
Naz
dde9a5462a Moved the version rewrite middleware to a module
refs https://github.com/TryGhost/Toolbox/issues/315

- There's enough logic in the middleware to become it's own module and maybe even get extracted to an external module
2022-05-05 22:18:40 +08:00
Matt Hanley
8e1c10d146
Updated migration to always set a value
- When both parameters passed to `update` resolve to `undefined` we throw an `Empty .update() call detected` error
- This change always updates the `sender_email` to null rather than skipping the field
- `sender_reply_to` should still be `undefined` so we don't override an existing non-null value
2022-05-05 15:11:44 +01:00
Fabien 'egg' O'Carroll
e65d335c76
Fixed types for migration utils (#14709)
`import('knex')` does not refer to the type of an instantiated Knex instance.
2022-05-05 15:01:22 +01:00
Daniel Lockyer
51498abb5c
Fixed model validation erroneously triggering on non-nullable text fields
refs https://github.com/TryGhost/Toolbox/issues/309

- I've just ran into a problem when deleting the `defaultTo` field on a
  non-nullable `text` column in our schema because this validation
  thinks there should be a value set
- `text` fields cannot have defaults so the schema is incorrect, and the
  validation triggering is a bug that's preventing it from being
  cleaned up
- the default is defined on the model so I don't think we're losing
  anything here
2022-05-05 14:56:59 +01:00
Hannah Wolfe
a22879824b
Disabled lint on api-version-compat service temporarily
- We're in the process of bringing this service together
- It needs refactoring, and that will move most of the code back to utils
2022-05-05 12:46:19 +01:00
Naz
648530009d Added use of email templates for version mismatch notifications
refs https://github.com/TryGhost/Toolbox/issues/292

- This change allows to reuse existing pattern present in Ghost on the version mismatch service layer, where we define the contents of the sent email through email templates instead of plain text.
- Apart form templates, there's now failed request URL present in the data passed to the email template along with site title and site url
2022-05-05 18:26:08 +08:00
Simon Backx
38b9cf2472
Fixed newsletter includes when adding or editing (#14696)
refs https://github.com/TryGhost/Team/issues/1571
refs https://ghost.slack.com/archives/C02G9E68C/p1650986988322609

- Makes sure the includes are always included
- Moved read to the newsletter service
- Added tests
- Updated unit tests to work with multiple findOne calls
- Fixed reject assertions not correctly awaiting in unit tests
2022-05-05 11:20:15 +02:00
Simon Backx
366a7be36d 🐛 Fixed newsletters' header_image saved as absolute url (#14690)
refs https://github.com/TryGhost/Team/issues/1579

- When writing to the database, the header_image is tranformed to the transformReady path
- When reading from the database, the transformReady path is transformed to an absolute path
- Includes a test when adding a newsletter

Migration:
- Updates all newsletter who have a header_image to make sure it is saved in transform ready format
- Down operation is required to work with the old model logic and transforms it back to an absolute format
2022-05-05 09:44:03 +01:00
Matt Hanley
9371f6fd24 Migrated previous email sending settings to newsletters
refs https://github.com/TryGhost/Team/issues/1581

- The original migration to create the default newsletter omitted the from address and reply-to settings
- `sender_reply_to` and `members_reply_address` are both enums with the same values and copy straight across
- `members_from_address` had a default value of 'noreply' as the fallback, which is remapped to NULL in the newsletters table
- We apply the change to all newsletters (there should only be one outside of alpha) which haven't already been reconfigured
2022-05-05 09:44:03 +01:00
Matt Hanley
00e6f4bb34 Removed from-address fallback to members_from_address setting
refs https://github.com/TryGhost/Team/issues/1558

- `members_from_address` is no longer configurable in Admin but was still used as a fallback
- This change removes the fallback so we default straight to noreply@<domain> when a from-address isn't set for a newsletter
2022-05-05 09:44:03 +01:00
Hannah Wolfe
7c795b4e26
Rewrite old version URLs to unversioned URLs with headers (#14646)
closes: https://github.com/TryGhost/Toolbox/issues/315

- For all the current versioned URLs, rewrite the URL as unversioned
  - Add the accept-version header
  - Add the deprecation header
  - Add the link header

- This then does the content-version middleware afterwards, ensuring that rewritten requests get this in the response
2022-05-05 08:45:24 +01:00
Rishabh Garg
420697291b
Added newsletter info to email unsubscribe url (#14693)
refs https://github.com/TryGhost/Team/issues/1495

For single newsletters, the unsubscribe link on emails auto unsubscribed member from the newsletter. In case of multiple newsletters, we were missing the newsletter information on unsubscribe URL that will allow us to auto unsubscribe member from that specific newsletter as they intended, while allowing them option to manage other newsletter preferences via Portal UI. This change -

- adds relevant newsletter UUID on the unsubscribe url in emails
- allows portal to auto unsubscribe members from desired newsletter
2022-05-05 11:00:24 +05:30
Fabien 'egg' O'Carroll
2da52130a6
Removed hasActiveStripeSubscriptions endpoint (#14689)
refs https://github.com/TryGhost/Team/issues/1147

This endpoint is no longer used in 5.0
2022-05-04 17:25:21 +01:00
Simon Backx
cf9231e77a
Added name property to duplicate newsletter ValidationError (#14694)
refs https://github.com/TryGhost/Team/issues/1564

We need this property in the frontend to correctly handle the error
2022-05-04 16:45:55 +02:00
Simon Backx
ad1ebe6a47
Fixed error when firing Members webhooks (#14645)
refs https://github.com/TryGhost/Team/issues/1577

The last seen at was being updated via the model rather than the
respository, which mean that the default relations were not being
loaded.

This fix updates the repository to load the newseletters relation,
updates the last seen at updated to use the repository and updates the
output serializer to handle missing newsletter relation.

We also update all packages relying on the domain-events package to
ensure that they're all using the same version.

Co-authored-by: Fabien 'egg' O'Carroll <fabien@allou.is>
2022-05-04 12:42:27 +02:00
Naz
c627779948 Extracted email-content-generator into a package
refs https://github.com/TryGhost/Toolbox/issues/292

- Following the concept of having as little code in Ghost core as possible :) The email content generation is also needed to be reused in the version mismatch handling package.
2022-05-04 17:28:09 +08:00
Naz
2d7bcdf80a Reworked EmailContentGenerator to async/await
refs https://github.com/TryGhost/Toolbox/issues/292

- Makes the code more readable
2022-05-04 15:36:50 +08:00
Naz
551bd5e511 Refactored email utils to a class with DI params
refs https://github.com/TryGhost/Toolbox/issues/292

- There's a need to reuse these utils in the version mismatch notification service. Having loads of tightly coupled dependencies makes it super hard to rip out this module for reuse
- It's a groundwork for extraction of the email-utils package
- Rewrote the unit tests that were written for these utils previously - they weren't testing anything useful. The goal of this util is to generate specific content based on provided data and available templates - now the tests do test those specific things, not the mailer itself!
2022-05-04 15:36:50 +08:00
Hannah Wolfe
499bb293c9
Fixed urlUtils usage in member config provider
- This is preparation work for getting rid of API versions
- The existing code used api versions for members, but the members API is not versioned
- This caused a bug as issuer was begin set to {{admin_url}}/ghost/api/undefined
- The updated code returns the correct value and is unit tested
- Whilst cleaning up I also swapped the usage of urlUtils to consistently use urlFor, as that is our main helper
2022-05-03 21:07:04 +01:00
Simon Backx
12f569ebf9
Dropped nullable from members_subscribe_events.newsletter_id (#14656)
closes https://github.com/TryGhost/Team/issues/1570

- Includes utils to disable foreign key checks when dropping nullable from columns
- Migration to drop nullable from members_subscribe_events.newsletter_id
2022-05-03 16:30:07 +02:00
Simon Backx
18ad847211
Added ValidationError for duplicate newsletter names (#14631)
refs https://github.com/TryGhost/Team/issues/1564

- While creating a newsletter
- While editing a newsletter
- Includes tests and updated snapshots
- Igored sort_order to snapshot test because sort_order is different in CI than locally so had to ignore it in the snapshot.
2022-05-03 15:33:56 +02:00
Hannah Wolfe
d01c1cba64
Fixed undefined error when serializing webhooks
closes: https://github.com/TryGhost/Toolbox/issues/318
refs: https://github.com/TryGhost/Toolbox/issues/320
refs: 2a11d5100e

- The underlying problem was caused by the removal of API versions
  - commit 2a11d5100e
  - I missed doing the same refactor as was done for the post-emailserializer here: 2a11d5100e (diff-0f7477bb5e5a9fdcb4c909a9e9e61ab5bb76b640b2d63a5791a9d6c8904f2758R7)
  - The removal of api versions included a change to remove circular references in the api module
- Written some basic unit tests to prove that webhook serialization works
  - I'm not 100% happy with the output, and not sure if it's the tests or reality, needs further work
  - Future work tracked in https://github.com/TryGhost/Toolbox/issues/320
2022-05-03 11:40:59 +01:00
Naz
3d397bb5f1 Revert "Disabled version compatibility emails temporarily"
This reverts commit 9a0d143fb1

- main is now a precursor of 5.0 which should have email notification turned on
- had to add missing `err` in the errorHandler middleware as it was not triggering the versionMissmatchHandler otherwise
2022-05-03 17:18:44 +08:00
Hannah Wolfe
c6ae3c30d8 Moved content-version middleware onto api app
closes: https://github.com/TryGhost/Toolbox/issues/319

- at the moment, content-version is only set if one of our endpoints touches the request
  - this was demonstrated in the e2e tests, where many of the tests that set accept-version did not receive accept-version
- by moving the middleware out of the http module and onto the api app we ensure it's always done
- I put the code in the api-version-compatibility service to keep it all co-located
- ideally we will refactor that service slightly so it only exposes middleware
2022-05-02 19:05:14 +01:00
Hannah Wolfe
55ce208ebb Fixed api-version-compatibility-service init error
closes: https://github.com/TryGhost/Toolbox/issues/317

- Added two tests for unknown versions with accept-versions set ahead and behind
   - Ahead passes, but we get an error for behind
- Refactored the api-version-compatibility-service to expose its own middleware so the init sequence is correct
2022-05-02 19:05:14 +01:00
Naz
03c8e7f010 Switched gscan to validate against v5 set of rules
refs https://github.com/TryGhost/Toolbox/issues/226

- We are on the finish line to release 5.0 - the instance should be validating it's themes agains v5 set of rules.
- The prominent deprecations are `{{author}}` and `@blog` helpers removals - will throw 'fatal' errors when encountered.
2022-05-02 20:56:25 +08:00
Hannah Wolfe
c9ab21f821
Fixed inconsistent error response from the API
- we have two JSON error response formats one old, one new (v2)
- we couldn't use the new one everywhere before without changing the response from older versions
- that is totally irrelevant in Ghost 5.0 as there is only one API version
- therefore we can and should use the new response format everywhere
- eventually we should rename it so it doesn't have v2 in it
2022-05-02 13:31:25 +01:00
Simon Backx
ab4ea4850d
Fixed null values in settings default newsletter migration (#14638)
refs https://ghost.slack.com/archives/C02G9E68C/p1651484563907609

- When the site has an empty name, it is set to `NULL` in settings.
- The name column is not nullable in newsletters, breaking the migration in that case.
- Fixed by excluding all non-nullable columns
- Replaced JS Date object with raw SQL `CURRENT_TIMESTAMP`
2022-05-02 12:16:58 +02:00
Hannah Wolfe
438a368a01
Added deprecation comments and notes to schema.js
- Adding some missing context for some parts of the schema that aren't how we would have them in an ideal world
2022-05-02 11:05:13 +01:00
Naz
5e441d0942 🔥 Removed {{author}} helper support
refs https://github.com/TryGhost/Toolbox/issues/230

 - Single {{author}} helper has been deprecated since multiple major releases. It has also been throwing fatal errors in gscan v5 since some time. It will finally be gone!
 - The plural {{authors}} helper should be used instead, read here for more information: https://ghost.org/docs/themes/helpers/authors/
2022-05-02 17:59:48 +08:00
Daniel Lockyer
ae13b61cb0
Removed backwards compatibility for ghost_head and ghost_foot settings
refs https://github.com/TryGhost/Toolbox/issues/308

- these two settings are deprecated and we're removing all the code in
  v5 that kept supporting them
2022-04-28 15:37:14 +01:00
Daniel Lockyer
3b6cdc2bc5
Renamed preview files to previews
refs https://github.com/TryGhost/Toolbox/issues/308

- we have a pattern of using plurals around Ghost but this was singular
- this shouldn't change any API functionality, it's just code
  refactoring
2022-04-28 15:37:14 +01:00
Hannah Wolfe
0eedb1c556
Added 307 redirects for old API endpoints
closes: https://github.com/TryGhost/Toolbox/issues/296

- This is a small change to permit any known API version to redirect to an unversioned URL
- We include v2 because although it should have been deleted in 5.0 anyway, in the spirit of the change away from versioned URLs there's
  absolutely no sense in forcing people to update clients that still work for no reason.
- We use a 307, because this preserves the original HTTP method, allowing POSTS, PUTs and DELETEs through as well as GETs
- We set the accept-version header on the redirect, meaning that for example with a request to the old /v4/ api, Ghost will respond as though
  the client sent `accept-version: v4.0` and if there are known breaking changes, it may choose to inform the admin and owner users of these
2022-04-28 15:37:14 +01:00
Daniel Lockyer
5e020f1a8f
Fixed Email Router naming in docs and debug call
- this was likely copied and pasted from the preview router but we
  forgot to change the name
2022-04-28 15:37:14 +01:00
Daniel Lockyer
f82ff87177
Changed /email_previews/posts/<post id> endpoint to return 204 upon success
refs https://github.com/TryGhost/Toolbox/issues/308

- this endpoint is currently used to send a test email with the post
- it currently returns a 200 with whatever the response of the mail
  service is
- this body isn't used in Admin nor is useful generally because it just
  contains the ID of the mailgun response
- it's better than we change it to 204 and no response
- this commit does that and updates the tests
2022-04-28 15:37:13 +01:00
Naz
75170535a4
Renamed destroyByAuthor to reassignByAuthor
refs https://github.com/TryGhost/Toolbox/issues/268

 - The previous naming didn't make much sense in the context of what the method what doing
2022-04-28 15:37:13 +01:00
Naz
5ba3f5efcf
Reassigned posts when deleting a user
refs https://github.com/TryGhost/Toolbox/issues/268

 - When the user is removed our current pattern was deleting their posts. This didn't work well and created all sorts of problems
 - As a solution we now reassign any posts that are only authored by the deleted user to the owner user
 - This change also reduced the dependency on "author" field
2022-04-28 15:37:13 +01:00
Daniel Lockyer
68cffa62ae
Renamed email-preview file to email-previews
refs https://github.com/TryGhost/Toolbox/issues/308

- I recently pluralised the API endpoint but never made the changes to
  the controller file and everywhere else it's needed
- this commit cleans up that inconsistency so it should be clearer
2022-04-28 15:37:12 +01:00
Daniel Lockyer
1b108d2cdb
Removed completed TODO
refs https://github.com/TryGhost/Toolbox/issues/308

- I've already done this but didn't delete the TODO
2022-04-28 15:37:12 +01:00
Daniel Lockyer
dcaeb67740
Fixed trailing comma 2022-04-28 15:37:11 +01:00
Daniel Lockyer
a48d8427f4
Change response code of special settings API endpoints to 204
refs https://github.com/TryGhost/Toolbox/issues/308

- these endpoints return no body but they were implemented to return a
  200 error code
- 204 would be more suitable so this commit changes that for v5
- also removes the passthrough serializer and updates the snapshots to
  reflect the changes
2022-04-28 15:37:11 +01:00
Daniel Lockyer
ea3c927d94
Renamed reset_all_passwords Authentication API endpoint to /global_password_reset
refs https://github.com/TryGhost/Toolbox/issues/308

- our API has a pattern of using nouns and not verbs for the endpoint
  names, so this changes the endpoint for v5
2022-04-28 15:37:11 +01:00