Commit Graph

40 Commits

Author SHA1 Message Date
renovate[bot]
2223db5379
Update Test & linting packages 2023-03-13 02:36:20 +00:00
Steve Larson
6b29e51c67
🐛 enabled mentions for pages (#16388)
no refs
-mentions were not being sent for pages
-added listeners for page events (published, unpublished, edited)
2023-03-09 17:31:29 -06:00
Simon Backx
38de815d98
Removed old email flow (#16349)
fixes https://github.com/TryGhost/Team/issues/2611

The old email flow is no longer used since we introduced the email stability flow. This commit removes the related code and tests. The general test coverage decreased a bit as a result, because the old email flow probably had a high test coverage. The new flow is in separate packages, so it couldn't contribute to a higher test coverage (but it does have 100% unit test coverage).
2023-03-07 16:08:40 +01:00
renovate[bot]
9f08732039 Update @tryghost 2023-03-02 09:47:02 +01:00
Simon Backx
81c4b46977
Grouped mentions from the same source (#16348)
fixes https://github.com/TryGhost/Team/issues/2625

- Adds an unique option to the mentions API. Enabling this will only
return the latest mention from each source.
- The frontend can fetch the related sources for each page by doing an
extra request to the mentions API.
2023-03-01 12:15:29 +01:00
Steve Larson
9e58181398
combined fetch for metadata and verification (#16330)
refs TryGhost/Team#2582
-removed duplicative fetch request
-added mention as type in oembed service
2023-02-28 08:39:28 -06:00
Simon Backx
603e0909c9 Fixed webmentions unit test coverage
no issue

Try catch was not covered
2023-02-22 16:36:11 +01: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
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
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
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
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
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
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
renovate[bot]
cf7ecb492c
Update dependency c8 to v7.13.0 2023-02-16 22:15:50 +00: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
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
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
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
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
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
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
Steve Larson
a3064d95cb
completely blocked external requests in Webmentions tests (#16186)
no issue
-had timeout issues in test suite
-tests were still doing dns lookup via external request
2023-01-25 10:43:57 -06:00
Ronald Langeveld
dd74f42376
Added mentions email notifications (#16170)
closes https://github.com/TryGhost/Team/issues/2429

- sends email notifications to staff users when their site receives a Webmention.
- currently behind a flag, that can be toggled in the labs settings.
2023-01-25 21:10:29 +08:00
Fabien 'egg' O'Carroll
33ebe971f8
Added BookshelfMentionRepository implementation (#16156)
fixes https://github.com/TryGhost/Team/issues/2418

This stores the received webmentions in the database.

Co-authored-by: Simon Backx <simon@ghost.org>
2023-01-20 14:32:50 +01:00
Simon Backx
8c9893e568 Improved MentionSendingService timeout
no issue

The current timeouts were unreliable.
2023-01-20 11:46:18 +01:00
Steve Larson
8895d22602
Added mention discovery service (#16154)
fixes https://github.com/TryGhost/Team/issues/2407

The MentionDiscoveryService fetches mentioned sites to return the webmention endpoint.
2023-01-20 11:45:48 +01:00
Simon Backx
a596acf7d2
Added MentionSendingService (#16151)
fixes https://github.com/TryGhost/Team/issues/2409

The MentionSendingService listens for post changes and sends webmentions
for outbound links in the post.
2023-01-19 17:35:10 +01:00
Fabien "egg" O'Carroll
4215786bf1 Improved internal types for the Mention entity
This makes development a little more streamlined, and helped catch a wee bug!
2023-01-19 19:25:19 +07:00
Fabien "egg" O'Carroll
3a0e0831ec Updated Mention entity validation of properties
Based on a discussion in slack we want to make all metadata properties optional,
with the exception of the title, which will default to the host of the source
URL if it's missing.

This is so that we can accept as many webmentions as possible and convert them
into Mentions. If we were to have strictly validation, we'd end up having to
drop webmentions that didn't match our criteria, and lose important data.

Giving the title a default allows us to provide a consistent UI experience too.
2023-01-19 19:24:07 +07:00
Fabien "egg" O'Carroll
743da542d0 Wired up the Webmention receive endpoint to the Mentions service
refs https://github.com/TryGhost/Team/issues/2419

This is the initial stab at having everything wired up, we're not
using a queue but we are handling the processing of the Webmention
asyncrounsly so that the HTTP response can be end immediately.

We've also laid the groundwork for extending and implementing the
correct processing of Webmentions, for example checking if the target
URL exists in the system, pulling out the metadata from the Webmention
source and fetching any internal resources.
2023-01-19 18:41:49 +07:00
Fabien "egg" O'Carroll
560d168169 Added site title and author to Mention entity
refs https://github.com/TryGhost/Team/issues/2435

We've made these fields optional, and we may need to extend this to other fields
too as we discover more about the data we're able to get access to.
2023-01-19 18:41:49 +07:00
Fabien "egg" O'Carroll
1babf6126a Added initial basic Mentions implementation
refs https://github.com/TryGhost/Team/issues/2416

This extends the mock API to use a more formal pattern of moving our
entity code into a separate package, and use the service/repository
patterns we've been work toward.

The repository is currently in memory, this allows us to start using
the API without having to make commitments to the database structure.

We've also injected a single fake webmention for testing. I'd expect
the Mention object to change a lot from this initial definition as we
gain more information about the type of data we expect to see.
2023-01-17 17:01:20 +07:00
Ronald Langeveld
e55405691a
Added webmentions package (#16133)
refs https://github.com/TryGhost/Team/issues/2408

- Added webmentions package 
- Setup basic folder structure, controllers, repositories & services to
get started.
- note package haven't been published yet
2023-01-17 13:18:16 +08:00