Commit Graph

72 Commits

Author SHA1 Message Date
Steve Larson
2e0293c99f
🐛 Fixed NQL filters for single letter slugs (#21340)
fixes https://github.com/TryGhost/Ghost/issues/20133
- includes fix to support single letter slugs
2024-10-17 15:35:26 +00:00
Daniel Lockyer
de5dcb8189 Fixed treeshaking and require size for date-fns
- we don't need to require the entire package and this costs 5% of our
  boot time
- this commit bumps NQL to the latest version, which fixes the requires
  to help with treeshaking and loading less code
2024-10-09 17:03:04 +01:00
Sodbileg Gansukh
2f02ec5566
Added unschedule bulk action to posts (#20945)
ref DES-675
2024-09-24 15:32:45 +08:00
Sag
430fbdb987
🐛 Fixed member filtering for "Unsubscribed from newsletter" filters (#20926)
ref https://linear.app/tryghost/issue/ENG-1466
ref https://linear.app/tryghost/issue/ENG-1484

- Previously, filtering members with multiple "Unsubscribed from
newsletter x" led to no filtering at all, all members were returned
- This was caused by a bug in NQL, that is fixed in version 0.12.5, cf.
[commit](dd18d1d6ca)
- We're also removing the safeguard in the product around bulk deletion
when multiple newsletter filters are in use, as the root problem has
been fixed
2024-09-16 11:16:49 +02:00
Princi Vershwal
309cb37cc6
Updated nql package (#20811)
Ref [ONC-216](https://linear.app/tryghost/issue/ONC-216/improve-the-performance-of-the-membersevents-aggregated-click-event)

Needed changes in nql package for this task.
2024-08-22 07:55:14 +00:00
renovate[bot]
4b28812861 Update TryGhost packages 2024-08-05 12:12:34 +02:00
Fabien 'egg' O'Carroll
5acdafc0e8
Removed ActivityPub backend from Ghost (#20410)
We are no longer going to run any ActivityPub logic inside of Ghost,
instead we're moving to a separate service, so all of this code is now
redundant.
2024-06-19 15:36:36 +07:00
renovate[bot]
3ebe206ea7 Update TryGhost packages 2024-05-27 16:58:32 +02:00
Steve Larson
842290cbef
Improved performance for filter strings with multiple neq statements (#20198)
ref https://linear.app/tryghost/issue/CFR-27
- updated packages to include performance improvement for NQL filter
strings including multiple neq filters for the same resource
- bumped `bookshelf-plugins`
- bumped NQL versions

We identified a performance fix that allows us to combine not equal
(neq) filters for the same resource in a logically-equivalent way that
also has far more performant resulting SQL.

We're effectively automatically combining strings like
'tag:-tag1+tag:-tag2` into 'tag:-[tag1,tag2]'.
2024-05-13 10:35:27 -05:00
Daniel Lockyer
82c612bad9 Rolled out API framework JSDoc typing to more places
- this updates a bunch of places where we're just using Object to cheat
  the system
- doing this means editor autocomplete and basic type checking is better
  because we now have proper types in place
- functionality should not change, these are just comments
2024-05-08 09:28:31 +02:00
renovate[bot]
a33dccf8cd Update TryGhost packages 2024-05-01 17:01:41 +02:00
renovate[bot]
60a3b5a913 Update TryGhost packages 2024-05-01 08:49:04 +02:00
Fabien O'Carroll
af02ca7044 Initial wire up of Posts -> Outbox flow
ref https://linear.app/tryghost/issue/MOM-29

This is very rough, and all still behind a flag. The idea is that any public
post which is published gets added to the Outbox of the site Actor. We also
dispatch an event, which will be used to deliver the Activity to any relevant
inboxes, but that is outside the scope of this commit.
2024-04-25 11:10:17 +07:00
Daniel Lockyer
162f438c63 Updated @tryghost/errors dependency
- this version is written in TS, but was published a few months ago and
  needs to be bumped here
- also updates a previous deep include into the library, which was
  unnecessary anyway
2024-03-11 17:33:51 +01:00
Michael Barrett
ed0762fb51
Removed usage of yg when using NQL (#19287)
refs https://github.com/TryGhost/NQL/pull/73

The referenced PR removes `yg` from the parsed NQL output, so we also
need to remove any usage of it in Ghost
2024-01-15 14:40:01 +00:00
Simon Backx
e5f644c27f
🐛 Fixed contain/starts/endsWith filters with /, _ or % in them (#19015)
fixes GRO-25

Updated @tryghost/nql to 0.12.0 and other packages that depend on it

1. SQLite: when a filter string contains /.

When we use a NQL contain/starts/endsWith filter that contains a slash,
underlyingly the whole filter will get converted to a MongoDB query, in
which we just use a regexp to represent the filter. In here we will
escape the slash: \/ as expected in a regexp. Later when we convert this
MongoDB query back to knex/SQL, we use a SQL LIKE query. Currently we
don't remove the escaping here for a normal slash. MySQL seems to ignore
this (kinda incorrect). SQLite doesn't like it, and this breaks queries
on SQLite that use slashes. The solution here is simple: remove the
backslash escaping when converting the regexp to LIKE, just like we do
with other special regexp characters.

2. We don't escape % and _, which have a special meaning in LIKE queries

Usage of % and _ is now as expected and doesn't have the special SQL
meaning anymore.
2023-11-16 09:35:20 +00:00
Nick Moreton
b9b1502772
🐛Changed "free_signups" to "signups" in Post Exporter (#18883)
ref https://github.com/TryGhost/Product/issues/4110

Made this change to increase clarity in data export

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 6c0508d</samp>

Renamed a column in posts export data and updated the corresponding test
case. This change makes the export data more consistent and clear for
users who have different member features enabled.
2023-11-07 09:52:28 +00:00
renovate[bot]
057d9599f5 Update TryGhost packages 2023-10-31 20:54:17 +01:00
Daniel Lockyer
85d41d0562 Aligned dependencies with resolution values
- this commit brings all dependencies up-to-date with the version set as
  a resolution
2023-10-13 08:37:36 +02:00
Fabien "egg" O'Carroll
6de0a2bfff Fixed #bulkDestroy from calling bulkDestroy
Rather than calling itself with the newly created transaction, it would call
the "parent" method, which meant that two events were dispatched. TBH I think
we can get rid of the check for a transaction here, and so the parent method
too, but not 100% sure.
2023-10-11 11:05:16 +02:00
Daniel Lockyer
85098e07d4 Configured all unit tests to use dot reporter
refs https://ghost.slack.com/archives/C02G9E68C/p1696490748701419

- this configures mocha to use the dot reporter because the default is
  way too verbose in CI
2023-10-05 12:24:24 +02:00
Fabien "egg" O'Carroll
3a624ec3a1 Fixed return values of CollectionService
Our service layer should not expose the Entities, it should return the DTOs.
This is to allow us to make internal refactors without having to modify the
entire stack.
2023-09-22 19:05:37 +07:00
Kevin Ansfield
1c68bd6779
Fixed transaction errors using PostsService inside of Post model's onSaving hook (#18148)
no issue

`PostsService` and `CollectionsService` were missing some passthroughs and had differing naming for a transaction instance on the `options` object which meant SQLite would hang if the Lexical renderer called out to `PostsService.browsePosts`

- added passthrough of `transacting` to the Lexical renderer ready for implementation of the collection-fetching function
- added rename of `options.transacting` to `options.transaction` and passthrough from `PostsService` to `CollectionsService` (passthrough from collections repository to bookshelf and required `transaction->transacting` was already in place)
2023-09-14 17:22:10 +00:00
Naz
11624e48ca Fixed filtering posts by empty collections error
https://github.com/TryGhost/Arch/issues/90

- Ghost produced an error when a collection filter was applied over Posts API and that collection contained no posts.
2023-09-14 14:31:23 +08:00
Daniel Lockyer
c6cb35074a Updated linting and testing packages 2023-09-01 15:51:17 +02:00
Fabien 'egg' O'Carroll
7c934ebf46
Enabled collection param for Post APIs
This will allow us to browse posts based on their collection which will
be used for rendering the collections card. As with the Collections API
we're not opening up the write endpoints yet.
2023-08-28 07:34:58 +00:00
Naz
46f8c15448 Fixed flaky test behavior for bulk actions
refs https://ghost.slack.com/archives/C02G9E68C/p1692816097875899

- With introduction of extra e2e test coverage for Collections some tests started to fail at random. The root issue here was the transaction processing collections was started before the original bulk action (bulk edit, bulk publish/unpublish, etc.) was fully committed. The full transaction commit happens with the bulkAction method return inside of `if (!options.transacting) {` block.
2023-08-24 16:06:41 +08:00
Naz
acccc16614 Added collections update after bulk adding tags
refs https://github.com/TryGhost/Arch/issues/77

- During initial development we have missed to support collections update when tags are added to posts in bulk. It's especially valid usecase since we can define automatic collection with a filter containing not yet existing tags.
2023-08-23 17:12:08 +08:00
Naz
18a4fa8cd9 Added bulk posts action events dispatching
refs https://github.com/TryGhost/Arch/issues/16

- Allows to subscribe to bulk unpublish/featured/unfeatured DomainEvents elsewhere in the system, for example, Collections.
2023-08-01 15:11:00 +08:00
Naz
9b257f3966 Update of collection posts on bulk destroy
refs https://github.com/TryGhost/Arch/issues/16

- When the bulk destroy is done on posts Collections need to know about the update and remove the stored posts from collections.
2023-08-01 15:11:00 +08:00
Naz
ffa101b550 Added post events package
refs https://github.com/TryGhost/Arch/issues/16

- This package is meant to hold Domain Events associated with Post model/entity. The very first one here is PostsBulkDestroyedEvent needed to signal bulk destroy action completion from the posts service.
2023-08-01 15:11:00 +08:00
Naz
48ccea818a Fixed unpublished collection posts filtering
closes https://github.com/TryGhost/Arch/issues/58

- Following assumptions were broken:
- Posts Admin API should include posts of all statuses when filtering by collection
-  Posts Content API should not include any unpublished posts
- Updated the "status" filter which fixes the problem. We still disallow any custom filters to be applied on top of collections filter.
2023-07-26 16:45:57 +08:00
Naz
6361423ff7 Fixed ability to remove post from an automatic collection
refs https://github.com/TryGhost/Arch/issues/16

- Post can be removed from a manual collection, but never from an automatic collection.
2023-07-21 19:46:22 +08:00
renovate[bot]
7dce046786 Update Test & linting packages 2023-07-11 15:26:07 +02:00
Kevin Ansfield
5d8ea79788
Implemented pages.hide_title_and_feature_image property in API (#17211)
closes https://github.com/TryGhost/Product/issues/3557

- bumped `@tryghost/admin-api-schema` to allow passthrough of the new property in API requests
- updated output mapper to ensure property always returns a boolean rather than `null` in the case where `posts_meta` doesn't exist for a page
- updated `PostsService.copyPost()` to include the new property when copying
- updated `checkResponse` test util and snapshots to expect `hide_title_and_feature_image` property in page API responses
- fixed pages e2e test so it doesn't inadvertently modify the match object breaking later tests
2023-07-05 14:01:24 +00:00
Michael Barrett
998f862e87
🐛 Fixed newsletter post duplication (#17103)
closes https://github.com/TryGhost/Team/issues/3521

When duplicating a newsletter (email only post) some of the fields
relating to the newsletter (i.e `newsletter_id`) were being erroneously
copied over. Upon publishing this made the post appear as if it was an
email only post that had been sent to subscribers when it actually had
not
2023-06-23 11:18:35 +01:00
Simon Backx
e94bdd57ae Updated posts exporter comment tests
fixes https://github.com/TryGhost/Team/issues/3505

I've investigated this, but luckily this is expected behaviour, and was just an error previously in the test:
- The `feedback_more_like_this` and `feedback_less_like_this` columns are only hidden if there is no newsletter with feedback enabled, or if member features are disabled.
- Having a post which is a draft, should not change the visible columns, only global settings should change the comments (so the format is consistent).
- Instead of that, the columns should be null, which means it will be visible but empty.
2023-06-21 16:57:54 +02:00
Hannah Wolfe
6161f94910
Updated to use assert/strict everywhere (#17047)
refs: https://github.com/TryGhost/Toolbox/issues/595

We're rolling out new rules around the node assert library, the first of which is enforcing the use of assert/strict. This means we don't need to use the strict version of methods, as the standard version will work that way by default.

This caught some gotchas in our existing usage of assert where the lack of strict mode had unexpected results:
- Url matching needs to be done on `url.href` see aa58b354a4
- Null and undefined are not the same thing,  there were a few cases of this being confused
- Particularly questionable changes in [PostExporter tests](c1a468744b) tracked [here](https://github.com/TryGhost/Team/issues/3505).
- A typo see eaac9c293a

Moving forward, using assert strict should help us to catch unexpected behaviour, particularly around nulls and undefineds during implementation.
2023-06-21 09:56:59 +01:00
Naz
09264261b7 Added ability to fetch posts by collection
closes https://github.com/TryGhost/Team/issues/3423

- For convenience we need a way to fetch posts that belong to a certain collection. This change adds support for `collection` query parameter: `/?collection=` which can be either an id or slug of the collections we are trying to fetch.
- When posts are fetched by collection we ignore any filters passed along in query parameters as collection is a "filter" by it's very nature.
2023-06-16 17:28:12 +07:00
Naz
1d214361ad
Refactored posts browsing to posts service
refs https://github.com/TryGhost/Team/issues/3423

- This refactor allow for smaller and cleaner change that's coming up when dealing with `?collection=` query parameter
2023-06-16 14:52:55 +07:00
Fabien "egg" O'Carroll
0d7f98f4d1 Supported adding/removing post to collection via Posts API
We've got some fairly simple diffing logic here to update the collections which
a post is in, the bulk of the changes here are to support the return of a DTO
rather than Bookshelf Model. This also helps improve the architecture because
we are step closer to removing infrastructure concerns (HTTP Response Headers)
from the business logic layer.

For now there is a crappy EventString which can be passed back to the
controller which can then handle any HTTP related concerns, although long term
these should be actual events like PostPublished or PostUpdated.
2023-06-16 09:28:19 +02:00
Fabien 'egg' O'Carroll
92172aca8e
Wired up collections to posts endpoint (#16945)
- Added support for `include=collections` to the Posts Admin API behind a flag
- Refactored some of the collections work to support it
2023-06-07 15:06:15 +02:00
Michael Barrett
59fe794b0c
Implemented duplicate post functionality (#16767)
refs: https://github.com/TryGhost/Team/issues/3139 https://github.com/TryGhost/Team/issues/3140

- Added duplicate post functionality to post list context menu
  - Currently only a single post can be duplicated at a time
  - Currently only enabled via the `Making it rain` flag
- Added admin API endpoint to copy a post - `POST ghost/api/admin/posts/<post_id>/copy/`
- Added admin API endpoint to copy a page - `POST ghost/api/admin/pages/<page_id>/copy/`
2023-05-15 09:30:32 +01:00
Simon Backx
fbed93b866
🐛 Added missing history logs for post/page bulk actions (#16734)
no issue

The post/page bulk actions weren't logged in the history log / actions
table.

This change adds support for logging bulk actions.
- New `addActions` static method on models. It creates an action log in
the database for multiple models at once. If only one model was edited,
deleted or added, it will fallback to `addAction`
- `addAction` can also be called statically now
- `actionName` option is now supported when using `addActions`,
`addAction`, and as a result also in all bulk manipulation methods, and
CRUD methods. This allows you to replace the default '5 posts edited'
into something more specific like '5 posts featured'
- Fixed support for null resource_id in the parse-history-event helper
- Removed the default 'published' status requirement when using
Post.findOne for internal queries.
2023-05-05 09:45:36 +02:00
Simon Backx
1ff71dc36c Removed unused bulkRemoveTags
no issue

This bulk action is not used at the moment.
2023-04-27 14:56:54 +02:00
Simon Backx
57557cb2f7 Added E2E tests for bulk post API
refs https://github.com/TryGhost/Team/issues/2925
2023-04-27 12:45:24 +02:00
Simon Backx
c4dd980421 Fixed transaction usage in bulk tag adding
refs https://github.com/TryGhost/Team/issues/2922
2023-04-13 17:47:00 +02:00
Simon Backx
788aa34c8b Added support for creating new tags when bulk editing posts
refs https://github.com/TryGhost/Team/issues/2922
2023-04-13 17:05:42 +02:00
Simon Backx
76fae2a724 Fixed unpublishing sent posts was allowed
refs https://github.com/TryGhost/Team/issues/2677
2023-04-13 16:20:58 +02:00
Fabien 'egg' O'Carroll
82393fa99d
Added bulk tag addition to post context menu
refs https://github.com/TryGhost/Team/issues/2922

Add multiple tags to multiple posts at once.

---------

Co-authored-by: Simon Backx <simon@ghost.org>
2023-04-13 16:17:36 +02:00