Browse Source

StatusParser: restore article formatting

pull/1371/head
Misty De Meo 2 months ago
parent
commit
6d6ae9141c
No known key found for this signature in database
GPG Key ID: 76CF846A2F674B2C
  1. 6
      app/lib/activitypub/parser/status_parser.rb
  2. 3
      spec/lib/activitypub/activity/update_spec.rb
  3. 7
      spec/services/activitypub/fetch_remote_status_service_spec.rb

6
app/lib/activitypub/parser/status_parser.rb

@ -39,7 +39,11 @@ class ActivityPub::Parser::StatusParser
def text
if @object['content'].present?
@object['content']
if @object['type'] == 'Article'
article_format(@object['content'])
else
@object['content']
end
elsif content_language_map?
@object['contentMap'].values.first
end

3
spec/lib/activitypub/activity/update_spec.rb

@ -252,7 +252,8 @@ RSpec.describe ActivityPub::Activity::Update do
expect { subject.perform }
.to(change { status.reload.text })
expect(status.text).to start_with("<h2>Future of the Fediverse</h2>\n\n<p>Guest article by Jane Mastodon</p><p>The fediverse is great reading this you will find out why!</p>")
# Hometown: expected Article text is different from upstream
expect(status.text).to start_with('Foo')
end
end
end

7
spec/services/activitypub/fetch_remote_status_service_spec.rb

@ -168,7 +168,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
id: 'https://foo.bar/blog/future-of-the-fediverse',
type: 'Article',
name: 'Future of the Fediverse',
content: 'Lorem Ipsum',
# Hometown: testing with HTML in content
content: '<h1>Hi! Welcome to Hometown!</h1> <a href="https://example.com">Here is a link</a>',
summary: '<p>Guest article by <a href="https://john.mastodon">John Mastodon</a></p><p>The fediverse is great reading this you will find out why!</p>',
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
}
@ -179,8 +180,8 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
expect(status).to_not be_nil
expect(status.url).to eq object[:id]
expect(status.text).to start_with "<h2>#{object[:name]}</h2>\n\n#{object[:summary]}\n\n"
expect(status.text).to include "href=\"#{object[:id]}\""
# Hometown: expected Article text is different from upstream
expect(status.text).to eq '<h1>Hi! Welcome to Hometown!</h1> <a href="https://example.com" rel="nofollow noopener" target="_blank">Here is a link</a>'
end
end

Loading…
Cancel
Save