From 6d6ae9141c1bd161140d89656af8b96c4322f00a Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Wed, 7 Jan 2026 09:41:30 -0800 Subject: [PATCH] StatusParser: restore article formatting --- app/lib/activitypub/parser/status_parser.rb | 6 +++++- spec/lib/activitypub/activity/update_spec.rb | 3 ++- .../activitypub/fetch_remote_status_service_spec.rb | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/lib/activitypub/parser/status_parser.rb b/app/lib/activitypub/parser/status_parser.rb index a9553fb9f..e59efcfda 100644 --- a/app/lib/activitypub/parser/status_parser.rb +++ b/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 diff --git a/spec/lib/activitypub/activity/update_spec.rb b/spec/lib/activitypub/activity/update_spec.rb index d905f68d8..b8e218f81 100644 --- a/spec/lib/activitypub/activity/update_spec.rb +++ b/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("

Future of the Fediverse

\n\n

Guest article by Jane Mastodon

The fediverse is great reading this you will find out why!

") + # Hometown: expected Article text is different from upstream + expect(status.text).to start_with('Foo') end end end diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index 07d05d762..dd39c0d7d 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/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: '

Hi! Welcome to Hometown!

Here is a link', summary: '

Guest article by John Mastodon

The fediverse is great reading this you will find out why!

', 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 "

#{object[:name]}

\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 '

Hi! Welcome to Hometown!

Here is a link' end end