Commit Graph

16212 Commits

Author SHA1 Message Date
Aileen Booker
e0331bbfcf
Added MilestoneCreatedEvent to staff service notifications (#16307)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

- Added MilestoneCreatedEvent subscription to staff-service incl. first
handling
- Logs information for now instead of actually sending an email
2023-02-23 11:20:13 +02:00
Daniel Lockyer
fed2cb2675
Added missing dev dependency to event-aware-cache-wrapper package
- this is used in tests so it needs to be defined in the package.json
2023-02-23 08:48:01 +01:00
Naz
6b72b2f51f
Removed public-resource-repository
refs https://github.com/TryGhost/Toolbox/issues/522

- Using a generic resource repository for caching purposes didn't prove to be effective as code was moved to api-level caching. There's no need to introduce extra abstraction level for simple calls like findPage when there's no extra logic to it.
2023-02-23 13:07:04 +08:00
Naz
b8bdd3e742
Moved Tags Content API to api-level caching
refs https://github.com/TryGhost/Toolbox/issues/522

- Caching on a repository level was pretty hard to achieve with more complex models like "posts", so that approach was abandoned in favor of API-response level caching.
- Also removed use of "public-resource-repository" as it was not serving any specific purpose anymore.
2023-02-23 13:07:04 +08:00
Naz
33f176a9de
Cleaned up use of public-resource-repository
no issue

- The caching has been moved down the layer  - the the api-framework's "pipeline", so there's no need to add complexity to post fetching logic with repository pattern.
2023-02-23 13:07:04 +08:00
Naz
f049e89a20
Hooked up event aware cache wrapper to posts cache
refs https://github.com/TryGhost/Toolbox/issues/522

- When caching responses the posts cache can create a situation where it becomes stale within the TTL period and would give stale responses to shared caches.
- Having full cache reset on 'site.changed' event makes cached content evergreen reducing the risk of caching stale content in shared caches
2023-02-23 13:07:04 +08:00
Naz
f74b19ab61
Added implementation for event-aware cache
refs https://github.com/TryGhost/Toolbox/issues/522

- The main feature of this cache wrapper is being able to "reset" the the cache without calling the "reset" on the wrapped cache. Being able to invalidate caches without accessing the data is a feature needed to run on caches with shared environment.
- Cache invalidation happens through a special "reset time" key being added to each key when setting or getting a value, when the cache is reset the reset time is set to a new value - essentially invalidating all previously accessible values.
2023-02-23 13:07:04 +08:00
Naz
0301f5983e
Bootstrapped module for EventAwareCacheWrapper
refs https://github.com/TryGhost/Toolbox/issues/522

- This is generated code for a new module. Nothing special here
2023-02-23 13:07:04 +08:00
Naz
0ddf0dd003
Added simple non-expiring caching to Posts API
refs https://github.com/TryGhost/Toolbox/issues/522

- The public posts "browse" endpoint is causing the most strain on the instance performance. Caching responses with small TTL would allow to reduce the amount of request processing.
2023-02-23 13:07:04 +08:00
Naz
3cfe6d2cbb
Added cache support to api-framework
refs https://github.com/TryGhost/Toolbox/issues/522

- API-level response caching allows to cache responses bypassing the "pipeline" processing
- The main usecase for these caches is caching GET requests for expensive Content API requests
- To enable response caching add a "cache" key with a cache instance as a value, for example for posts public cache configuration can look like:
```
module.exports = {
    docName: 'posts',

    browse: {
        cache: postsPublicService.api.cache,
        options: [ ...
```
2023-02-23 13:07:04 +08:00
Aileen Nowak
80ebd1c5be Fixed random timeouts in milestone service e2e test
no issue

- Passed specific config to `useFakeTimers` so the test only fakes the `setTimeout` call
2023-02-22 20:26:53 +02:00
Simon Backx
94f5ad60c3 Added temporary fix for email suppression list error logs in tests
refs https://github.com/TryGhost/Team/issues/2598

In tests the model is undefined because the service is imported too early.
2023-02-22 19:13:52 +01:00
Simon Backx
7220be92e2 Webmentions sending tests stability improvements
no issue
2023-02-22 18:25:06 +01:00
Daniel Lockyer
ccc443bf28
Commented out flaky adapter-cache-memory-ttl tests
- at least until we can fix them in a reliable way
2023-02-22 17:24:26 +01:00
Steve Larson
18eeb9e523 moved spam prevention test
no refs
-spam prevention test was causing subsequent tests to fail randomly
-moving to the end ensures (for now) we don't interrupt other tests
-seems to be an issue with awaiting the jobservice which do concurrent
2023-02-22 09:52:26 -06:00
Simon Backx
a7090dddcd Email snapshot updates 2023-02-22 16:49:28 +01:00
Simon Backx
603e0909c9 Fixed webmentions unit test coverage
no issue

Try catch was not covered
2023-02-22 16:36:11 +01:00
Kevin Ansfield
dda1293ec0
Wired up lexical editor focus when clicking below editor canvas
no issue

- we added support for and a demo of clicking below the editor moving focus to it in the Koenig repo but the implementation in Admin was missing
- replaced the commented-out mobiledoc handling in `<GhKoenigEditorLexical>` with the new Koenig-lexical equivalent
2023-02-22 15:26:31 +00:00
Simon Backx
f45d1810a6 Improved webmention receiving E2E test reliability
refs https://github.com/TryGhost/Team/issues/2596
2023-02-22 16:19:56 +01:00
Djordje Vlaisavljevic
1b3d19ba81 Updated new mention email template design
refs https://github.com/TryGhost/Team/issues/2491
2023-02-22 15:11:29 +00:00
Djordje Vlaisavljevic
5a7138bb4b Removed repetitive post titles
refs https://github.com/TryGhost/Team/issues/2575
2023-02-22 15:11:29 +00:00
Sanne de Vries
4095fbc745 Removed unused Spirit styles
No issue
- These specific styles were clashing with the Tailwind classes used in the Lexical editor. As they are not used anywhere in Admin, the simplest solution is to remove them.
2023-02-22 15:44:07 +01:00
Aileen Booker
3aa75ee5dc
Improved milestone e2e test (#16314)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

- Check with more realistic dates and validate changes on milestone
model
2023-02-22 16:15:21 +02:00
Aileen Booker
cf7d34d862
Added BookshelfMilestoneRepository implementation (#16305)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

This stores the received milestones in the database.
2023-02-22 15:53:29 +02:00
Djordje Vlaisavljevic
7b778eabe4 Updated post analytics mentions widget design
refs https://github.com/TryGhost/Team/issues/2575
2023-02-22 13:11:39 +00:00
Djordje Vlaisavljevic
fb3347bc64 Updated mentions dashboard widget design
refs https://github.com/TryGhost/Team/issues/2481
2023-02-22 13:11:39 +00:00
Ronald Langeveld
76640d9b7e
Added page resources to emails (#16315)
refs https://github.com/TryGhost/Team/issues/2572

- Passes post resource data to emails.
- Updated email templates accordingly.
- Added snapshot e2e tests.
2023-02-22 21:02:15 +08:00
Aileen Booker
4556e9be88
Added milestone_notifications column (#16306)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

- created a migration for a new boolean column in users that would
determine if the staff user gets an email when a new milestone is
achieved.
2023-02-22 14:13:50 +02:00
Daniel Lockyer
db36da6b5d
Increased global Playwright expect timeout to 10s
- this sometimes helps when CI is slow, and is the best way to set it
  globally
2023-02-22 12:54:26 +01:00
Simon Backx
228de811bb Cleaned up comment
refs aed10d38f0
2023-02-22 12:23:46 +01:00
Simon Backx
aed10d38f0 Hid Bridgy Webmentions
fixes https://github.com/TryGhost/Team/issues/2591
2023-02-22 12:21:43 +01:00
Daniel Lockyer
2d1f9fff0c
Updated @tryghost/errors dependency
- there's a weird situation when we have mixed versions of the
  dependency because different libraries try to compare instances
- this brings the usage up to 1.2.21 so we can fix the build for now
2023-02-22 11:32:11 +01:00
Simon Backx
85ac38cc48 Added mentions page for a post
fixes https://github.com/TryGhost/Team/issues/2590

Added a new route that only shows mentions for a given post. Reuses the same controller and template.
2023-02-22 10:48:15 +01:00
renovate[bot]
0181f2f61d Update dependency body-parser to v1.20.2 2023-02-22 09:59:25 +01:00
Daniel Lockyer
e9eb94dd81
Fixed missing timeout on nodemailer Mailgun requests
refs 8ce2321cb1

- without this, we have no timeout on the requests and it's good to
  control how long our connections are active for
2023-02-22 09:51:57 +01:00
Aileen Booker
32630c27cc
Added milestones database table (#16300)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

- added new `milestones` database table to be able to store created
milestones.
- updated schema and tests to match.
2023-02-22 10:46:43 +02:00
Naz
ad6097b695
Refactored post's extra-attributes to use options
refs https://github.com/TryGhost/Toolbox/issues/522

- Having simpler method signature makes it easier to use it in different context - needed for changes in public resource repository
- TLDR of the changes - reduced parameter 'frame.options' -> 'options'
2023-02-22 15:46:56 +08:00
renovate[bot]
61bacb6681 Update dependency socket.io to v4.6.1 2023-02-22 05:41:56 +00:00
Sam Lord
c72dcd629f Fixed balance of email recipient data in data generator
no issue

Previously the number of opened emails was being generated incorrectly as the number of delivered emails was being reported too high.

Also, the faker date function occasionally fails for dates which are
too close together so this switches to manually generating a date
between the two.
2023-02-21 23:50:02 +00:00
Sam Lord
6cdf37c0ee Added open rates to members in data generator
no issue
2023-02-21 23:50:02 +00:00
Djordje Vlaisavljevic
34c694529d Added logic for displaying resource type
refs https://github.com/TryGhost/Team/issues/2491
2023-02-21 22:20:12 +00:00
Djordje Vlaisavljevic
88fa56ee37 Updated new mention email template design
refs https://github.com/TryGhost/Team/issues/2491
2023-02-21 22:13:39 +00:00
Djordje Vlaisavljevic
d03cf20aa6 Updated spacing
refs https://github.com/TryGhost/Team/issues/2481
2023-02-21 20:27:36 +00:00
Djordje Vlaisavljevic
b16a926a24 Updated spacing
refs https://github.com/TryGhost/Team/issues/2575
2023-02-21 20:27:21 +00:00
Djordje Vlaisavljevic
11b201b431 Added static HTML for post analytics mentions feed
refs https://github.com/TryGhost/Team/issues/2575
2023-02-21 20:11:41 +00:00
Djordje Vlaisavljevic
ba93f95905 Added mentions widget to post analytics
refs https://github.com/TryGhost/Team/issues/2575
2023-02-21 20:10:49 +00:00
Djordje Vlaisavljevic
179fe96c5a Updated mentions dashboard widget design
refs https://github.com/TryGhost/Team/issues/2481
2023-02-21 20:10:40 +00:00
Djordje Vlaisavljevic
a439631d3c Updated mentions dashboard widget design
refs https://github.com/TryGhost/Team/issues/2481
2023-02-21 19:59:02 +00:00
Djordje Vlaisavljevic
1545d4fb5b Added mentions widget to post analytics
refs https://github.com/TryGhost/Team/issues/2575
2023-02-21 19:59:02 +00:00
Ghost CI
d3563d9c06 Merged v5.35.1 into main 2023-02-21 15:36:02 +00:00
Ghost CI
aaf13b4f6b v5.35.1 2023-02-21 15:35:59 +00:00
Simon Backx
fb210ba6a0 Added extra Mailgun retry
no issue
2023-02-21 16:22:26 +01:00
Simon Backx
461634c57c Fixed snapshot tests 2023-02-21 16:15:00 +01:00
Simon Backx
7781c2da07 Implemented retrying for sending email via Mailgun API
no issue

Retry sending an email up to 5 times if it failed.
2023-02-21 16:06:23 +01:00
Simon Backx
b665b1a3cc Implemented email analytics retrying (#16273)
fixes https://github.com/TryGhost/Team/issues/2562

New event fetching loops:
- Reworked the analytics fetching algorithm. Instead of starting again
where we stopped during the last fetching minus 30 minutes, we now just
continue where we stopped. But with ms precision (because no longer
database dependent after first fetch), and we stop at NOW - 1 minute to
reduce chance of missing events.
- Apart from that, a missing fetching loop is introduced. This fetches
events that are older than 30 minutes, and just processes all events a
second time to make sure we didn't skip any because of storage delays in
the Mailgun API.
- A new scheduled fetching loop, that allows us to schedule between a
given start/end date (currently only persisted in memory, so stops after
a reboot)

UI and endpoint changes:
- New UI to show the state of the analytics 'loops'
- New endpoint to request the analytics loop status
- New endpoint to schedule analytics
- New endpoint to cancel scheduled analytics
- Some number formatting improvements, and introduction of 'opened'
count in debug screen
- Live reload of data in the debug screen

Other changes:
- This also improves the support for maxEvents. We can now stop a
fetching loop after x events without worrying about lost events. This is
used to reduce the fetched events in the missing and scheduled event
loop (e.g. when the main one is fetching lots of events, we skip the
other loops).
- Prevents fetching the same events over and over again if no new events
come in (because we always started at the same begin timestamp). The
code increases the begin timestamp with 1 second if it is safe to do so,
to prevent the API from returning the same events over and over again.
- Some optimisations in handing the processing results (less merges to
reduce CPU usage in cases we have lots of events).

Testing:
- You can test with lots of events using the new mailgun mocking server
(Toolbox repo `scripts/mailgun-mock-server`). This can also simulate
events that are only returned after x minutes because of storage delays.
2023-02-21 16:00:32 +01:00
Simon Backx
51cbf13be4 Reenabled email errors again
refs https://ghost.slack.com/archives/C04MSE4MKJT/p1676990553465999
2023-02-21 15:58:10 +01:00
Peter Zimon
42f2f4087f Forced style for the new signup email
no refs.

- Spark email client injected styles for the new email signup email which broke the layout. This commit forces those styles for the email to be consistent in all clients.
2023-02-21 15:50:05 +01:00
Rishabh
74f93c23db Added copy changes for portal 2023-02-21 18:40:26 +05:30
Rishabh
8f05d4dc50 Released Portal v2.25.0 2023-02-21 18:37:44 +05:30
Sam Lord
522652e99e Prevent duplicate label names in data generator
no issue
2023-02-21 11:42:33 +00:00
Simon Backx
1ef4690c7b Wired up mentions API to post analytics
refs https://github.com/TryGhost/Team/issues/2575
2023-02-21 11:46:16 +01:00
Djordje Vlaisavljevic
097416ba19 Added rough placeholder mentions widget
refs https://github.com/TryGhost/Team/issues/2575
2023-02-21 10:18:50 +00:00
renovate[bot]
b9c2af5d4c Update dependency i18next-parser to v7.7.0 2023-02-21 09:38:04 +01:00
renovate[bot]
fab4d49077 Update dependency terser to v5.16.4 2023-02-21 09:37:50 +01:00
Ronald Langeveld
ba0c99d6fb
Added page resource type to Mentions (#16302)
closes https://github.com/TryGhost/Team/issues/2572

The mentions browse output previously only showed resource info if the
mentioned resource type was a `post`.
Additionally, the `resource_type` column basically defaulted to `post`
regardless whether it was a page or in fact a post.

With this change we now have `resource_type` wired in to correctly
determine if the mentioned url was a page or a post.
2023-02-21 13:02:47 +08:00
Djordje Vlaisavljevic
066db4c46f Updated mentions feed design
refs https://github.com/TryGhost/Team/issues/2583
2023-02-20 17:35:01 +00:00
Daniel Lockyer
badbdbbedd
Renamed yarn translate:portal to yarn translate:generate
refs https://github.com/TryGhost/Ghost/issues/15502

- needed to add the `i18n` tests so we don't lose the "Hello" test I
  wrote, and keeping everything under one command is easier
2023-02-20 16:55:54 +01:00
Sam Lord
744b92333c Fixed members-click-event created_at time
no issue
The faker date method seems to spontaneously fail sometimes, as it had decided that the "later" time was before the opened time.
2023-02-20 15:46:47 +00:00
Simon Backx
923c522778
Implemented email analytics retrying (#16273)
fixes https://github.com/TryGhost/Team/issues/2562

New event fetching loops:
- Reworked the analytics fetching algorithm. Instead of starting again
where we stopped during the last fetching minus 30 minutes, we now just
continue where we stopped. But with ms precision (because no longer
database dependent after first fetch), and we stop at NOW - 1 minute to
reduce chance of missing events.
- Apart from that, a missing fetching loop is introduced. This fetches
events that are older than 30 minutes, and just processes all events a
second time to make sure we didn't skip any because of storage delays in
the Mailgun API.
- A new scheduled fetching loop, that allows us to schedule between a
given start/end date (currently only persisted in memory, so stops after
a reboot)

UI and endpoint changes:
- New UI to show the state of the analytics 'loops'
- New endpoint to request the analytics loop status
- New endpoint to schedule analytics
- New endpoint to cancel scheduled analytics
- Some number formatting improvements, and introduction of 'opened'
count in debug screen
- Live reload of data in the debug screen

Other changes:
- This also improves the support for maxEvents. We can now stop a
fetching loop after x events without worrying about lost events. This is
used to reduce the fetched events in the missing and scheduled event
loop (e.g. when the main one is fetching lots of events, we skip the
other loops).
- Prevents fetching the same events over and over again if no new events
come in (because we always started at the same begin timestamp). The
code increases the begin timestamp with 1 second if it is safe to do so,
to prevent the API from returning the same events over and over again.
- Some optimisations in handing the processing results (less merges to
reduce CPU usage in cases we have lots of events).

Testing:
- You can test with lots of events using the new mailgun mocking server
(Toolbox repo `scripts/mailgun-mock-server`). This can also simulate
events that are only returned after x minutes because of storage delays.
2023-02-20 16:44:13 +01:00
Steve Larson
2d84b7d990
Upgraded got package from v9.6.0 to v11.8.6 (#16261)
Refs TryGhost/Team#2459
-upgraded got from v9.6.0 to v11.8.6 to support following redirects (and
other fixes)
-got v12+ requires ESM, so we do not want to upgrade further at this
time
-required changes to a few libraries that use externalRequests
-mention discovery service tests updated to test for follow redirects
2023-02-20 09:33:11 -06:00
Simon Backx
52a26a7f80 Removed unreliable upload test
no issue

This test failed randomly. It is hard to improve the test without defeating the purpose of the test.
2023-02-20 13:58:01 +01:00
Aileen Booker
386298310b
Added timeout for running milestone service (#16290)
no issue

- Instead of running milestone service directly on boot, set a random
timeout of 0-4 days to run after boot
- Updated tests
- Service is still behind a beta flag
2023-02-20 14:14:06 +02:00
Sam Lord
25eaf05395 Made data generator import labels from the base pack when specified
no issue

This will allow us to use a custom (non-random) set of labels, which should look more realistic.
2023-02-20 12:02:44 +00:00
Simon Backx
0706d5f273 Added pagination to mentions feed
fixes https://github.com/TryGhost/Team/issues/2573

Adds infinite scrolling to the mentions feed.
2023-02-20 12:27:36 +01:00
Sam Lord
70e2c07f2e Data generator: Ensure user roles are only generated if roles already exist
no issue

Fixes the build, as in the test environment there are no user roles
2023-02-20 11:06:18 +00:00
Naz
d6f1e51dd6
Removed outdated post serialization code
refs 0306c397d0
refs https://github.com/TryGhost/Toolbox/issues/522

- 'extraProperties' should have been cleaned up along with the referenced commit. This property does not perform any logic in current codebase (see ref) and makes it problematic to make "post" resource serialization more generic (for caching purposes).
2023-02-20 18:34:31 +08:00
Daniel Lockyer
49ea1682d0
Added logging message when websockets client connects
- this helps with debugging because we can see when a client is
  connected
2023-02-20 11:31:33 +01:00
Sam Lord
37f16b1b17 Added roles to users in data generator
no issue
2023-02-20 09:26:28 +00:00
Sam Lord
36ea0cc6d6 Added labels to data-generator
no issue
2023-02-20 09:26:28 +00:00
Sam Lord
db7ac14467 Added offers to data generator
no issue

Can generate a pair of offers.

TODO: Add offers to the base-data pack
2023-02-20 09:26:28 +00:00
Sam Lord
22ac685354 Added pages to data-generator
no issue

Data generator will now add 3 pages by default - can add extra support here, e.g. webmentions later.
2023-02-20 09:26:28 +00:00
Sam Lord
c6e119ecf5 Allow data-generator to make scheduled and draft posts
no issue

Also adds visiblity options, paid, members-only and public
2023-02-20 09:26:28 +00:00
Naz
bb855cd462
Fixed timers in ttl cache tests
refs 95530a6617

- The timers on CI are too sensitive and failing tests. Made wait times relatively longer as a fix
2023-02-20 15:41:10 +08:00
Naz
95530a6617
Added optional in-memory TTL cache
refs https://github.com/TryGhost/Toolbox/issues/515

- We don't have a good way to test TTL caches without setting up Redis in the environment
- Adding in-memory cache adapter with TTL allows to run tests on CI without having to install Redis
- Also, TTL in memory cache can be a great substitution for Redis-based caches on instances that
have a lot of spare RAM and don't need to use Redis necessarily
- MemoryTTL cache accepts two parameters "TTL" and "max"
- TTL - is time in milliseconds to hold the value for in cache
- max - is the maximum amount of items to keep in the cache

- To use MemoryTTL cache specify following config in the cache section:
```
    "adapters": {
        "cache": {
            "imageSizes": {
                "adapter": "MemoryTTL",
                "ttl": 3600
            }
        }
    }
```
- Above config would apply MemoryTTL cache to imageSizes feature with TTL fo 3600 ms
2023-02-20 15:16:33 +08:00
renovate[bot]
77a65fee61
Update dependency sanitize-html to v2.10.0 2023-02-20 00:24:48 +00:00
renovate[bot]
61fd9cc74b
Update dependency c8 to v7.13.0 2023-02-17 21:21:52 +00:00
renovate[bot]
6703a0e91c
Update dependency i18next to v22.4.10 2023-02-17 16:06:34 +00:00
Ghost CI
dc51f4703f v5.35.0 2023-02-17 16:00:47 +00:00
Sam Lord
10a4a8eb12 Fixed tests for demo-data
no issue
2023-02-17 15:08:01 +00:00
Sam Lord
ca395a958c Added post analytics to data generator
no issue
2023-02-17 14:03:59 +00:00
Simon Backx
ffc0cc020a Updated coverage excemption list
Removed the wrapper class for the email service from coverage, because this only wires up a lot of dependencies, which is hard to test in a unit test because we also have to init all the dependencies in a unit test. It is already covered by E2E tests.
2023-02-17 14:27:59 +01:00
Simon Backx
ec3f262ea4 Increased scheduling default test timeout 2023-02-17 13:29:07 +01:00
Fabien "egg" O'Carroll
8908a51547 Improved verification logic for Mentions
refs https://github.com/TryGhost/Team/issues/2550

By using cheerio to parse the HTML we can correctly look for elements
which use the target URL as the href attribute, rather than doing a
plaintext search. This closer to what the spec says.
2023-02-17 19:07:11 +07:00
Fabien "egg" O'Carroll
e14d2e662b Wired up verification to MentionsAPI
refs https://github.com/TryGhost/Team/issues/2550

Whilst this isn't ideal making multiple requests for the same site
it's a first step towards verification properties, and can be
refactored to improve performance later. With the current volume of
incoming Webmentions we've seen so far this shouldn't be a problem.
2023-02-17 19:07:11 +07:00
Fabien "egg" O'Carroll
37cfb96d9f Added support for verified property to BookshelfMentionRepository
refs https://github.com/TryGhost/Team/issues/2549

This ensures we can persist the verification of a Mention to MySQL/SQLite3
2023-02-17 19:07:11 +07:00
Fabien "egg" O'Carroll
277a563138 Added ability to set verified when instantiating Mention
refs https://github.com/TryGhost/Team/issues/2548

We need to be able to do this outside of the verify method so that
repository implementations have the ability to create existing
instances without running expensive verification checks!
2023-02-17 19:07:11 +07:00
Fabien 'egg' O'Carroll
101cabb188
Added separate job service for webmentions (#16285)
[Added initial mentions-jobs
service](3656190114)

This is the result of running `cp -r jobs mentions-jobs` in the services
directory.

[Waited for mentions-jobs queue before
shutdown](2bb1a12a89)

This matches the functionality of the existing jobs service where we
will wait
for jobs to complete before closing the process.

[Used mentions-jobs service in the mentions
service](4e4f9fdd00)

This ensures that any delays in the mentions jobs queue does not effect
other
parts of the application.
2023-02-17 13:05:36 +01:00
Daniel Lockyer
2edfd8b8e0
Increased timeout to allow for delays in browser e2e test
- this test was randomly timing out, and the tests above allow for a
  greater timeout before failing
2023-02-17 12:13:09 +01:00
Aileen Booker
2f57e95a5d
Slack notifications service for Milestones behind flag (#16281)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4?pvs=4

- Added a `slack-notifications` repository which handles sending Slack
messages to a URL as defined in our Ghost(Pro) config (also includes a
global switch to disable the feature if needed) and listens to
`MilestoneCreatedEvents`.
- Added a `slack-notification` service which listens to the events on
boot.
- In order to have access to further information such as the reason why
a Milestone email hasn't been sent, or the current ARR or Member value
as comparison to the achieved milestone, I added a `meta` object to the
`MilestoneCreatedEvent` which then gets accessible by the event
subscriber. This avoid doing further requests to the DB as we need to
have this information in relation to the event occurred.

---------

Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
2023-02-17 12:59:18 +02:00
Steve Larson
034a230365 Added alpha feature to demonstrate websockets
refs https://github.com/TryGhost/Team/issues/2561

- added simple socket-io implementation to Ghost server
- added alpha flag for websockets
- added route in admin to test websockets using a simple counter stored in server local memory (refreshes on reboot)
2023-02-17 11:55:15 +01:00
Daniel Lockyer
e52efb31b8
Updated coverage exemption list
- like the members jobs, we don't need to run unit tests on these
  because they're not library code
2023-02-17 11:43:13 +01:00
Steve Larson
1e00bd2af9 Handled empty content when sending webmentions
refs https://ghost.slack.com/archives/C02G9E68C/p1676564978732119

- `cheerio` errors when trying to parse `null`
2023-02-17 10:46:48 +01:00
Naz
f27c7ba044
Fixed variable name typo 2023-02-17 17:27:51 +08:00
Naz
3ddfe59e15
Added resource caching to Posts/Pages Content API
refs https://github.com/TryGhost/Toolbox/issues/522

- Browse endpoints for Posts and Pages are creating the most database traffic in the system. These are read-only endpoints that don't have to be fresh 100% of the time. Having optional cache allows to offload some of the database querying to more efficient storage.
- To enable cache for Posts/Pages browse endpoints there are two prerequisites:
  - set 'hostSettings:postsPublicCache:enabled' to 'true' in the configuration file
  - add 'postsPublic' cache adapter in cache configuration

- Example config for adapters with 60s TTL for a cached resource:
```
    "adapters": {
        "cache": {
            "postsPublic": {
                "adapter": "Redis",
                "ttl": 60,
                "keyPrefix": "site_id_here:posts-content-api:"
            }
        }
    },
```
2023-02-17 17:27:51 +08:00
Naz
c3d7104367
Refactored tags repository to be model-agnostic
refs https://github.com/TryGhost/Toolbox/issues/522

- The caching rules for Content API resources like Tags / Posts / Pages / Authors are the same, so it makes sense to make a common repository which would take in a model as a parameter and perform the queries on that level instead of implementing repository-per-model.
- With this refactor getting Posts Content API caching would be much simpler change.
2023-02-17 17:27:51 +08:00
Steve Larson
5d00b64e27
Added timeout to external requests
no refs

- got doesn't have a timeout by default
- we think we might have hanging jobs because of this
2023-02-17 09:16:58 +01:00
Daniel Lockyer
9a2d765c73
Added one-off job name and current queue length into log line
- this makes it easier to know what jobs are being scheduled and what
  the current queue length is
2023-02-17 09:16:40 +01:00
Aileen Nowak
cd3930d08e Promote milestoneEmails to beta feature
no issue

- Promotes `milestoneEmails` to a beta feature so it can be a private beta to be tested
2023-02-17 07:45:51 +02:00
Aileen Nowak
1c0ee675fe Updated milestone values in default config 2023-02-17 07:45:51 +02:00
renovate[bot]
7de35f1ca3 Update dependency node-jose to v2.2.0 [SECURITY] 2023-02-17 05:29:46 +00:00
renovate[bot]
cf7ecb492c
Update dependency c8 to v7.13.0 2023-02-16 22:15:50 +00:00
Sam Lord
b4c90bf07d Reduced number of login events in large-scale data generation
no issue

This should massively increase the speed of importing for the large dataset, which is important as the time to import it on Pro is >10 minutes at the moment
2023-02-16 20:54:14 +00:00
renovate[bot]
38642af435 Update dependency cssnano to v5.1.15 2023-02-16 14:59:59 +01:00
Sam Lord
b8f59f07f2 Added --clear-database option to make it easier to use the data generator
no issue
2023-02-16 12:11:08 +00:00
Simon Backx
f8e77ad012 🐛 Fixed uploading images with custom storage adapters
fixes https://github.com/TryGhost/Ghost/issues/16278

`urlToPath` is not a method that is defined on the StorageBase, and thus is not implemented on any custom storage adapter.

We need this method to prevent uploading a file in two different directories. Currently this is an edge case:
- If you upload a file at midnight between a month shift, it is possible that we upload one file at `/2023/02/file.png` and the original at `/2023/03/file_o.png`
- To make sure we upload the second at the same directory, we need the `urlToPath` implementation. The save method sadly only returns the URL, which could be different than the stored file path, so we cannot use that return value.

This fix only uses `urlToPath` if available, to prevent above issue.
2023-02-16 11:49:37 +01:00
Simon Backx
8dfa490638
Added outbound link tagging for web posts (#16201)
fixes https://github.com/TryGhost/Team/issues/2433

- Moved all outbound link tagging code to separate OutboundLinkTagger
- Because a site can easily enable/disable this feature, we don't store
the ?refs in the HTML but add them on the fly for now in the Content
API.
2023-02-16 11:26:35 +01:00
Fabien "egg" O'Carroll
a310ec2e3e Fixed Mention unit test
refs https://github.com/TryGhost/Ghost/commit/c6b90b6ac
2023-02-16 14:37:22 +07:00
Fabien "egg" O'Carroll
c6b90b6ac7 Added verified property to Mentions Admin API
closes https://github.com/TryGhost/Team/issues/2551

Rather than blindly passing all data through the API we explicitly include each
new property. This allows us to make changes to the core entities without
affecting the API. The verified property is being added now to give design the
ability to display these mentions differently.

We also needed to include the verified property in the return value of toJSON,
this was missed as part of the original entity changes
2023-02-16 14:31:05 +07:00
Ghost CI
dd48f65712 Merged v5.34.1 into main 2023-02-16 07:23:52 +00:00
Ghost CI
443085ab87 v5.34.1 2023-02-16 07:23:49 +00:00
Naz
8a0c20b54c
Fixed Redis cluster ttl configuration
refs https://github.com/TryGhost/Toolbox/issues/520

- The cluster config is taking over local adapter ttl configuration - the priority should be reverse adapter config first followed by cluster config
- In addition if we add nested config merging to adapter manager we could achieve the same effect by having per-adapter configuraiton with "clusterConfig.options.ttl" value
2023-02-16 14:13:44 +08:00
John O'Nolan
14c5e48190
Improved micro copy on Portal email tips 2023-02-15 12:30:03 -04:00
Aileen Nowak
5f12c7ad40 Updated Milstone test to expect no event for existing milestone 2023-02-15 14:28:57 +02:00
Aileen Nowak
dc8dc90212 Exposed MilestoneCreatedEvent as module 2023-02-15 14:28:57 +02:00
Aileen Nowak
d482046a25 Moved event creation to all save events and not only new ones 2023-02-15 14:28:57 +02:00
Aileen Nowak
b55a95b944 Removed usage of GhostMailer in MilestonesService
no issue

- With the switch of using a `MilestoneCreatedEvent` we'll be decoupling the mailing functionality and not need `GhostMailer` as dependency in the package anymore
2023-02-15 14:28:57 +02:00
Aileen Nowak
513b7d1df4 Added MilestoneCreatedEvent using DomainEvents
no issue

- In preparation of using event emitting for Milestone achievements, we needed to add a dedicated `MilestoneCreatedEvent` to the `Milestone` entity.
- The event will be emitted using `DomainEvents` when a new milesteone is saved, which will allow us to listen to these events.
2023-02-15 14:28:57 +02:00
renovate[bot]
636ff6d4ef Update sentry-javascript monorepo to v7.37.2 2023-02-15 11:25:44 +01:00
Aileen Nowak
a400353881 Renamed milestone-emails to milestones
no issue

- The way we're going to implement milestones diverged from the original idea of handling email sending within the milestone-emails package, as we'll be sending events instead and will utilise the StaffService to listen to them and send the emails
- This renames the package as well as the service in core itself and all relevant tests
2023-02-15 10:43:05 +02:00
Aileen Booker
41e4132a17
Refactored milestones service to preserve API instance (#16272)
no issue

- For better testability with in-memory repository, refactor the
milestones service to preserve the API instance
- Fetching the information about Stripe live mode from Stripe service
was causing difficulties when testing. As a workaround we switched to
reading the live mode keys and determine it that way.

---------

Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
2023-02-15 08:43:40 +02:00
Naz
d62eba6c7f
Fixed Redis cluster ttl configuration
refs https://github.com/TryGhost/Toolbox/issues/520

- The cluster config is taking over local adapter ttl configuration - the priority should be reverse adapter config first followed by cluster config
- In addition if we add nested config merging to adapter manager we could achieve the same effect by having per-adapter configuraiton with "clusterConfig.options.ttl" value
2023-02-15 11:39:04 +08:00
Ronald Langeveld
f9eeec10db Updated email-preview test snapshot
no issue

- fixed up tests failing from the outdated email snapshot.
2023-02-15 11:21:37 +08:00
Peter Zimon
5bb5977a47 Fixed issue with bookmark cards width on Android
no refs.

- On Android Gmail client the bookmark cards were not taking the full width of the screen
2023-02-14 14:31:16 +01:00
Ronald Langeveld
c651f5b10f
Added verified mention column (#16264)
refs https://github.com/TryGhost/Team/issues/2549

- Added `verified` column to mentions table
- Added a new migration
- Updated schema
- Updated integrity test
2023-02-14 15:46:07 +08:00
renovate[bot]
7f278bd762 Update Test & linting packages 2023-02-14 04:25:29 +00:00
John O'Nolan
0334595a0e Updated post preview meta description prompt 2023-02-13 16:58:28 -04:00
John O'Nolan
4f3733a7cf 🎨 Improved meta description preview 2023-02-13 16:30:02 -04:00
Ghost CI
e8d3add2bd v5.34.0 2023-02-13 17:04:36 +00:00
Kevin Ansfield
6fe8154329
Fixed email rendering of lexical posts
refs c489343831

- `lexicalLib.lexicalHtmlRenderer` can't be used directly because it's missing required config for nodes to render properly
- updated email serializers to use `lexicalLib.render()` instead
2023-02-13 16:48:30 +00:00
Kevin Ansfield
c489343831
Fixed saving and rendering of Lexical posts containing new cards
closes https://github.com/TryGhost/Team/issues/2558

- bumped `kg-lexical` packages so we're working with latest suite of default nodes and renderer
- added a `render()` method directly to our `lexicalLib` object
  - allows us to pass through all of Ghost's config for image transforms etc in one place rather than every time we want to render something
2023-02-13 16:35:34 +00:00
Simon Backx
4e361a65fa Added webmention delete test and cleaned up webmention tests
refs https://github.com/TryGhost/Team/issues/2553

- Added webmention delete test
- Fixed dangling promise in test
- Fixed missing .persist in tests
2023-02-13 17:15:34 +01:00
Daniel Lockyer
4bca725215
Added basic unit test for cache adapter module
- this helps improve our testing capabilities of the new cache adapters
2023-02-13 17:10:42 +01:00
Kevin Ansfield
247d0f1f92
Removed editor.url from config.development.json
no issue

- local development Ghost installs should not default to a locally served `koenig-lexical.umd.js` file but should use the default CDN version
- a locally served file should be set in `config.local.json` when you want to develop against an unreleased version
2023-02-13 15:10:49 +00:00
Kevin Ansfield
440d4c41f9
Fixed media thumbnail uploads in koenig-lexical editor
no issue

- added `requestMethod` to `fileTypes` map
- added pass-through of `formData` options to `upload(file, options)` so `url` property can be passed to map uploaded image file to media file
- fixed `resourceName` for media thumbnail uploads
2023-02-13 15:00:29 +00:00
Simon Backx
0e8d13bdde 🐛 Fixed email replacements without fallback
fixes https://github.com/TryGhost/Team/issues/2557

When a member doen't have a name, and the first_name replacement doesn't have a fallback, we did show %recipient.first_name% instead of an empty string.
2023-02-13 15:58:40 +01:00
Aileen Booker
6f0d1b0ff9
Added milestone email service behind alpha flag (#16241)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4

Added milestone email service behind a flag. The service will currently
run on boot and is meant to be scheduled soon, which should happen in
the next step. For now it's protected behind the alpha flag.
2023-02-13 16:29:01 +02:00
Simon Backx
48f9485f46
🐛 Fixed storing email failures with an empty message (#16260)
no issue

- When we receive an email failure with an empty message, the saving of
the model would fail because of schema validation that requires strings
to be non-empty.
- This adds more logging to the email analytics service to help debug
future issues
- Performance improvement to storing delivered, opened and failed emails
by replacing COALESCE with WHERE X IS NULL (tested and should give a
decent performance boost locally).
2023-02-13 15:25:36 +01:00
Kevin Ansfield
fb882e2e2a
Updated koenig-lexical upload function to handle multiple file types
refs https://github.com/TryGhost/Koenig/pull/491

- `<KoenigComposer>` now takes a `fileUpoader` object in place of `imageUploadFunction`
- updated the upload functions in `koenig-lexical-editor.js` to match expected patterns, handle multiple files and file types, and return expected upload progress, result, and error details
2023-02-13 13:38:35 +00:00
Sam Lord
9e42d1356a Updated avatar styles for webmentions
no issue

This makes the style for generated webmentions much better.
2023-02-13 13:16:24 +00:00
Fabien "egg" O'Carroll
90b7a3f4d0 Added verified member and verify method to Mention entity
closes https://github.com/TryGhost/Team/issues/2548

Rather than use a setter here we've used a verify method which takes the HTML
string and naively validates that the target URL is present. This is so that the
logic of verification is encapsulated in the Mention, and should mean that
erroneous verification doesn't happen.

We could consider down the line that the verify method fetches the content
itself, but if we're to do that we should pass in `got` as a param, so that it's
possible to stub in tests.

One thing to think about when it comes time to making this as performant as
possible is doing a single fetch of the source document and using that for
verification and metadata extraction. At that point we should probably
consolidate both of those operations, either moving the metadata extraction into
the Mention entity (passing in any necessary deps) OR we move the verification
out to the same layer as metadata extraction.
2023-02-13 19:23:34 +07:00
Fabien "egg" O'Carroll
bf6bcdbff3 Added e2e tests for updating Mentions
closes https://github.com/TryGhost/Team/issues/2552

We send a Webmention for the same URL twice, but change the contents
of the source document, and we check that the source metadata is
updated appropriately.

We should consider extending all of these tests to include featured
images and logos etc...
2023-02-13 19:09:31 +07:00
Simon Backx
77032262c4
🐛 Fixed subscriptions visible as "Active" within Ghost Admin (#16255)
fixes https://github.com/TryGhost/Team/issues/2542 
fixes https://github.com/TryGhost/Team/issues/2543 
fixes https://github.com/TryGhost/Team/issues/2544

- Hides incomplete subscriptions
- Shows Past Due subscriptions
- Fixed UI issues with 3+ subscriptions
- Fixed missing complimentary subscription when one subscription was
incomplete/inactive
- Fixed sending a paid subscription started email for incomplete
subscriptions. This change also required us to actually send the email
when the incomplete subscription eventually becomes active. So the
introduction of a new `SubscriptionActivatedEvent` made sense/was
required (because sending a SubscriptionCreatedEvent again would cause
other issues).
2023-02-13 13:07:53 +01:00
Naz
7c18263227 Extracted adapter-cache-redis from core codebase
refs https://github.com/TryGhost/Toolbox/issues/515

- This implementation allows to use Redis cluster as a caching adapter. The cache adapter can be configured through same adapter configuration interface as others. It accepts following config values:
  - "ttl" - time in SECONDS for stored entity to live in Redis cache
  - "keyPrefix" - special cache key prefix to use with stored entities
  - "host" / "port" / "password" / "clusterConfig" - Redis instance specific configs
- Set test coverage to non-standard 75% because the code mostly consists of the glue code that would require unnecessary Redis server mocking and would be a bad ROI. This module has been used in production for a long time already, so can be considered pretty stable.
2023-02-13 19:01:43 +08:00
Naz
b3252f956f Added adapter-cache-redis package
refs https://github.com/TryGhost/Toolbox/issues/515

- Redis-based caches can be used on hosted-environments to store information with high memory impact - when in-memory caches would be too impractical to use
- This is a placeholder package for a cluster-aware Redis cache implementation compatible with Ghost's cache adapter interface (a41d351f16/packages/adapter-base-cache)
2023-02-13 19:01:43 +08:00
Naz
1c12d789f9 Added async cache support to Tags repository
refs https://github.com/TryGhost/Toolbox/issues/515

- The caches relying on external storage like e.g.: Redis, the get/set operations are usually async. The tags repository should be working with these as caching is expected to be non-in-memory for these data.
2023-02-13 19:01:43 +08:00
Naz
9d4ea7b8c9 Moved cache initialization behind the hostSetting
refs https://github.com/TryGhost/Toolbox/issues/515

- By moving the cache initialization behind the hostSettings configuration we can limit the experimental feature to only hosted environments with special capacities
- An example configuration to enable Tags caching looks like this:
```
    "hostSettings": {
        "tagsPublicCache": {
            "enabled": true
        },
```
In addition to have the caching backed by a Redis backend or even InMemoryTTL cache the site configuration should include a cache adapter configuration like this:
```
    "adapters": {
        "cache": {
            "active": "Memory",
            "tagsPublic": {
                "adapter": "TTL",
                "ttl": 60000 // 60 * 1000 minute
            },
```
2023-02-13 19:01:43 +08:00
Naz
5216220541 Public tags repository caching
refs https://github.com/TryGhost/Toolbox/issues/515

- There are a lot of repeated cacheable tag-related queries coming from
{{get}} helpers in themes that can be cached.
- Having a repository layer deal with very specific type of query allows
to add extra functionality, like caching, on top of the database query
- This commit is wiring code that addds a default in-memory cache to
all db queries. Note, it lasts forever and has no "reset" listeners. The
production cache is mean to have a short time-to-live (TTL) - removes a need
to keep the cache always fresh.
- Kept the cache key shortened. Without a "context" and any other non-model options the cache-key can store more variations of queries. For example, there is no member-specific or integration-specific query results, so having those in the cache key would only partition the cache and use up more memory.
2023-02-13 19:01:43 +08:00
renovate[bot]
b48262b5d8 Update sentry-javascript monorepo to v7.37.1 2023-02-13 09:22:57 +01:00
renovate[bot]
ccfe6dd638 Update dependency minimist to v1.2.8 2023-02-13 09:21:59 +01:00
Fabien 'egg' O'Carroll
57695d03df
Fixed rate limit test (#16258)
closes https://github.com/TryGhost/Team/issues/2547

Changed the configuration for testing to be a bit more strict, by slowing down the amount of requests it can handle to give CI enough time to kick in the rate limiter. Before this, CI simply wasn't hitting the API fast enough to trigger the rate limiter.

Co-authored-by: Ronald Langeveld <hi@ronaldlangeveld.com>
2023-02-13 15:16:56 +08:00
renovate[bot]
2c9fb2ad5e
Update dependency ember-template-lint to v5.5.0 2023-02-10 11:43:30 +00:00
Kevin Ansfield
d6b8ff124b
Updated <KoenigComposer> props to use generic cardConfig object
refs aed55d415d

- `unsplashConfig` has changed to a generic `cardConfig` object
2023-02-10 11:13:57 +00:00
Ronald Langeveld
b37aff52ca Mention alert toggle only visible to admins
refs https://ghost.slack.com/archives/C02G9E68C/p1675916876727609

- Added the mentions alert toggle to only be visible to owners and
  admins, since it will not have any effect for non-admins staff users.
2023-02-10 17:24:02 +08:00
Fabien "egg" O'Carroll
3df19235b0 Added support for updating Mentions when Webmentions are resent
refs https://github.com/TryGhost/Team/issues/2535

At the moment we only update the metadata of the Webmention source, so
that we can capture update titles, excerpts, etc... when a post is updated.
2023-02-10 11:43:16 +07:00
Fabien "egg" O'Carroll
78bebc6279 Refactored the assignment of Mention metadata
refs https://github.com/TryGhost/Team/issues/2535

Moving this into a separate method allows us to set the metadata externally from
the Mention entity and keep all of the validation, without having duplicate code
2023-02-10 11:43:16 +07:00
renovate[bot]
b271d5a53a Update metascraper to v5.33.8 2023-02-10 02:02:53 +00:00
renovate[bot]
3a11525ad7
Update dependency mysql2 to v3.1.2 2023-02-09 20:10:27 +00:00
Daniel Lockyer
49e9be4368 Reconfigured clean-expired-comped job to execute during morning UTC
refs https://ghost.slack.com/archives/C04MSE4MKJT/p1675948815531779

- running at a fixed hh:mm every day means a platform with a large number
  of Ghost sites will get hammered with DB requests when they all start
  up
- this reconfigures the cron to run at a random minute and second
  between 0am and 5am, which gives a 6 hour window
2023-02-09 15:58:43 +01:00
John O'Nolan
5b4abea56d
Fixed broken link 2023-02-09 10:53:53 -04:00
Ronald Langeveld
4096571b8d Commented out flaky webmention test
refs https://ghost.slack.com/archives/C02G9E68C/p1675934676146349

- Commented out the rate limiter test as it proves to be flaky on CI,
  till we find a better way of implementing it.
2023-02-09 21:35:15 +08:00
Fabien 'egg' O'Carroll
4e8af72305
Added support for deleting mentions (#16238)
refs https://github.com/TryGhost/Team/issues/2534

As we're using soft deletes for mentions we need to store the `deleted` column
as well as enforce a `'deleted:false'` filter on the bookshelf model. 

We've also implemented the handling for deleting mentions. Where we remove a
mention anytime we receive and update from or to a page which no longer exists.

Co-authored-by: Steve Larson <9larsons@gmail.com>
2023-02-09 17:29:13 +07:00
Steve Larson
d20696805f
Added mentions deleted column (#16251)
refs https://github.com/TryGhost/Team/issues/2534

This is so that we can support soft deletes for Mentions.
We need to add the defaults to the model so that write continue to work.

Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
2023-02-09 16:19:07 +07:00
Daniel Lockyer
d750612508
Merged v5.33.8 into main
v5.33.8
2023-02-09 10:08:43 +01:00
Ghost CI
83bf4ccb53 v5.33.8 2023-02-09 09:06:34 +00:00
Ronald Langeveld
ce567b9816
Added Mentions email notification settings (#16245)
closes https://github.com/TryGhost/Team/issues/2526

- Mention emails can now be toggled inside staff user' profiles, if they
have the webmention flag enabled on their Ghost site.
- Removed the flag dedicated to webmention email notifications and is
now handled by the `webmention` flag.
- Does not send email notification if `webmention` flag is not enabled.
- Updated tests.

---------

Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
2023-02-09 17:03:03 +08:00
Simon Backx
da97519082 Moved email event fetching to main thread (#16231)
refs https://github.com/TryGhost/Team/issues/2482

This moves the processing of Mailgun events to the main thread. By using a simple approach where we emit a start event on the worker thread (via the job manager) and listen for it on the main thread. This is needed because for now the job manager doesn't support scheduling periodic jobs on the main thread (not offloaded).

Apart from that, the email processor now uses the email event storage directy instead of emitting events (it is still emitting event for now). This makes sure we await for the event to be processed before continuing with the next event.
2023-02-09 09:44:44 +01:00
Simon Backx
ea2c69565f
Moved email event fetching to main thread (#16231) 2023-02-09 09:36:39 +01:00
renovate[bot]
fd79ca3f5a Update dependency html-validate to v7.13.2 2023-02-09 09:30:14 +01:00
Simon Backx
b7be02f057
🐛 Fixed throwing errors during link redirects
no issue

Errors weren't correctly passed on to Express in the middleware.
2023-02-09 09:26:45 +01:00
Kevin Ansfield
f7aefa2feb
🐛 Fixed default email recipients always being "everyone" rather than matching post visibility (#16247)
refs https://github.com/TryGhost/Ghost/issues/16125

The previous fix for incorrect recipient details being shown when
re-sending a failed email introduced another bug that prevented the
"Match post visibility" default recipients setting from working.

- the server always sets `post.emailSegment` to `'all'` for new posts so
the publish flow recipient filter logic that checked for
`post.emailSegment` being present always defaulted to `'all'` rather
than falling back to the selected default recipients setting
- when a post has been published but the email failed it will have its
`newsletter` value set so we can use that as a check for using the
`post.emailSegment` value in place of the default recipients setting
2023-02-09 09:24:50 +01:00
Ronald Langeveld
30dc2a8228
Added mention_notifications column (#16242)
refs https://github.com/TryGhost/Team/issues/2526

- created a migration for a new boolean column in users that would
determine if the staff user gets an email when the publication receive a
new mention.
2023-02-09 16:15:54 +08:00
Ronald Langeveld
9fc13cfe65
Implemented mentions rate limiter (#16223)
closes https://github.com/TryGhost/Team/issues/2419

- adds a rate limiter implementation to the mentions receiving
endpoint.
- Current configuration is `{"minWait": 10,
             "maxWait": 100,
             "lifetime": 1000,
             "freeRetries": 100}` which is still very open and almost unrestricted. 
- currently makes use of database storage to track the limits, but can be relatively easily swapped out to something eg Redis should we find this endpoint getting hit too often and maliciously.
2023-02-09 14:57:48 +08:00
Naz
93a10d8f4f Optimized queries for tiers (aka products)
refs https://github.com/TryGhost/Toolbox/issues/515
refs dd4d6aeae5

- The `productRepository.list` call produced 5 db queries and a transaction wrapping this call.
- Transaction is not needed in this situation as there are no possible writes in the meantime (transaction wrapping code was put in there through refed commit to guard against failing Stripe API calls, which are no longer involved when calling the list method)
-  The `limit: 'all'` makes sure all product entries are fetched AND removes an extra aggregation query called over stripe_prices join
- The 'monthlyPrice' and 'yearlyPrice' relations are not needed because this data is not used in downstream code - only slug and type are used for visiblity/content gating  (ref. 1 3b6759ca6d/ghost/core/core/server/services/members/content-gating.js (L44-L55), ref. 2 3b6759ca6d/ghost/core/core/server/api/endpoints/utils/serializers/output/mappers/posts.js (L39-L54))
2023-02-09 13:07:57 +08:00
Steve Larson
6c97edec25
moved sending mentions to job (#16234)
refs TryGhost/Team#2523
-implemented jobsService within mention sending service
-updated tests so we don't need to sleep
2023-02-08 16:29:12 -06:00
Sam Lord
0d7944861c Data generator: Swap order of free and premium newsletters
no issue
Free and premium newsletters were the other way around in the demo-data. This was a good opportunity to stop the email table importer from relying on the newsletter name, and use the order alone.
2023-02-08 22:12:19 +00:00
Kevin Ansfield
923a9a1cd6
🐛 Fixed default email recipients always being "everyone" rather than matching post visibility (#16247)
refs https://github.com/TryGhost/Ghost/issues/16125

The previous fix for incorrect recipient details being shown when
re-sending a failed email introduced another bug that prevented the
"Match post visibility" default recipients setting from working.

- the server always sets `post.emailSegment` to `'all'` for new posts so
the publish flow recipient filter logic that checked for
`post.emailSegment` being present always defaulted to `'all'` rather
than falling back to the selected default recipients setting
- when a post has been published but the email failed it will have its
`newsletter` value set so we can use that as a check for using the
`post.emailSegment` value in place of the default recipients setting
2023-02-08 11:41:48 +00:00
Simon Backx
4436a1cd18 🐛 Fixed throwing errors during link redirects
no issue

Errors weren't correctly passed on to Express in the middleware.
2023-02-08 11:50:22 +01:00
Aileen Booker
3b6759ca6d
Added initial basic milestone emails in-memory repository (#16216)
refs
https://www.notion.so/ghost/Marketing-Milestone-email-campaigns-1d2c9dee3cfa4029863edb16092ad5c4

This adds a milestone entity and in-memory repository in a new
`milestone-emails` package. This also adds a first initial definition of
milestones and their types which is held in the default config to avoid
DB changes when, e. g. values change.

This should get everything in place to begin with the service
implementation.
2023-02-07 12:47:35 +02:00
Ghost CI
c518446c17 Merged v5.33.7 into main 2023-02-07 10:32:47 +00:00
Ghost CI
ca568817dd v5.33.7 2023-02-07 10:32:43 +00:00
Simon Backx
ac2daccf95 Added short lived caching to email batch body (#16233)
fixes https://github.com/TryGhost/Team/issues/2522

When sending an email for multiple batches at the same time, we now
reuse the same email body for each batch in the same segment. This
reduces the amount of database queries and makes the sending more
reliable in case of database failures.

The cache is short lived. After sending the email it is automatically
garbage collected.
2023-02-07 11:30:37 +01:00
Simon Backx
fb3cbe5fc8
Added short lived caching to email batch body (#16233)
fixes https://github.com/TryGhost/Team/issues/2522

When sending an email for multiple batches at the same time, we now
reuse the same email body for each batch in the same segment. This
reduces the amount of database queries and makes the sending more
reliable in case of database failures.

The cache is short lived. After sending the email it is automatically
garbage collected.
2023-02-07 11:01:49 +01:00
renovate[bot]
654a991c98 Update dependency mysql2 to v3.1.1 2023-02-07 09:20:11 +01:00
Sam Lord
e0bcb26600 Improved data-generator tooling
no issue

This makes the data-generator more customisable.
2023-02-06 10:42:56 +00:00
renovate[bot]
c01875b85c Update sentry-javascript monorepo to v7.36.0 2023-02-06 10:26:32 +01:00
renovate[bot]
b76466946e Update dependency @types/express to v4.17.17 2023-02-06 10:26:06 +01:00
renovate[bot]
d60fea59e2 Update dependency terser to v5.16.3 2023-02-04 04:47:16 +00:00
Steve Larson
efd01f649b removed suppressionList from labs settings 2023-02-03 14:57:30 -06:00
Steve Larson
5ccb778ac8
enabled always sending mentions (#16227)
refs TryGhost/Team#2507
-removed labs check from sending service
-labs flag controls seeing mentions in admin and receiving mentions
2023-02-03 14:52:20 -06:00
Steve Larson
02953490a5
added mention sending service e2e tests (#16226)
refs TryGhost/Team#2508
-added sending service e2e tests
-should job off this sending service for better tests
-and for ghost to finish processing the job before shutdown
2023-02-03 10:45:50 -06:00
Ghost CI
d37ed200ab Merged v5.33.6 into main 2023-02-03 13:41:48 +00:00
Ghost CI
8e72332c77 v5.33.6 2023-02-03 13:41:45 +00:00
Simon Backx
30b9d02f70 Increased wait time between Mailgun events to 200ms
no issue

Reduce concurrency if the database is going a bit slower, until we have more permanent fix for this.
2023-02-03 14:38:44 +01:00
Djordje Vlaisavljevic
3f7b717c0f Added logic to display target post titles
refs https://github.com/TryGhost/Team/issues/2481
2023-02-03 11:18:03 +00:00
Djordje Vlaisavljevic
5f1bdd6d87 Fixed scroll state issue
refs https://github.com/TryGhost/Team/issues/2434
2023-02-03 11:18:03 +00:00
Djordje Vlaisavljevic
2e379809d0 Updated timestamp design
refs https://github.com/TryGhost/Team/issues/2434
2023-02-03 11:18:03 +00:00
Simon Backx
29e1e93ca1 Increased wait time between Mailgun events to 150ms
no issue

Reduce concurrency if the database is going a bit slower, until we have more permanent fix for this.
2023-02-03 10:39:55 +01:00
Simon Backx
4fad1986a0 🐛 Fixed link to posts on audio cards in emails
refs https://ghost.slack.com/archives/CTH5NDJMS/p1675356984043299

The url property doesn't exists on post, this was copied from the old MEGA flow that serialized the model first.
2023-02-03 10:37:02 +01:00
Naz
b35b1ae98b
Added cleanup note
refs https://github.com/TryGhost/Toolbox/issues/516
refs 4c60cdce9c

- The syntax used to skip non-`/r/` routes is unreadable. Needs a little love during cleanup
2023-02-03 13:11:59 +08:00
Simon Backx
0f08f39a1b 🐛 Fixed link to posts on audio cards in emails
refs https://ghost.slack.com/archives/CTH5NDJMS/p1675356984043299

The url property doesn't exists on post, this was copied from the old MEGA flow that serialized the model first.
2023-02-02 18:19:31 +01:00
Ghost CI
509affb1f7 Merged v5.33.5 into main 2023-02-02 16:33:50 +00:00
Ghost CI
771a6182c7 v5.33.5 2023-02-02 16:33:46 +00:00
Naz
32cd3b9433 Optimized link redirects handling
refs https://github.com/TryGhost/Toolbox/issues/515

- The link redirect handled was querying database on every single frontend request causing a significant amount of unnecessary traffic
- The optimization is returning early if the incoming URL does not start with a common "r/" prefix
2023-02-02 17:27:30 +01:00
Ghost CI
f90d6ca66b Merged v5.33.4 into main 2023-02-02 13:33:14 +00:00
Ghost CI
3f5e34f840 v5.33.4 2023-02-02 13:33:10 +00:00
Kevin Ansfield
1ffb92dd27
Re-build .lint-todo file
no issue

- deleted the file and ran `yarn lint:hbs --update-todo` to clean up fixed errors in the todo list and reset the hide->warn dates
2023-02-02 13:13:59 +00:00
Simon Backx
06de10786f
Added automatic database query retrying to the email service (#16218)
fixes https://github.com/TryGhost/Team/issues/2512

The email sending is a crucial flow that should not be interrupted. If
there are database connection issues, we should try to recover from them
automatically by retrying individual database queries and transactions
for a limited amount of time.

This adds a helper method to retry database operations. It limits all
database queries before sending the actual email to maximum 10 minutes.
Database operations that happen after sending have a higher retry time
because they are more crucial to prevent data loss (e.g. saving that an
email was sent).
2023-02-02 14:12:54 +01:00
Kevin Ansfield
5f5ae79897
Fixed template lint error
refs 7f1e970a0b

- `koenig-card-callout.hbs` was touched without fixing the lint errors or updating to todo list causing the lint todos to become out of sync
- fixed the lint error and updated the todo list
2023-02-02 13:12:03 +00:00
Robin Cussol
1c019a3f35
Added e2e tests for page.unscheduled webhook (#15722)
refs: https://github.com/TryGhost/Ghost/issues/15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.
2023-02-02 13:03:23 +00:00
Tihomir Valkanov
7f1e970a0b
🐛 Fixed emoji causing page jump in safari (#16026)
fixes: https://github.com/TryGhost/Ghost/issues/15295

- By design Safari [does not support focus on a button
element](https://bugs.webkit.org/show_bug.cgi?id=22261). We have to keep
the focus somehow otherwise we cause page jump in Safari when changing
the emoji. Tabindex -1 is a good choice because it does not mess with a
tab sequence if we have one.
2023-02-02 12:59:24 +00:00
Fabien "egg" O'Carroll
669b1927aa Promoted webmentions to private beta
refs https://github.com/TryGhost/Team/issues/2509
2023-02-02 16:42:13 +07:00
Fabien "egg" O'Carroll
e5d31e2900 Added resource data to Mentions Admin API
refs https://github.com/TryGhost/Team/issues/2503

This is in the MentionController atm as it's considered a presentation
concern. We might want to consider moving this into the MentionsAPI in
future so that we can simplify the controller and even remove it
completely in favour of putting the data-mapping in the endpoint definition.
2023-02-02 16:13:49 +07:00
Ronald Langeveld
bef3516f72 Added e2e test for filtering members by tier id
no issue

- Added a test for filtering members by tier id since we now have a new
  way of filtering members in the admin.
2023-02-02 15:10:19 +08:00
Naz
4c60cdce9c
Optimized link redirects handling
refs https://github.com/TryGhost/Toolbox/issues/515

- The link redirect handled was querying database on every single frontend request causing a significant amount of unnecessary traffic
- The optimization is returning early if the incoming URL does not start with a common "r/" prefix
2023-02-02 15:04:52 +08:00
Ronald Langeveld
e02c67dd3a
Mentions ordering (#16215)
closes https://github.com/TryGhost/Team/issues/2498

- can now order mentions via the API via params eg `api/admin/mentions/?order=created_at%20desc`.
2023-02-02 13:25:09 +08:00
Steve Larson
855bcb8613 added tests to cover internal data checks
no ref
-tests didn't cover imported data escape
-tests didn't cover internal data escape
2023-02-01 17:40:29 -06:00
Steve Larson
3186323663 updated listeners in test to be fully inclusive
no ref
-test wasn't previously updated to include all event listeners
2023-02-01 17:20:24 -06:00
Steve Larson
ae92d1425d
updated events that send mentions (#16219)
refs TryGhost/Team#2477
-removed post.edited as it was too inclusive
-changed to post.published, post.published.edited, post.unpublished
-blocked import and internal data from triggering mentions
2023-02-01 16:49:58 -06:00
renovate[bot]
5367fa94cc
Update dependency sanitize-html to v2.9.0 2023-02-01 15:39:45 +00:00
Ronald Langeveld
24681398af
🐛 Fixed members tier filtering (#16212)
refs https://ghost.slack.com/archives/CTH5NDJMS/p1675194453354469 https://secure.helpscout.net/conversation/2127479135/94711

- replaced tiers filtering by `slug` with `id` as we hit an edge case where the NQL filtering is struggling to handle slugs with a single character, eg `a`, `b`. Now filters by the tier's `id` instead.
- added new member, `tier_id` relation to make it possible to filter by id, eg `/?filter=tier_id:<id>`.
2023-02-01 20:33:57 +08:00
Sam Lord
1c0a0e0549 Added email table to data generator
refs: https://github.com/TryGhost/Toolbox/issues/454
2023-02-01 11:58:20 +00:00
Ghost CI
a444d2e703 Merged v5.33.3 into main 2023-02-01 11:07:22 +00:00
Ghost CI
e82ed951f4 v5.33.3 2023-02-01 11:07:19 +00:00
Kevin Ansfield
3c695064bd
🐛 Fixed blank email previews when opening from member activity feeds (#16207)
refs https://github.com/TryGhost/Team/issues/2506

`email` objects no longer contain a `html` field and the fallback logic in the email preview modal was failing resulting in a 404 from trying to fetch an email preview using the email id rather than a post id.

- added quick-fix to the preview modal logic to use `data.post_id || data.id` for generating the preview URL (previous logic never expected to reach the fallback when working with an email record)
2023-02-01 09:52:45 +00:00
Fabien "egg" O'Carroll
72d7580461 Added source_is_ghost flag to outgoing Webmentions
This is a pretty simple way for us to track which webmentions are sent
by Ghost. Although it's easily spoofed, so are other approaches like
using a header (e.g. User-Agent). If we find that this data is being
spoofed we can look at different approach.

Becuase our receiving implementation stores the payload of the
Webmention, we'll be able to know inside Ghost which Mentions
originated from another Ghost installation, which is useful for stats
and gives us the possibility to display that information in the feed.

Longer term we might want to consider storing this data in a separate
column for Mentions, rather than the `payload` column - but that is
outside the scope of this change.
2023-02-01 13:44:55 +07:00
renovate[bot]
c34735f8a2 Update dependency terser to v5.16.2 2023-01-31 19:05:50 +00:00
Simon Backx
4f889586ad
🐛 Fixed email header image width not set (#16210)
refs
https://ghost.slack.com/archives/CTH5NDJMS/p1675182725388589?thread_ts=1675181248.903819&cid=CTH5NDJMS

Missing dependency was causing image widths not set
2023-01-31 18:51:36 +01:00
Ghost CI
356c370905 Merged v5.33.2 into main 2023-01-31 14:37:47 +00:00
Ghost CI
444ca6f5e5 v5.33.2 2023-01-31 14:37:44 +00:00
Naz
25d81c99ca
Fixed {{price}} helper to render empty instead of throwing
refs https://github.com/TryGhost/Toolbox/issues/497
refs fb7532bf5d

- We downgraded the 'GS090-NO-PRICE-DATA-CURRENCY-CONTEXT' rule in gscan to non-fatal, meaning Ghost should not be throwing an error but instead render an empty value for {{price}} helper when price data is empty.
- For example, a legacy syntax like this: '{{price currency=@price.currency}}' should not cause a page render error but return an empty price string.
- The pattern of returning an empty string instead of crashing is used in other helpers like {{img_url}} and and {{url}}
2023-01-31 22:14:43 +08:00
Naz
9390f0953f
Fixed {{price}} helper to render empty instead of throwing
refs https://github.com/TryGhost/Toolbox/issues/497
refs fb7532bf5d

- We downgraded the 'GS090-NO-PRICE-DATA-CURRENCY-CONTEXT' rule in gscan to non-fatal, meaning Ghost should not be throwing an error but instead render an empty value for {{price}} helper when price data is empty.
- For example, a legacy syntax like this: '{{price currency=@price.currency}}' should not cause a page render error but return an empty price string.
- The pattern of returning an empty string instead of crashing is used in other helpers like {{img_url}} and and {{url}}
2023-01-31 21:01:19 +08:00
Simon Backx
62ab5073ac Fixed Playwright test not awaiting Stripe setup
no issue

The test closed the setup modal to fast, which caused the @task to be cancelled and the save would not complete (portalPlans not saved).
2023-01-31 11:26:42 +01:00
renovate[bot]
a85c2ad3d6 Update metascraper to v5.33.7 2023-01-31 10:16:20 +01:00
renovate[bot]
02ca1940f8 Update dependency mysql2 to v3.1.0 2023-01-31 10:16:05 +01:00
Hannah Wolfe
9475c9404c
Fixed minor comment typo in boot
- nothign to see here!
2023-01-31 09:07:08 +00:00
Ronald Langeveld
c77984e6ab
Added mentions permissions (#16200)
closes https://github.com/TryGhost/Team/issues/2420

- Added user roles and permissions for the mentions admin API.
- We only have a `browse` function for our current use case, accessible
by `administrator` and `admin integration`.
2023-01-31 16:40:44 +08:00
renovate[bot]
5ab7654695 Update Test & linting packages 2023-01-31 05:44:54 +00:00
Djordje Vlaisavljevic
f24a3d649f Fixed link to mentions feed
refs https://github.com/TryGhost/Team/issues/2481
2023-01-30 21:53:05 +00:00
Djordje Vlaisavljevic
368d110b1b Fixed feature images not showing in mentions feed
refs https://github.com/TryGhost/Team/issues/2502
2023-01-30 21:49:40 +00:00
Simon Backx
8a153a83ad Improved job manager unit test stability 2023-01-30 17:26:38 +01:00