Merge commit '4896d2c4c6d3bd6b878c5a075b6611c65d4203b2' into glitch-soc/merge-upstream

Conflicts:
- `app/views/settings/preferences/appearance/show.html.haml`:
  Upstream changed stuff too close to glitch-soc's theming system changes.
  Applied upstream's changes.
- `streaming/index.js`:
  Upstream refactored a bunch of stuff where our code was different due to
  local-only posts.
  Applied upstream's changes while taking care of local-only posts.
This commit is contained in:
Claire committed 2025-10-28 22:10:12 +01:00
commit 48ec31bec8
136 files changed
+1041 -1409

No files matched your search

+81 -4
View File
@@ -149,18 +149,17 @@ RSpec.describe ActivityPub::Activity::Update do
shared_examples 'updates counts' do
it 'updates the reblog count' do
expect(status.untrusted_reblogs_count).to eq reblogs
expect { subject.perform }.to change { status.reload.untrusted_reblogs_count }.to(reblogs)
end
it 'updates the favourites count' do
expect(status.untrusted_favourites_count).to eq favourites
expect { subject.perform }.to change { status.reload.untrusted_favourites_count }.to(favourites)
end
end
context 'with an implicit update' do
before do
status.update!(uri: ActivityPub::TagManager.instance.uri_for(status))
subject.perform
end
it_behaves_like 'updates counts'
@@ -173,11 +172,89 @@ RSpec.describe ActivityPub::Activity::Update do
before do
status.update!(uri: ActivityPub::TagManager.instance.uri_for(status))
subject.perform
end
it_behaves_like 'updates counts'
end
end
context 'with an Article object' do
let(:updated) { nil }
let(:favourites) { 50 }
let(:reblogs) { 100 }
let!(:status) do
Fabricate(
:status,
uri: 'https://example.com/statuses/article',
account: sender,
text: "<h2>Future of the Fediverse</h2>\n\n<p>Guest article by John Mastodon</p><p>The fediverse is great reading this you will find out why!</p>"
)
end
let(:json) do
{
'@context': 'https://www.w3.org/ns/activitystreams',
id: 'foo',
type: 'Update',
actor: sender.uri,
object: {
type: 'Article',
id: status.uri,
name: 'Future of the Fediverse',
summary: '<p>Guest article by Jane Mastodon</p><p>The fediverse is great reading this you will find out why!</p>',
content: 'Foo',
updated: updated,
likes: {
id: "#{status.uri}/likes",
type: 'Collection',
totalItems: favourites,
},
shares: {
id: "#{status.uri}/shares",
type: 'Collection',
totalItems: reblogs,
},
},
}.with_indifferent_access
end
shared_examples 'updates counts' do
it 'updates the reblog count' do
expect { subject.perform }.to change { status.reload.untrusted_reblogs_count }.to(reblogs)
end
it 'updates the favourites count' do
expect { subject.perform }.to change { status.reload.untrusted_favourites_count }.to(favourites)
end
end
context 'with an implicit update' do
before do
status.update!(uri: ActivityPub::TagManager.instance.uri_for(status))
end
it_behaves_like 'updates counts'
end
context 'with an explicit update' do
let(:favourites) { 150 }
let(:reblogs) { 200 }
let(:updated) { Time.now.utc.iso8601 }
before do
status.update!(uri: ActivityPub::TagManager.instance.uri_for(status))
end
it_behaves_like 'updates counts'
it 'changes the contents as expected' 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>")
end
end
end
end
end
+13 -1
View File
@@ -35,12 +35,24 @@ RSpec.describe Extractor do
end
describe 'extract_hashtags_with_indices' do
it 'returns an empty array if it does not have #' do
it 'returns an empty array if it does not have # or #' do
text = 'a string without hash sign'
extracted = described_class.extract_hashtags_with_indices(text)
expect(extracted).to eq []
end
it 'returns hashtags preceded by an ASCII hash' do
text = 'hello #world'
extracted = described_class.extract_hashtags_with_indices(text)
expect(extracted).to eq [{ hashtag: 'world', indices: [6, 12] }]
end
it 'returns hashtags preceded by a full-width hash' do
text = 'hello #world'
extracted = described_class.extract_hashtags_with_indices(text)
expect(extracted).to eq [{ hashtag: 'world', indices: [6, 12] }]
end
it 'does not exclude normal hash text before ://' do
text = '#hashtag://'
extracted = described_class.extract_hashtags_with_indices(text)
+4
View File
@@ -84,6 +84,10 @@ RSpec.describe Tag do
expect(subject.match('this is #aesthetic').to_s).to eq '#aesthetic'
end
it 'matches #foo' do
expect(subject.match('this is #foo').to_s).to eq '#foo'
end
it 'matches digits at the start' do
expect(subject.match('hello #3d').to_s).to eq '#3d'
end
+23
View File
@@ -248,6 +248,29 @@ RSpec.describe '/api/v1/statuses' do
end
end
context 'with a quote of a reblog' do
let(:quoted_status) { Fabricate(:status, quote_approval_policy: Status::QUOTE_APPROVAL_POLICY_FLAGS[:public] << 16) }
let(:reblog) { Fabricate(:status, reblog: quoted_status) }
let(:params) do
{
status: 'Hello world, this is a self-quote',
quoted_status_id: reblog.id,
}
end
it 'returns a quote post, as well as rate limit headers', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:quote]).to be_present
expect(response.parsed_body[:quote][:quoted_status][:id]).to eq quoted_status.id.to_s
expect(response.headers['X-RateLimit-Limit']).to eq RateLimiter::FAMILIES[:statuses][:limit].to_s
expect(response.headers['X-RateLimit-Remaining']).to eq (RateLimiter::FAMILIES[:statuses][:limit] - 1).to_s
end
end
context 'with a self-quote post and a CW but no text' do
let(:quoted_status) { Fabricate(:status, account: user.account) }
let(:params) do
+1 -28
View File
@@ -352,34 +352,7 @@ RSpec.describe 'signature verification concern' do
end
end
# TODO: Remove when feature is enabled
context 'with an HTTP Message Signature (final RFC version) when support is disabled' do
before { Fabricate(:account, domain: 'remote.domain', uri: 'https://remote.domain/users/bob', private_key: nil, public_key: actor_keypair.public_key.to_pem) }
context 'with a valid signature on a GET request' do
let(:signature_input) do
'sig1=("@method" "@target-uri");created=1703066400;keyid="https://remote.domain/users/bob#main-key"'
end
let(:signature_header) do
'sig1=:WfM6q/qBqhUyqPUDt9metjadJGtLLpmMTBzk/t+R3byKe4/TGAXC6vBB/M6NsD5qv8GCmQGtisCMQxJQO0IGODGzi+Jv+eqDJ50agMVXNV6nUOzY44c4/XTPoI98qyx1oEMa4Hefy3vSYKq96iDVAc+RDLCMTeGP3wn9wizjD1SNmU0RZI1bTB+eCkywMP9mM5zXzUOYF+Qkuf+WdEpPR1XUGPlnqfdvPalcKVfaI/VThBjI91D/lmUGoa69x4EBEHM+aJmW6086e7/dVh+FndKkdGfXslZXFZKi2flTGQZgEWLn948SqAaJQROkJg8B14Sb1NONS1qZBhK3Mum8Pg==:' # rubocop:disable Layout/LineLength
end
it 'cannot verify signature', :aggregate_failures do
get '/activitypub/signature_required', headers: {
'Host' => 'www.example.com',
'Signature-Input' => signature_input,
'Signature' => signature_header,
}
expect(response).to have_http_status(401)
expect(response.parsed_body).to match(
error: 'Error parsing signature parameters'
)
end
end
end
context 'with an HTTP Message Signature (final RFC version)', feature: :http_message_signatures do
context 'with an HTTP Message Signature (final RFC version)' do
context 'with a known account' do
let!(:actor) { Fabricate(:account, domain: 'remote.domain', uri: 'https://remote.domain/users/bob', private_key: nil, public_key: actor_keypair.public_key.to_pem) }