Commit Graph

893 Commits

Author SHA1 Message Date
Simon Backx
f4fdb4fa6c
Added new email event processor (#15879)
fixes https://github.com/TryGhost/Team/issues/2310

This moves the processing of the events from the event-processor to a
new email-event-processor in the email-service package.

- The `EmailEventProcessor` only translates events from
providerId/emailId to their known emailId, memberId and recipientId, and
dispatches the corresponding events.
- Since `EmailEventProcessor` runs in a separate worker thread, we can't
listen for the dispatched events on the main thread. To accomplish this
communication, the events dispatched from the `EmailEventProcessor`
class are 'posted' via the postMessage method and redispatched on the
main thread.
- A new `EmailEventStorage` class reacts to the email events and stores
it in the database. This code mostly corresponds to the (now deleted)
subclass of the old `EmailEventProcessor`
- Updating a members last_seen_at timestamp has moved to the
lastSeenAtUpdater.
- Email events no longer store `ObjectID` because these are not
encodable across threads via postMessage
- Includes new E2E tests that test the storage of all supported Mailgun
events. Note that in these tests we run the processing on the main
thread instead of on a separate thread (couldn't do this because
stubbing is not possible across threads)

There are some missing pieces that will get added in later PRs (this PR
focuses on porting the existing functionality):
- Handling temporary failures/bounces
- Capturing the error messages of bounce events
2022-11-29 11:15:19 +01:00
Fabien 'egg' O'Carroll
a95cc4e7ac
Lowered minimum function coverage tests (#15894)
refs https://github.com/TryGhost/Ghost/pull/15877
refs https://github.com/TryGhost/Ghost/pull/15892

We've been running into issues with unit test coverage in the references
PR's and have tried adding unit tests, but the problem persists. We're
lowering this to unblock development.
2022-11-29 16:55:53 +07:00
Rishabh
64ac47f4ef Added table to store email recipient failures
refs https://github.com/TryGhost/Team/issues/2291

When sending out mails to individual recipients, its possible that recipient gets a temporary or permanent failure for receiving the mail. Temporary failures can generally get resolved after a bit when the recipient’s mail server accepts the email, unlike permanent failures. For both customer visibility and easier debugging on what went wrong while delivering to a particular recipient, we’ll store the permanent/temporary failure for a recipient.

- migration adds a new table that stores the failure information for the recipients
2022-11-29 15:19:36 +05:30
Naz
a2d487e074
Removed db schema config from test coverage
refs https://ghost.slack.com/archives/C02G9E68C/p1669707419081529?thread_ts=1669702577.532999&cid=C02G9E68C
refs https://github.com/TryGhost/Toolbox/issues/117

- Database schema definition file is a special type of "configuration" file containing mostly static declarations. This sort of code should not be tested by unit tests, rather by e2e tests
2022-11-29 14:50:28 +07:00
Naz
5dd6cb909f
Tweaked code coverage config for e2e tests
refs https://github.com/TryGhost/Toolbox/issues/475
refs https://github.com/TryGhost/Toolbox/issues/117

- The frontend/src folded would never get picked up by a code coverage tooling as scripts there are dynamically minimized and served from the server
- There's nothing to cover under frontend/public
- Logic behind these changes is the same as in second referenced issue
2022-11-29 14:22:27 +07:00
Simon Backx
709b40144d Added JSDoc for GhostMailer replyTo message option
no issue
2022-11-28 18:37:51 +01:00
Ghost CI
4a3ac50a82 Merged v5.24.2 into main 2022-11-28 17:36:37 +00:00
Ghost CI
a176d1d36f v5.24.2 2022-11-28 17:36:34 +00:00
Simon Backx
2a832645dd Added getNoReplyAddress settings helper
no issue

New settings method used for https://github.com/TryGhost/Ghost/pull/15877, which shouldn't belong in the member service like it currently is.
2022-11-28 18:28:15 +01:00
Simon Backx
6e72767a50
Fixed verification trigger not working for large imports (#15887)
fixes https://github.com/TryGhost/Team/issues/2326

When importing more than 500 members, we didn't testImportThreshold at
the right time. It was called too early because the importing job was
not awaited. This also adds an E2E test for this case.
2022-11-28 18:22:10 +01:00
Elena Baidakova
1b784b5ec5
Added events to Post Analytics page (#15886)
closes TryGhost/Team#2313
- Added Sent event to Post analytics and Members feed. Now post can be
Sent or Received or Bounced.
- Excluded Delivered event from Sent filter on backend.
2022-11-28 17:43:35 +04:00
Ghost CI
d9b4057fe1 Merged v5.24.1 into main 2022-11-28 11:51:06 +00:00
Ghost CI
2a28fa411b v5.24.1 2022-11-28 11:51:02 +00:00
Naz
60d066b243
🔒 Disabled editable relations by default
refs https://github.com/TryGhost/Ghost/security/advisories/GHSA-9gh8-wp53-ccc6
refs https://github.com/TryGhost/Toolbox/issues/465

- Bookshelf relations allows us to edit relational records by default, which was used liberally in the codebase.
- Not having a clear track record of editable relations left the model layer prone to triggering unwanted nested saves and created a vulnerability where members were able to edit newsletter settings.
- With explicit editable relations it's easier to keep track of relations having editable access to related records. Makes the relational data modification pattern safer to use too.
- Anyone running 5.x should update to 5.24.1

Credits: Dave McDaniel and other members of [Cisco Talos](https://talosintelligence.com/vulnerability_reports)
2022-11-28 18:40:26 +07:00
Naz
22738b1b50 🔒 Disabled editable relations by default
refs https://github.com/TryGhost/Ghost/security/advisories/GHSA-9gh8-wp53-ccc6
refs https://github.com/TryGhost/Toolbox/issues/465

- Bookshelf relations allows us to edit relational records by default, which was used liberally in the codebase.
- Not having a clear track record of editable relations left the model layer prone to triggering unwanted nested saves and created a vulnerability where members were able to edit newsletter settings.
- With explicit editable relations it's easier to keep track of relations having editable access to related records. Makes the relational data modification pattern safer to use too.
- Anyone running 5.x should update to 5.24.1

Credits: Dave McDaniel and other members of [Cisco Talos](https://talosintelligence.com/vulnerability_reports)
2022-11-28 18:39:39 +07:00
Sam Lord
60b924f173 Use headless mode by default for Playwright tests
no issue

The setting `headless: false` is superceded by using `PWDEBUG=1` as an
environment variable during debug sessions / while working on tests.
2022-11-28 10:52:38 +00:00
Ghost CI
e1279c74b4 v5.24.0 2022-11-25 15:00:47 +00:00
Gabriel Ribeiro
64329d716e
Fixed missing amp-youtube properties (#15880)
fixes: https://github.com/TryGhost/Ghost/issues/15878

- Fix `amp-youtube` component, add mandatory `width` and `height`
properties. Also change the `layout` property to `responsive`, so that
the width adapts to mobile devices.

---

Error log:
`The mandatory attribute 'height' is missing in tag 'amp-youtube'.`

Documentation `amp-youtube`:
https://amp.dev/documentation/components/amp-youtube
2022-11-25 07:26:33 +00:00
Sam Lord
7e02568cec Fixed PlayWright config
no issue

Using multiple workers could cause Stripe to be removed from one test while another test was using it.
2022-11-24 18:16:43 +00:00
Sam Lord
8b80233ae6 Added sample Portal test to PlayWright suite
refs: https://github.com/TryGhost/Toolbox/issues/479
2022-11-24 17:47:04 +00:00
Sam Lord
6fe5023e91 Added working Playwright tests
refs: https://github.com/TryGhost/Toolbox/issues/479
2022-11-24 15:11:40 +00:00
Rishabh
c5abef057c Stored new source data for emails
refs https://github.com/TryGhost/Team/issues/2280
refs 9b0c21e0a2

As part of the email stability work, we added new `source` and `source_type` columns to `email` table, which allows us to store the email source information. The source for all existing emails before the stability work was always `html`, while newer emails will store `mobiledoc` or `lexical` directly.

While the `source` for all existing emails was populated with the `html` as part of above migration, we also need to store the right `source` for all new emails created till the feature is under a flag.

This change updates the current email flow to also store `source` with html data, so it can be used in future with new email service and allows removing old `html` column.
2022-11-24 16:08:02 +05:30
e.baidakova
f5e1e6296c Add suppression modal to Portal
closes TryGhost/Team#2256
- Users can remove themselves from the suppression list from the profile in Portal.
2022-11-24 13:58:27 +04:00
renovate[bot]
e48072e471 Update dependency bson-objectid to v2.0.4 2022-11-24 11:24:07 +07:00
renovate[bot]
a26cbacfd6 Update dependency @playwright/test to v1.28.1 2022-11-24 10:03:08 +07:00
renovate[bot]
0ca3031df1 Update sentry-javascript monorepo to v7.21.1 2022-11-23 15:15:14 +00:00
Hannah Wolfe
62cd52ff98 Improved Sentry server side error reporting
refs: https://github.com/TryGhost/Team/issues/1121
refs: 54574025e0

- The previous change to fall back to a generic error on the server side is resulting in lots of much less useful Sentry reports
- For unexpected errors, change what's sent to Sentry back to context
- This is done by adding a specific code, so we don't have to match on a string that might change
- Also add the error type, id, code & statusCode as tags to the events - these are searchable structured data
- Adding code as a tag also makes it possible to find all errors that showed the generic message
2022-11-23 12:37:24 +00:00
Hannah Wolfe
36b80f2dda Updated sentry to use @tryghost/version
- As demonstrated by my comments in the boot file, I thought sentry was already depending on the version package
- IMO it's undesirable to require package.json directly esp when we have a tool setup and ready for tis
- Added a bunch of tests to show that Sentry does roughly what we think
2022-11-23 12:37:24 +00:00
Elena Baidakova
8d9d22e5a7
Added member API for removing email from suppression list (#15867)
closes TryGhost/Team#2306
2022-11-23 14:41:00 +04:00
Simon Backx
4b4592630f
Added new email batch sending service (#15865)
fixes https://github.com/TryGhost/Team/issues/2284

New batch sending flow (still WIP). Logs the sent emails instead of actually sending them. Unit tests are coming in later commits.
2022-11-23 11:33:44 +01:00
Rishabh
9b0c21e0a2 Populated email table source with existing html data
refs https://github.com/TryGhost/Team/issues/2280

- updates `source` value for all existing rows to contain `html` data for future compatibility with new columns
2022-11-23 15:04:11 +05:30
Rishabh
5780fc2a93 Added new source and source type columns to emails table
refs https://github.com/TryGhost/Team/issues/2280

We are moving away from storing html and plaintext on email and instead will store the email data in source and source_type columns which allows us to store the email in other formats like mobiledoc and lexical. Storing in those formats allows greater flexibility for later html generation

- adds new `source` column that stores `mobiledoc`/`lexical`/`html` data for a newsletter
- adds new `source_type` column that stores one of `mobiledoc`/`lexical`/`html` to identify type of source
2022-11-23 15:04:11 +05:30
Rishabh Garg
d3267dd5b0
Added columns to store error information for email batches (#15859)
closes https://github.com/TryGhost/Team/issues/2290

Currently, if the whole batch of email fails to send we don’t capture
any errors directly tied to the batch. This makes it hard to debug which
and why a batch failed when debugging email errors. Going forward we'll
store the error information for a failing email batch directly that
allows easier debugging for batch.

- `error_status_code` : Captures statusCode returned by Mailgun,
available in error.status from the example batch error
- `error_message` : Captures short error message from Mailgun and
status, available in context object of batch error
- `error_data` : Captures while whole error json for a batch. As
mentioned in pitch, this will be huge data and we’ll figure out long
term how to best use this.
2022-11-23 13:13:49 +05:30
renovate[bot]
e4e8df44dd Update sentry-javascript monorepo to v7.21.0 2022-11-23 12:29:15 +07:00
Sam Lord
f6870fa846 Added browser-based testing framework
refs: https://github.com/TryGhost/Toolbox/issues/479

Framework includes:
* command to run tests
* command to record tests
* mechanism for starting and stopping Ghost before and after each suite of tests
* mechanism for loading fixtures into Ghost before starting tests
* sample test for controlling Ghost Admin
2022-11-22 14:12:34 +00:00
Fabien "egg" O'Carroll
f056614b45 Wired up EmailSuppressionList to MEGA
refs https://github.com/TryGhost/Team/issues/2269

This ensures that we do not send emails to members who's email is on
the email suppression list
2022-11-22 13:26:28 +07:00
Peter Zimon
b0ac096d94 Fixed content importer email on errors
no refs.

- the content importer didn't send emails on unhandled errors
2022-11-21 13:09:33 +01:00
Simon Backx
44f189b56a
Added email service package (#15849)
fixes https://github.com/TryGhost/Team/issues/2282

Added a new email service package that is used when the email stability
flag is enabled. Currently not yet implemented so will throw an error
for all entry points (if flag enabled).

Removed usage of `labs.isSet.bind` across the code, because that breaks
the stubbing of labs by `mockManager.mockLabsEnabled` and
`mockManager.mockLabsDisabled`. `flag => labs.isSet(flag)` should be
used instead.

All email depending tests now disable the `emailStability` feature flag
to keep the tests passing + make sure we still run all the tests for the
old flow while the email stability package is being built.
2022-11-21 10:29:53 +01:00
renovate[bot]
96aa1c930c Update dependency @playwright/test to v1.28.0 2022-11-21 15:37:46 +07:00
renovate[bot]
c4e41909a6 Update dependency html-validate to v7.10.0 2022-11-21 15:36:36 +07:00
renovate[bot]
0c2a62f47c
Update Test & linting packages 2022-11-18 23:04:37 +00:00
Peter Zimon
3cf3e5b5c4 Updated content importer to fail only on errors
no refs.

- the content importer sent an "Import failed" email even if only warnings occured during import
2022-11-18 19:07:03 +01:00
Ghost CI
a3376fe502 v5.23.0 2022-11-18 15:00:50 +00:00
Ghost CI
952df7070c 🎨 Updated Casper to v5.4.1 2022-11-18 15:00:49 +00:00
Simon Backx
6c84e10e46 Added email stability feature flag
no issue
2022-11-18 15:46:18 +01:00
Simon Backx
5c2f0b9a4b
Removed getCreatedEvents and added verification trigger test (#15832)
refs https://github.com/TryGhost/Team/issues/2266

This removes the deprecated `getCreatedEvents` method in the event
repository and adds tests to the verification trigger to see if we don't
break anything.

Changes extracted from https://github.com/TryGhost/Ghost/pull/15831
2022-11-18 15:05:15 +01:00
Simon Backx
2220686113 Sped up comments and feedback tests by reusing Ghost app instance
refs https://ghost.slack.com/archives/C02G9E68C/p1668777066462859

Added a duplicate method to the mmebers agent, so we can reuse the same app instance and options, whenever we need multiple agents (each with their own cookies).
2022-11-18 14:58:35 +01:00
Peter Zimon
bb91bfd1ee Fixed copy bug in content import email
no refs.

- the title and the preview text of the content import email contained the copy from the member import email
2022-11-18 12:58:35 +01:00
Peter Zimon
ab8f16ce79 Updated copy for content import emails
no refs.
2022-11-18 12:49:55 +01:00
Fabien 'egg' O'Carroll
8283de99c8
Wired up EmailSuppressionList to Members Admin API (#15848)
refs https://github.com/TryGhost/Team/issues/2268

The approach of using the service to lead email suppression data as
opposed to bookshelf relations allows us to wire things up without
having implemented the database. The getBulkSuppressionData allows us to
do this without much of a DB performance hit.
2022-11-18 16:28:13 +07:00