Commit Graph

12382 Commits

Author SHA1 Message Date
Kevin Ansfield
95105836aa
Removed logging require in db/connection.js (#12690)
refs https://github.com/TryGhost/Ghost/issues/12496

- having the logging require here means that workers wanting to use the db are unable to do so without requiring logging as a side-effect
- `connection.loggingHook` does not appear to be widely used for anything outside of specific debugging scenarios when using MySQL so it should be safe to disable until a proper fix is found for workers+logging leaking file descriptors
2021-02-22 12:58:57 +00:00
Kevin Ansfield
42e452b127
Removed models require from analytics job (#12689)
refs https://github.com/TryGhost/Ghost/issues/12496

By requiring the models layer the shared logging util was being required as a side-effect causing the open file descriptors problem to continue. Removing logging from the models layer isn't feasible due to deep require chains spreading across the codebase, it's much quicker to remove the need for models in the analytics job.

- models layer was only needed because it's used by the session service
- updated analytics job to create it's own instance of `EmailAnalyticsService` rather than the default instance in order to pass in custom dependencies
- pass in custom `logging` object that uses `parentPort.postMessage` as a way of writing log output
- pass in custom `settings` object that returns settings that have been manually fetched and cached during job instantiation
2021-02-22 12:10:19 +00:00
Renovate Bot
f106de99f6
Update dependency @tryghost/vhost-middleware to v1.0.13 2021-02-22 09:30:40 +00:00
Rish
0620ff6ae0 Added new browse email endpoint
refs https://github.com/TryGhost/Ghost/issues/12633

Adds new `browse` endpoint for emails that allows Admin to check performance of newsletters over time and show stats on dashboard as primary usecase
2021-02-22 13:55:20 +05:30
Naz
12a1c60424 Added custom worker message handler
refs https://github.com/TryGhost/Ghost/issues/12496

- Handling logging in the main thread avoids file handle leaks which happen due to leaky implementation of bunyan logger (see referenced issue for more context)
- Bumped job-manager version to allow for `workerMessageHandler` callback funciton
2021-02-22 20:02:00 +13:00
Naz
8a718ca99a Migrated jobs to use parentPort.postMessage
refs https://github.com/TryGhost/Ghost/issues/12496

- Using ghost-ignition logging caused file handle leaks. As there is no straight-forward way to handle write streams with bunyan (ghost-ignition's underlying logging library) this method of logging was chosen as an alternative to keep the amount of open file handles to minimum
- The follow up changes will include custom formatter for jobs service which should make logging match the same format  as has been used inside the jobs
2021-02-22 20:02:00 +13:00
Naz
adebca422f Made addUnique/dropUnique migration utils idempodent
refs https://github.com/TryGhost/Ghost/pull/12598

- This changeset adds idepmotence to situations where unique contraint has to be dropped or added to the table
- Note '4.0/07-alter-unique-constraint-for-posts-slug.js` was migration that was effected by lack of idempotence
2021-02-22 16:13:28 +13:00
Naz
ce50653f89 Removed "object" as a valid value for settings type
refs https://github.com/TryGhost/Ghost/issues/10318

- Storing JSON object in settings has caused multiple bugs in the past and was considered an antipattern
- This is a last bit in the long process of getting rid of "object" settings in the database. At this point there should be no settings with this type. Yey!
2021-02-22 13:23:03 +13:00
Hannah Wolfe
176433e307 Refactored notify to send started + ready
- In the old boot the server wasn't started til we were ready
- In new boot, we start the server immediately and send the old started event
- Then, when we are ready to accept some traffic, we send a ready event
- At the moment, ready isn't quite sent at the right time:
   - It _should_ be when we're ready to serve real traffic, not just send 503s
   - This is after the URL generation has finished
   - But this requires more refactoring work :(
   - So for now we send when everything else is ready
- This really needs some tests
2021-02-19 20:42:10 +00:00
Hannah Wolfe
2527efd6fc Moved notify out of GhostServer
- make this a standalone module
2021-02-19 20:22:56 +00:00
Hannah Wolfe
b65cb7bd7b Renamed announceServerReadiness to notifyServerStarted
- Notify is a more familiar name e.g. systemd has the sd_notify system which this is similar to
- We're actually announcing the server started, it's not actually ready for traffic (will serve 503s)
2021-02-19 20:11:35 +00:00
Renovate Bot
b5f1c3ef6e Update dependency @tryghost/members-csv to v0.4.5 2021-02-19 16:18:18 +00:00
Hannah Wolfe
09eadad667 Removed extra console times for test utils
- Think it's pretty clear these functions take ~30ms consistently
- Not interesting to optimise these when the whole restart takes seconds
2021-02-19 15:30:40 +00:00
Hannah Wolfe
edbf9a7076 💡 Removed main script that no longer exists
refs 481e2425af

- We no longer support using Ghost as an npm module (this was deprecated long ago)
- We've now removed the file that this used to point to (in 481e2425af)
- As we aren't supporting this approach, we are removing the main script rather than updating it
2021-02-19 15:22:50 +00:00
Hannah Wolfe
b1a98b0b67 Cleaned up global server events
- use theme.ready for loading themes instead of server.start and properly clean this up
- remove server.start and server.stop as they are no longer used (only server.start was used, and only for themes)
- we're moving away from the pattern of using global events like this as they are hard to reason about
2021-02-19 15:21:58 +00:00
Hannah Wolfe
d150516ec3 Improved readability of ghost server and boot
- removed some unused code I added preivously
- refactored boot logging into a mini class for readability
2021-02-19 15:04:55 +00:00
Hannah Wolfe
481e2425af Finalised new boot process
- This commit removes the old boot process and any files that are no longer needed as a result
- Remove the duplicate event for triggering inactive themes to load
- Tidied up a few other bits
2021-02-19 13:15:12 +00:00
Thibaut Patel
9e93ed7ef0 Adding sentry logging to all ping errors
issue TryGhost/Team#362
2021-02-19 14:00:50 +01:00
Hannah Wolfe
b28b4e1cb0 Cleaned up, commented + co-located new boot
- moved the DB init back into the boot file so everything is colocated - want it to be EASY to reason about whats happening
- added some more debug, and made the method signatures all the same
- expanded on comments to make it clear what the intentions are here, as there's a lot more work to do
2021-02-19 12:27:49 +00:00
Daniel Lockyer
db1c1ce21d Changed DB path for SQLite tests
no issue

- previously for SQLite tests we were pointing to a DB file within the
  content/data folder, which would be stored on the filesystem
- by pointing this file to be under `/tmp`, the file is stored in memory
  and should be a lot quicker to access
- this works great for me! - 2x faster test suite for SQLite
- however, Windows doesn't have a `/tmp` folder so we need to rewrite that
  part to replace with `os.tmpdir()`
2021-02-19 12:21:00 +00:00
Hannah Wolfe
71521d166e Readded job scheduling to boot process
- This was missing from the new boot process!
- Added it back because obviously it is necessary :D
2021-02-19 10:09:41 +00:00
Hannah Wolfe
4b472615a8 Added Sentry to new boot process
- With the new boot finalised it's clearer to see where this needs to go
- Update comments to add more clarity around what's happening and why
- Cleaned up the version require, as this was prep for maybe using version via config, which won't work in MigratorConfig
2021-02-19 09:20:41 +00:00
Renovate Bot
ab65f70ef1
Update dependency ghost-ignition to v4.4.4 2021-02-19 04:41:24 +00:00
Renovate Bot
cda68d21a3
Update dependency @sentry/node to v6.2.0 2021-02-18 21:59:02 +00:00
Hannah Wolfe
f1be3418d9 Switched tests to use new boot method
- We currently have 2 boot systems in the codebase, until now the tests were still running against the old one
- Regression tests using the forceStart + subdir flag no longer work. These need reworking, but this _should_ be easier later
- Note those tests work fine if they were the first tests run, it is only the case of trying to restart the server with a subdirectory after starting without that doesn't work
2021-02-18 20:24:49 +00:00
Kevin Ansfield
29f34468f5
Updated mobiledoc tests for lazy loaded images (#12672)
refs 074ce4efb0
2021-02-18 19:49:40 +00:00
Kevin Ansfield
074ce4efb0 Added native lazy loading behaviour to content images
refs https://github.com/TryGhost/Ghost/issues/1325

- updated `kg-default-cards` to version that includes lazy loading attributes on image and gallery card output
- updated `kg-markdown-html-renderer` to version that includes lazy loading attributes on markdown images
2021-02-18 18:53:35 +00:00
Thibaut Patel
6e58846c94 Added sentry logging to 429 ping errors
issue https://github.com/TryGhost/Team/issues/362
2021-02-18 19:21:15 +01:00
Daniel Lockyer
a2dd7c7f7d
Unified migration logging styles
no issue

- all migrations should contain a logging message
- info for successful things, or warn if we deviated from what was
  expected for some reason
- also added some spacing to make them easier to read
2021-02-18 17:35:32 +00:00
Daniel Lockyer
bf960bcecb
Fixed typo in migration message
no issue

- simple rewording to clean up the message
2021-02-18 17:05:00 +00:00
Hannah Wolfe
5970f1df9e Split out old boot method from test utils
- clearly mark what counts as "boot" so we can swap it for new boot
2021-02-18 16:11:47 +00:00
Hannah Wolfe
469382eb95 Cleaned test utils start and stop Ghost functions
- create clarity around the two modes of "starting" ghost - one is just a reload of the DiB and some services!
- both of these modes ends the same way - with exposing fixtures and returning the server
2021-02-18 15:38:31 +00:00
Hannah Wolfe
d6a319aa3e Cleaned test utils exposing fixtures
- This is actually a really useful part of our test framework
- Rewrite it to be cleaner and clearer what does
- Add timing function to see if its worth optimising this later
2021-02-18 15:38:31 +00:00
Hannah Wolfe
9f718750b4 Added comments and TODOs to startGhost test util 2021-02-18 15:38:31 +00:00
Kevin Ansfield
c7a29b4e7c
🐛 Fixed unexpected members-only content appearing in excerpt field (#12670)
closes https://github.com/TryGhost/Team/issues/468

- updated post-gating
  - clears excerpt if there's no access
  - rebuilds excerpt from free preview if paywall card is used and there's no custom excerpt
2021-02-18 14:12:06 +00:00
Rish
6d2b731379 Fixed member status events query
refs https://github.com/TryGhost/Ghost/issues/12602

- Adds aggregate option to permitted options
- Cleans up SQL query to fetch delta values
2021-02-18 18:11:50 +05:30
Fabien 'egg' O'Carroll
7abc6ac705
Added initial member events timeline API (#12661)
refs https://github.com/TryGhost/Ghost/issues/12633

Allows us to show a list of recent member events for the site dashboard
2021-02-18 11:52:18 +00:00
renovate[bot]
9c0ecd7214
Update dependency @tryghost/members-api to v1.0.0-rc.3 (#12668)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-18 11:51:08 +00:00
Hannah Wolfe
cf93b168d8 Revert committing new test code 2021-02-18 10:27:19 +00:00
Hannah Wolfe
24bfb5567b Cleaned up test utils with async/await
- I'm on a mission to make this code comprehensible so we can work it into something better with new boot
- Who else loves async/await? :D
- Dried up a block of duplicated code
2021-02-18 10:15:19 +00:00
Kevin Ansfield
2c96df42ac
Added paywall card to mark end of free content preview (#12663)
closes https://github.com/TryGhost/Team/issues/466

- upgraded kg-default-cards to include paywall card
- extracted `htmlToPlaintext` from post model to shared util for re-use
- updated post-gating to set html+plaintext to the free preview if a paywall card has been used
  - re-generates plaintext from the truncated html using `htmlToPlaintext` util
- display free content in the `{{content}}` helper via the default CTA template
2021-02-17 23:00:26 +00:00
Naz
abb8c1df74 Updated unsplash setting migration to be idempotent
refs https://github.com/TryGhost/Ghost/issues/10318

- Previous version of migration was not following the idempotence rule of migrations
2021-02-18 10:55:59 +13:00
Naz
e0cc314f91 Removed duplicate migration
no issue

- The migration didn't want to go away after rebases combined with renames
2021-02-18 10:55:59 +13:00
Fabien O'Carroll
7785fb6dc5 Refactored usage of pre v4 "unsplash" setting format
refs https://github.com/TryGhost/Ghost/issues/10318

- API changes introduced:

canary/v4 Admin API
GET /settings/ (browse)

+ "unsplash" present in response as boolean value

GET /settings/:settingName (read)

+ "unsplash" present in response as boolean value

PUT /settings/ (edit)

+ "unsplash" updates setting, accepts ONLY  boolean format

v3  Admin API
GET /settings/ (browse)

+ "unsplash" present in response with object value

GET /settings/:settingName (read)

+ "unsplash" present in response with object value

PUT /settings/ (edit)

+ "unsplash" updates setting, accepts either boolean or object formats

v2 Admin API
GET /settings/ (browse)

+ "unsplash" present in response with object value

GET /settings/:settingName (read)

+ "unsplash" present in response with object value

PUT /settings/ (edit)

+ "unsplash" updates setting, accepts object format
2021-02-18 10:55:59 +13:00
Fabien O'Carroll
9cb069eb8e 🏗 Updated "unsplash" setting handling to match updated format
refs https://github.com/TryGhost/Ghost/issues/10318

- JSON object format used in previous "unsplash" setting was considered an
anti-pattern. Flat structure was extracted out of the "unsplash.isActive" JSON.
- The naming convention uses `amp` as  a precedent (https://github.com/TryGhost/Team/issues/331#issuecomment-658815017)
2021-02-18 10:55:59 +13:00
Naz
0097f2037c Fixed slack setting migration to follow idempotance rule
refs https://github.com/TryGhost/Ghost/pull/12631

- Initialy writen migration would break if executed twice
- Also accounted for situation if only part of the migration executed leaving only one of the values migrated
2021-02-18 10:55:32 +13:00
Hannah Wolfe
9964a5c23a Moved cacheRules from testUtils into fixtures
- yet more tidy up of the huge test utils index file
2021-02-17 17:55:38 +00:00
Hannah Wolfe
1b4ebce3b0 Split urlServiceUtils from testUtils & unified
- There is now just one way to wait until the UrlService is finished across all of our tests!
- db.ready is only called in the one utility + the actual UrlService tests
2021-02-17 17:36:27 +00:00
Hannah Wolfe
d3b50c8af3 Updated portal to include accent color in preview mode
- If we are in preview mode, we output an additional string to set the accent color for portal
- This is semi-temporary, as we will probably have a proper way to pass portal settings later
2021-02-17 13:49:41 +00:00
Hannah Wolfe
a0bdba2516 Added theme preview mode
- Allow the frontend to accept post messages to generate previews of the frontend
- Created a new endpoint in admin we can use to render these previews, which is possibly not necessary
- Supports a limited group of settings, which can easily be expanded, but care should be taken if expanding to use user-provided strings
2021-02-17 13:49:41 +00:00