Commit Graph

15409 Commits

Author SHA1 Message Date
Naz
0ab652b768
Fixed playwright port
refs https://github.com/TryGhost/Toolbox/issues/479

- e2e and integration test suites are running on port 2369. Playwright was not following this convention, without good reason.
- Port 2368 is the default port for development and production processes, so using it for test environment is not ideal
2022-12-06 16:14:37 +07:00
Ghost CI
54b693a359 Merged v5.25.1 into main 2022-12-06 05:14:41 +00:00
Ghost CI
55b0f564ba v5.25.1 2022-12-06 05:14:37 +00:00
Simon Backx
c47891c3f6
🐛 Fixed setting delivered_at to null after hard bounce (#15942)
refs https://ghost.slack.com/archives/C02G9E68C/p1670075366333929?thread_ts=1669963540.980309&cid=C02G9E68C

When we receive a permanent bounce/failure, we set delivered_at to null.
But we don't want to lose this information.

Instead we should be able to handle recipients that both have failed_at
and delivered_at set.
2022-12-06 10:26:54 +05:30
Kevin Ansfield
1685a84a27 Fixed incorrect property access
refs 0e181c84b2

- the code is already running in the `session` service so it shouldn't access the role property via a non-existing injection
2022-12-05 17:17:47 +00:00
Kevin Ansfield
0e181c84b2 Added user role to captured Sentry data
closes https://github.com/TryGhost/Team/issues/2241

- as part of the authenticated application setup, update the captured Sentry data with the user role
- helps narrow things down when we see permission errors pop up due to requests being made for endpoints that the current user doesn't have permission to access
2022-12-05 17:15:55 +00:00
Sam Lord
d3716007bf
Fixed browser-based tests running in CI
refs: https://github.com/TryGhost/Toolbox/issues/481

* Correctly setup environment variable to run both local & staging browser-based tests
* Use non-production Ghost Admin build, since production builds require HTTPS to use Stripe Connect
2022-12-05 13:39:10 +00:00
Simon Backx
bededf4520
🐛 Fixed errors of old events from deleted members (#15944)
refs https://ghost.slack.com/archives/C02G9E68C/p1670215917451249

When a member is deleted, and we receive an opened event for an email to
that member. We threw an uncaught Bookshelf EmptyResponse error.

- This change makes fetching the member not a requirement when handling
that event in the last seen at updater.
- It also adds try catches for all event listeners in the last seen at
updater
2022-12-05 14:36:23 +01:00
Elena Baidakova
5e973688bf
Added redirect to Email Preferences in Portal after resubscribing (#15940)
closes TryGhost/Team#2360
- Redirect member to Email Preferences after email removed from
suppression list.
2022-12-05 15:58:55 +04:00
Kevin Ansfield
3817f583fa 🐛 Fixed unexpected "unsaved changes" modal when deleting a member
closes https://github.com/TryGhost/Team/issues/2275

When deleting a member, after confirming deletion another "unsaved changes" modal popped up. From that point, if you clicked to stay you remained on the member screen with stale data (the member was still deleted) resulting in further errors when any attempt to make changes was made.

- prevented the unsaved changes check running for a deleted member because it would always return `true` in that case
- ensured the data setup for the unsaved changes check still occurs when a member is accessed directly via the URL
  - previously it was skipped because the data setup only occurred inside `fetchMemberTask` but that isn't called when the route already loaded the model via it's `model()` hook
2022-12-05 11:48:37 +00:00
Naz
879aad263d
Added email verification trigger test
refs https://github.com/TryGhost/Toolbox/issues/476

- The email verification trigger and host settings related bugs have been a cause of bugs in past releases.  The admin client verification source did not have any test coverage in the past.
- The members test suite size is getting out of hand. This test is quite verbose, because of the state it's trying to check.
- In the future we should consider splitting up Member API (and probably other) test suites into smaller pieces.
2022-12-05 18:24:28 +07:00
Simon Backx
2519f4b20d Disabled autoRefresh for batch sending service to increase performance
fixes https://github.com/TryGhost/Team/issues/2363
2022-12-05 12:09:30 +01:00
Naz
e170f293e3
Extracted sleep method to e2e framework module
no issue

- The sleep method has been used in 8 modules reimplementing the same thing over and over again. It's usually a sign of async event processing outside of the request/response loop. It's good to have a single point of implementation for a "hack" like this, so we could track it easier and address the even processing delay in a more optimal way centrally if it ever becomes a bottleneck
2022-12-05 17:26:29 +07:00
Elena Baidakova
0caf8bff18
Renamed all references to "Flagged as spam email" (#15938)
closes TryGhost/Team#2352
2022-12-05 12:07:26 +04:00
Elena Baidakova
f09ed78af2
Fixing the misalignment of avatar between member activity and member detail (#15939)
closes TryGhost/Team#2356
2022-12-05 11:59:17 +04:00
renovate[bot]
82722bbf43
Update dependency fastq to v1.14.0 2022-12-05 04:20:14 +00:00
renovate[bot]
b8ab57b692 Update dependency expect to v29 2022-12-05 11:16:46 +07:00
renovate[bot]
7f169cdd96 Update dependency html-validate to v7.10.1 2022-12-05 10:21:00 +07:00
renovate[bot]
1e2c45f208 Update dependency terser to v5.16.1 2022-12-05 10:20:15 +07:00
renovate[bot]
cdca9d73b3
Update Test & linting packages 2022-12-02 23:05:46 +00:00
Sam Lord
00d223991d Improved browser test CI integration
refs: https://github.com/TryGhost/Toolbox/issues/481
2022-12-02 17:04:04 +00:00
Sam Lord
7bfe5db716 Ensure tests pass when pointing at a remote server
no issue

This will need some work, since we are introducing a 500ms delay to wait for a network request to return. Ideally the tier expander should eventually populate itself.
2022-12-02 17:04:04 +00:00
Sam Lord
47526bc175 Fixed Portal test in browser suite
no issue
2022-12-02 17:04:04 +00:00
Sam Lord
40903c3136 Fixed browser-based tests in local context
no issue

Local tests can now setup Stripe during the global setup process, and the webhook server is run out-of-process.
Running tests in CI against localhost will use environment variables to setup Stripe.
Providing a test URL will avoid setting up Stripe and will assume that it is already done.
2022-12-02 17:04:04 +00:00
Daniel Lockyer
bc0b1f6adc Added CI for running Playwright tests
🚧
2022-12-02 17:04:04 +00:00
Sam Lord
668e523ab4 Allow playwright tests to run locally and remotely
no issue

This commit allows tests to run remotely by replacing selectors with production-suitable ones (no [data-test...]).

It also allows running locally with Stripe webhooks by adding a new global setup function.
2022-12-02 17:04:04 +00:00
Rishabh
e74ba81276 Refined email debug screen error handling
refs https://github.com/TryGhost/Team/issues/2327
2022-12-02 21:29:07 +05:30
Simon Backx
6ae9b49e73 Added post title to email debug page 2022-12-02 16:51:51 +01:00
Peter Zimon
cd5a85021a Fixed member name alignment on email debug screen
refs. https://github.com/TryGhost/Team/issues/2327

- on the first two tabs of the email debug screen, the member email wasn't aligned properly when there was no name for a member
2022-12-02 16:16:01 +01:00
Rishabh
ddb61c3b3c Wired static expand error logic on email debug
refs https://github.com/TryGhost/Team/issues/2327

- wires the static handling of error message on debug screen with real error
2022-12-02 20:41:08 +05:30
Ghost CI
d9ed6bcdb8 v5.25.0 2022-12-02 15:00:48 +00:00
Peter Zimon
768ba2be50 Minor UI fixes on email debug screen
refs. https://github.com/TryGhost/Team/issues/2327
2022-12-02 15:49:23 +01:00
Peter Zimon
c7600407bd Fixed text color bug in box button links 2022-12-02 15:46:52 +01:00
Simon Backx
ea72934c41
Improved email concurrency sending (#15923)
no issue

Send 10 batches at the same time
2022-12-02 15:30:02 +01:00
Peter Zimon
f562d19f3c Updated error display styles for error debug
refs. https://github.com/TryGhost/Team/issues/2327

- Some minor CSS style changes were needed for errors on the email debug screen. Also we weren't showing any message i - for whatever reason - there was no data for batches.
2022-12-02 15:13:07 +01:00
renovate[bot]
c7d10c2d49 Update Node.js to v18 2022-12-02 14:07:37 +00:00
Simon Backx
fc12767917 Wired up retry button on debug page 2022-12-02 14:57:03 +01:00
Peter Zimon
e0c52d0670 Added static expand error logic to email debug
refs. https://github.com/TryGhost/Team/issues/2327

- The length of the error messages for temporary and permanent failure tabs on the email debug screen can be arbitrary. This degrades scannability and limits the number of displayed rows in the list. Adding an expand button to the error message makes sense since the errors might repeat and the error code + the beginning of the message can be enough to understand them. Also this allows more rows to be displayed per screen.
2022-12-02 14:49:28 +01:00
Simon Backx
b81cc13e48 Fixed email batches and recipient pagination 2022-12-02 14:49:21 +01:00
Simon Backx
928a73c536 Fixed email debug page always showing error + breadcrumb 2022-12-02 14:45:06 +01:00
Peter Zimon
9b276e6aa2 Added empty state handling to email debug tabs
refs. https://github.com/TryGhost/Team/issues/2327

- the lists and tables were completely empty when there was no error or some data was missing
2022-12-02 13:34:30 +01:00
Rishabh
cee94217a8 Fixed lint 2022-12-02 16:22:59 +05:30
Rishabh
d82cfb1d57 Updated static error message on debug screen
refs https://github.com/TryGhost/Team/issues/2327

- updates major error message on email debug screen from the email model
2022-12-02 16:12:48 +05:30
Simon Backx
1958d0db63
Removed spaces and quotes from replacement ids (#15921)
fixes https://github.com/TryGhost/Team/issues/2350
2022-12-02 10:49:01 +01:00
Simon Backx
6fbda0730d Added unit test for paywall and segments 2022-12-02 10:48:29 +01:00
Simon Backx
53b5c152d9 Added email event storage unit tests
refs https://github.com/TryGhost/Team/issues/2339
2022-12-02 10:21:39 +01:00
Rishabh Garg
a8a879ef53
Wired email debug screen with API (#15919)
refs https://github.com/TryGhost/Team/issues/2327

- wires email debug screen with real data from API
- fetches email batch data for showing all batches along with those errored
- fetches all recipient failures - temporary and permanent
- shows email settings that was used for sending out the email
2022-12-02 14:38:40 +05:30
Simon Backx
2a3a72e4d5
Added email debug API (#15915)
fixes https://github.com/TryGhost/Team/issues/2346

- Adds email batch browse endpoint
- Adds email recipient failures browse endpoint
- Adds new fixtures and E2E tests for the new API
- Added support for snapshot tests to have 'nullable' types.
2022-12-02 09:44:32 +01:00
renovate[bot]
46bb38b18a Update sentry-javascript monorepo to v7.23.0 2022-12-02 11:59:31 +07:00
Hannah Wolfe
79dbdff054 Fixed error logging in importer
refs: https://github.com/TryGhost/Toolbox/issues/431

- the error logging was only outputting 'Content import was unsuccessful' and not outputting the associated error
2022-12-01 19:14:18 +00:00
Rishabh Garg
f9161876b3
Updated unit test coverage for email service (#15913)
refs https://github.com/TryGhost/Team/issues/2339

- adds unit test for email renderer, segmenter and sending service
2022-12-02 00:33:28 +05:30
James Morris
c74857052f Released Portal v2.20.3 2022-12-01 19:01:06 +00:00
James Morris
2405b59f55 Added in the suppression check to stop link from showing on Portal home
refs https://github.com/TryGhost/Team/issues/2348
2022-12-01 18:59:25 +00:00
James Morris
50383316c0 Attempting to add a single newsletter solution for FAQ to get around lack of back stack
refs https://github.com/TryGhost/Team/issues/2348
2022-12-01 18:30:50 +00:00
James Morris
7c392a6d30 Released Portal v2.20.2 2022-12-01 17:48:33 +00:00
James Morris
9953722bcc Fixing unused variable that was making linting failed
refs https://github.com/TryGhost/Team/issues/2348
2022-12-01 17:42:50 +00:00
James Morris
b64ce8fcb6 Removed a broken test from portal to do with suppressions
refs https://github.com/TryGhost/Team/issues/2348
2022-12-01 17:42:50 +00:00
James Morris
6b4b7f207f Adds brand new FAQs and links to Portal based on support documents
- Adds links and new modals for two new FAQs
- Has some checks for suppressions based on member property email_suppressions
- Using different technique for back buttons to simulate bigger stack

refs https://github.com/TryGhost/Team/issues/2348
2022-12-01 17:42:50 +00:00
e.baidakova
6b7d313415 fixup! Added email suppression FAQ modal 2022-12-01 17:42:50 +00:00
e.baidakova
23ded6fb67 Added email suppression FAQ modal 2022-12-01 17:42:50 +00:00
Peter Zimon
7df63d67b4 Added static "Settings" tab to debug screen
refs. https://github.com/TryGhost/Team/issues/2327

- there was only a placeholder for the Settings tab, this adds the structure so we can test and wire in dynamic data
2022-12-01 18:14:55 +01:00
Kevin Ansfield
a855973ac6 Wired up top-of-document handling in Lexical editor
closes https://github.com/TryGhost/Team/issues/2285

- added passthrough of `cursorDidExitAtTop` action so the editor can trigger title input focus on key commands that trigger the cursor to leave the top of document
2022-12-01 16:46:06 +00:00
Peter Zimon
a51f3a124d Added static batch errors to error debug
refs. https://github.com/TryGhost/Team/issues/2327

- the batch errors tab content was just a placeholder, this adds static version to be able to test and wire it in
2022-12-01 17:30:13 +01:00
Simon Backx
0182965aa3 Updated batch sending to log errors separately
fixes https://github.com/TryGhost/Team/issues/2347

Makes sure we can use the error code
2022-12-01 16:35:54 +01:00
Peter Zimon
dee00e36a0 Added static UI to email debug screen
refs. https://github.com/TryGhost/Team/issues/2327

- static UI was needed on the email debug screen for testing and backend wiring
2022-12-01 15:13:48 +01:00
Fabien "egg" O'Carroll
6849a4ef66 Removed mock data from event fetcher
closes https://github.com/TryGhost/Team/issues/2277

This data is no longer needed since we wired up to the mailgun implementation
2022-12-01 20:19:59 +07:00
Fabien "egg" O'Carroll
c5b233ac65 Moved the filtering of suppressed emails behind a flag check
We want to be able to release this code without restricting the
sending of emails on our end, so this logic needs to be behind a
feature flag
2022-12-01 20:14:30 +07:00
Fabien "egg" O'Carroll
2350cacf3a Wired up MailgunEmailSuppressionList
This switches out the in-memory implementation for the mailgun one and
is the final piece in wirign up everything to real data.
2022-12-01 20:14:30 +07:00
Fabien "egg" O'Carroll
a25fdf4052 Added MailgunEmailSuppressionList
refs https://github.com/TryGhost/Team/issues/2253
refs https://github.com/TryGhost/Team/issues/2254
refs https://github.com/TryGhost/Team/issues/2255

This is the implementation of the EmailSuppressionList specific to
Mailgun, it listens for the new events and stores suppressions based
on those.
2022-12-01 20:14:30 +07:00
Fabien "egg" O'Carroll
5e72e42d32 Moved InMemoryEmailSuppressionList to own file
This cleans up the service file so we can make the switch to a Mailgun specific
implementation later.
2022-12-01 20:14:30 +07:00
Fabien "egg" O'Carroll
c6c962d5d6 Added methods for removing suppressions from Mailgun
refs https://github.com/TryGhost/Team/issues/2255

These methods will be used by the Mailgun implementation of EmailSuppressionList
so that emails are removed from both our internal list and Mailguns.
2022-12-01 20:14:30 +07:00
Simon Backx
4c166e11df
Added E2E tests for batch sending (#15910)
refs https://github.com/TryGhost/Team/issues/2339

- Includes a new pattern in the job manager that allows us to properly
await jobs.
- Added new convenience mocking methods to stub settings
- Tests the main flows for bulk sending:
    - Sending in multiple batches
    - Sending to multiple segments
    - Handling a failed batch and retrying that batch
- Fixes bug in batch generation (ordering not working)

In a different PR I'll add more detailed tests.
2022-12-01 13:43:49 +01:00
Rishabh Garg
a5ca64f693
Added basic email debug design (#15914)
refs https://github.com/TryGhost/Team/issues/2327

As part of improving visibility for email failures, this change adds a new debug screen that allows visualising the email failures for a post. The screen is hidden on the UI for now and only accessible via URL directly.

Co-authored-by: Djordje Vlaisavljevic <dzvlais@gmail.com>
2022-12-01 17:58:37 +05:30
Fabien "egg" O'Carroll
12219fed65 Handled receiving duplicate SpamComplaintEvents
We need to check for both ER_DUP_ENTRY and SQLITE_CONSTRAINT because
different DB engines give us back different error codes.
2022-12-01 17:27:06 +07:00
Fabien "egg" O'Carroll
c0e91c73d3 Added unique constraint to email_spam_complaint_events table
We can fetch the same event multiple times from Mailgun so we need to
be able to protect against inserting duplicate events in the
database. This will allow us to catch duplicate errors on insert when
handling complaint events.
2022-12-01 17:27:02 +07:00
Fabien "egg" O'Carroll
f9fdee1b28 Wired up storage of EmailSpamComplaintEvents
refs https://github.com/TryGhost/Team/issues/2337

This also removes the code which unsubscribes members from newsletters because
that is not the spec of the feature.
2022-12-01 17:26:59 +07:00
Fabien "egg" O'Carroll
9c691f3ea9 Added support for EmailSpamComplaintEvent to activity feed
We need to add relations and filterRelations to the model so that we can
correctly filter events by post_id and member_id
2022-12-01 17:26:24 +07:00
Naz
04d9cbb1eb Removed unused members settings module
no issue

- This module is marked for deletion with a todo comment.  It also popped up as least covered place in the codebase, because it was never used.
2022-12-01 16:12:09 +07:00
Simon Backx
d8187123af
Added storage for email failures (#15901)
fixes https://github.com/TryGhost/Team/issues/2332

Saves events in the database and collects error information.

Do note that we can emit the same events multiple times, and as a result
out of order. That means we should correctly handle that a delivered
event might be fired after a permanent failure. So a delivered event is
ignored if the email is already marked as failed. Also delivered_at is
reset to null when we receive a permanent failure.
2022-12-01 10:00:53 +01:00
Kevin Ansfield
a1ee04b08f Wired up title->editor keyboard handling in Lexical editor
closes https://github.com/TryGhost/Team/issues/2286

- use the `registerAPI` prop to get access to a basic API for focusing and inserting paragraphs
- replaced commented mobiledoc based title key handling with lexical handling
2022-11-30 22:04:02 +00:00
Elena Baidakova
95c3a68c34
Updated the filter naming in Post Analytics (#15898)
closes TryGhost/Team#2329
- Replace 'Received' on 'Sent' in member's filter
- Moved links for feedback analytics from chart to table
2022-11-30 17:39:37 +04:00
Simon Backx
26d51687b1
Implemented email previews and tests using new email flow (#15899)
fixes https://github.com/TryGhost/Team/issues/2330

Uses new flow for previewing and testing emails (only if email stability
flag is enabled)
2022-11-30 13:56:28 +01:00
Rishabh Garg
42f9d392a3
Added mailgun provider for sending emails (#15896)
closes https://github.com/TryGhost/Team/issues/2309

- adds new mailgun provider to send out batch emails
- updates sending service to send email id for mailgun provider, allows tagging mail with email id
2022-11-30 16:21:58 +05:30
Naz
0cfef77a01
Removed db schema config from e2e test coverage
refs a2d487e074

- Same reasoning as in referenced commit: "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-30 17:08:47 +07:00
Naz
130f379176
Added "frontend/helpers" to coverage ignore list
refs https://github.com/TryGhost/Toolbox/issues/486

- Frontend helpers are extremely hard to cover fully in e2e tests and are better suited to be covered by unit tests (which they have very hight coverage with)
2022-11-30 17:06:27 +07:00
Naz
aa8fe65665
Added "testmode" app to coverage ignore list
refs https://github.com/TryGhost/Toolbox/issues/486

- Testmode is a special app used for manual testing and has no value in code coverage reports
2022-11-30 16:45:22 +07:00
Naz
80decf8303
Fixed invalid query strings in tests
closes https://github.com/TryGhost/Team/issues/2324

- It seemed like the "limit" query parameter did not work properly returning multiple entries from the endpoint. In reality the whole query string was ignored because of an error in the "filter" part of the query ^_^
2022-11-30 13:31:06 +07:00
Naz
65d910f43b
Increased timeout for the import job test
refs 9fe1274fbe

- Temporary fix to let the CI pass the test. Needs investigation into why MySQL is so much slower comparing to SQLite
2022-11-30 13:25:18 +07:00
Daniel Lockyer
52fc66762a
Updated .npmignore with new files
- these files should not be included in the published package as they're
  for development purposes
2022-11-30 12:40:47 +07:00
renovate[bot]
40c4ae4e00 Update dependency @babel/plugin-proposal-decorators to v7.20.5 2022-11-30 12:28:57 +07:00
renovate[bot]
491cf44f52 Update dependency @sinonjs/fake-timers to v10 2022-11-30 12:26:53 +07:00
renovate[bot]
d6a9b464b3 Update dependency jwks-rsa to v3 2022-11-30 12:24:08 +07:00
renovate[bot]
8682100e58 Update dependency @types/mocha to v10.0.1 2022-11-30 12:23:06 +07:00
Naz
9fe1274fbe
Fixed member import job test
refs https://github.com/TryGhost/Team/issues/2326

-  The job takes considerably longer to run with MySQL, so needed a longer sleep time. It's a temporary fix to unblock a broken build. We should investigate why the job takes so long to run on MySQL
2022-11-30 11:15:12 +07:00
Naz
ff1c17d661
Bumped e2e test coverage thresholds
refs fc9f8aebc1

- With integration & regression test suites included in the e2e coverage reports the coverage has jumped up nicely. We should keep the threshold as hight as possible from accidentally reducing the coverage quality
2022-11-30 10:41:32 +07:00
Naz
fc9f8aebc1
Fixed ci test runs
refs 3e0ec26408

- The refed commit excluded integration/regression test suites from CI test runs by accident
2022-11-30 10:39:32 +07:00
renovate[bot]
fc16bf97da Update dependency postcss-cli to v10.1.0 2022-11-30 10:09:41 +07:00
renovate[bot]
b05434ca91
Update metascraper to v5.32.2 2022-11-29 17:02:07 +00:00
Kevin Ansfield
457c672c6a
Added URL transform for image cards in Lexical documents (#15890)
refs https://github.com/TryGhost/Team/issues/2225

- updated the `formatOnWrite` transform map for posts to include the new `nodes` and `transformMap` options used by `urlUtils` for transforming node payload data
- added `nodes` to the `lexicalLib` module that pulls in our default nodes to be passed in to the URL transform utilities
- added `urlTransformMap` to the `lexicalLib` module that maps transform type and data type to URL transform utility functions that accept a single URL argument
2022-11-29 16:57:01 +00:00
Elena Baidakova
86abab4f1d
Remove member's activity double scrolling (#15897)
closes TryGhost/Team#2325
2022-11-29 16:08:11 +04:00
Fabien "egg" O'Carroll
ba5b8ea33d Added email_spam_complaint_events table and model
refs https://github.com/TryGhost/Team/issues/2318

As with our other events, we've disabled destroy and edit static methods
on the bookshelf model.
2022-11-29 18:13:12 +07:00
Fabien "egg" O'Carroll
83be54af42 Added suppressions table and model
refs https://github.com/TryGhost/Team/issues/2317

This table is used for persisting the email suppression list.
We don't have a member_id column because emails, not members are suppressed.
2022-11-29 18:12:24 +07:00
Simon Backx
f5045b9bf7
Added email renderer implementation draft (#15877)
fixes https://github.com/TryGhost/Team/issues/2308

- Still has some missing pieces, but mostly works.
- Uses new handlebars template for emails
- When sending emails with the new email stability flag enabled, one
test email is now sent via the default smtp ghost mailer.
2022-11-29 11:27:17 +01:00
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
Elena Baidakova
fbf761b0ac
Fixed post title in the filter dropdown on the Members page (#15884)
closes TryGhost/Team#2265
2022-11-28 16:47:50 +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
Elena Baidakova
1161ab98f9
Rename column to Sent on Dashboard (#15883)
closes TryGhost/Team#2321
2022-11-28 11:22:35 +04:00
Ghost CI
e1279c74b4 v5.24.0 2022-11-25 15:00:47 +00:00
Kevin Ansfield
d4ea9c877d Fixed editor key commands throwing errors when range has no section
closes Sentry ADMIN-CC8
closes Sentry ADMIN-DDM
closes Sentry ADMIN-C9F

- there are situations where the editor range when key commands are triggered does not have a head section which then throws errors due to the commands assuming there will always be a section present
- added a guard to key commands that use the head section to abort early and fall back to default Mobiledoc behaviour when the section is missing
2022-11-25 08:56:38 +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
renovate[bot]
68d3faf77c
Update dependency terser to v5.16.0 2022-11-24 19:01:01 +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
Elena Baidakova
0bdccb6497
Update member activity dropdown (#15875)
closes TryGhost/Team#2250
2022-11-24 20:21:43 +04:00
Sam Lord
6fe5023e91 Added working Playwright tests
refs: https://github.com/TryGhost/Toolbox/issues/479
2022-11-24 15:11:40 +00:00
Kevin Ansfield
ef71d52ec0 Fixed Cannot read properties of null (reading 'offsetHeight') errors in markdown card
closes sentry ADMIN-CAV

- the mobile nav element is not always displayed so we should assume we can read it's `offsetHeight` property
2022-11-24 12:52:16 +00:00
Kevin Ansfield
37d9e8bb8b Fixed Cannot set properties of null (setting 'scrollTop') errors in <GhHtmlIframe>
closes sentry ADMIN-C7S

- we can't guarantee that the iframe being swapped to has rendered yet at the time we swap iframes so we need a guard around the `contentDocument.body` property existing before setting it's `scrollTop` value
2022-11-24 12:52:16 +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
e.baidakova
69c2af1ffe Split AccountHomePage file on separate files
closes TryGhost/Team#2256
- Moved components to separate file for better navigation.
2022-11-24 13:58:27 +04:00
e.baidakova
991e628022 Add ability to use absolute paths for import
closes TryGhost/Team#2264
- Instead of relative paths, we can use absolute. It helps to keep code cleaner and don't worry about import when doing refactoring.
Relative paths require rewriting them in case a file is moved to another directory.
2022-11-24 13:58:27 +04:00
e.baidakova
f151d223c3 Add ability to import css files
closes TryGhost/Team#2256
- Now we can write css in separate files and then import them as string.
2022-11-24 13:58:27 +04:00
Fabien "egg" O'Carroll
a88201089e Updated dev dependency to use pinned version
This is the standard for our deps in packages.
2022-11-24 13:58:12 +07:00
Fabien "egg" O'Carroll
90c9a03319 Added @tryghost/email-events package
refs https://github.com/TryGhost/Team/issues/2253
refs https://github.com/TryGhost/Team/issues/2254

This package is analogous to the @tryghost/member-events package. The
events here will be consumed by the EmailSuppressionList
implementation and used to add emails to said list. They'll be
dispatched by the code which handles events received from Mailgun.
2022-11-24 13:56:35 +07:00
Elena Baidakova
54f075b330
Update the suppression notice front-end (#15869)
closes TryGhost/Team#2288
2022-11-24 10:02:57 +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
Hannah Wolfe
e4dbf9b0fd Updated error fallbacks to generic error message
refs: https://github.com/TryGhost/Team/issues/1121

- We've decided on one  preferred message for unexpected errors
- We want to use this everywhere where we don't know what to display
- We now have a GENERIC_ERROR_MESSAGE constant that we should use
2022-11-23 21:49:40 +00:00
Hannah Wolfe
907319a507 Renamed mw-error-handler test file to match lib
- minor inconsistency in naming was tripping me up
2022-11-23 21:49:40 +00:00
Elena Baidakova
e1ba0f6a2d
Fixed member avatar size (#15871)
closes TryGhost/Team#2279
2022-11-23 20:01:23 +04:00
Hannah Wolfe
32353f2920 Removed detail rule from showAPIError
refs: https://github.com/TryGhost/Team/issues/1121

- showAPIError is a method intended for formatting errors from the Ghost API
- Ghost API Errors do not have a detail field, therefore this code was redundant
- there are also no related tests
- removing now because I'm trying to cleanup and streamline all our error handling code
2022-11-23 15:56:58 +00:00
Hannah Wolfe
c740eecaec Fixed duplicate error messages from API
refs: https://github.com/TryGhost/Team/issues/1121

- In certain cases our API sends the same data for message and context.
- We will also fix this server-side, but we should also be smart in the UI and not show duplicate info
2022-11-23 15:56:58 +00:00
Silvan Hagen
4ed245a405 fix: missing "the" in sentence regarding trial 2022-11-23 15:38:48 +00:00
renovate[bot]
0ca3031df1 Update sentry-javascript monorepo to v7.21.1 2022-11-23 15:15:14 +00:00
Kevin Ansfield
9ceecba5fd Added TransitionAborted errors to Sentry's ignore list
no issue

- "unhandled" `TransitionAborted` errors almost always occur as part of expected application behaviour and were causing a lot of noise in Sentry making it harder to track down real errors
- when a `TransitionAborted` error occurs outside of expected behaviour it will usually be accompanied by other errors that do get logged
- there's a long-standing Ember issue about how aborted transition errors should be handled at https://github.com/emberjs/ember.js/issues/12505
2022-11-23 13:23:47 +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