Merge commit 'f877aa9d70d0d600961989b8e97c0e0ce3ac1db6' into glitch-soc/merge-upstream

Conflicts:
- `.github/dependabot.yml`:
  Upstream made changes, but we had removed it.
  Discarded upstream changes.
- `.rubocop_todo.yml`:
  Upstream regenerated the file, we had some glitch-soc-specific ignores.
- `app/models/account_statuses_filter.rb`:
  Minor upstream code style change where glitch-soc had slightly different code
  due to handling of local-only posts.
  Updated to match upstream's code style.
- `app/models/status.rb`:
  Upstream moved ActiveRecord callback definitions, glitch-soc had an extra one.
  Moved the definitions as upstream did.
- `app/services/backup_service.rb`:
  Upstream rewrote a lot of the backup service, glitch-soc had changes because
  of exporting local-only posts.
  Took upstream changes and added back code to deal with local-only posts.
- `config/routes.rb`:
  Upstream split the file into different files, while glitch-soc had a few
  extra routes.
  Extra routes added to `config/routes/settings.rb`, `config/routes/api.rb`
  and `config/routes/admin.rb`
- `db/schema.rb`:
  Upstream has new migrations, while glitch-soc had an extra migration.
  Updated the expected serial number to match upstream's.
- `lib/mastodon/version.rb`:
  Upstream added support to set version tags from environment variables, while
  glitch-soc has an extra `+glitch` tag.
  Changed the code to support upstream's feature but prepending a `+glitch`.
- `spec/lib/activitypub/activity/create_spec.rb`:
  Minor code style change upstream, while glitch-soc has extra tests due to
  `directMessage` handling.
  Applied upstream's changes while keeping glitch-soc's extra tests.
- `spec/models/concerns/account_interactions_spec.rb`:
  Minor code style change upstream, while glitch-soc has extra tests.
  Applied upstream's changes while keeping glitch-soc's extra tests.
This commit is contained in:
Claire
2023-05-08 19:05:55 +02:00
429 changed files with 6138 additions and 3323 deletions

View File

@@ -43,7 +43,7 @@ RSpec.describe ActivityPub::Activity::Accept do
end
end
context 'given a relay' do
context 'when given a relay' do
subject { described_class.new(json, sender) }
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }

View File

@@ -39,7 +39,7 @@ RSpec.describe ActivityPub::Activity::Announce do
subject.perform
end
context 'a known status' do
context 'with known status' do
let(:object_json) do
ActivityPub::TagManager.instance.uri_for(status)
end
@@ -49,7 +49,7 @@ RSpec.describe ActivityPub::Activity::Announce do
end
end
context 'an unknown status' do
context 'with unknown status' do
let(:object_json) { 'https://example.com/actor/hello-world' }
it 'creates a reblog by sender of status' do
@@ -60,7 +60,7 @@ RSpec.describe ActivityPub::Activity::Announce do
end
end
context 'self-boost of a previously unknown status with correct attributedTo' do
context 'when self-boost of a previously unknown status with correct attributedTo' do
let(:object_json) do
{
id: 'https://example.com/actor#bar',
@@ -76,7 +76,7 @@ RSpec.describe ActivityPub::Activity::Announce do
end
end
context 'self-boost of a previously unknown status with correct attributedTo, inlined Collection in audience' do
context 'when self-boost of a previously unknown status with correct attributedTo, inlined Collection in audience' do
let(:object_json) do
{
id: 'https://example.com/actor#bar',
@@ -123,7 +123,7 @@ RSpec.describe ActivityPub::Activity::Announce do
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json))
end
context 'and the relay is enabled' do
context 'when the relay is enabled' do
before do
relay.update(state: :accepted)
subject.perform
@@ -135,7 +135,7 @@ RSpec.describe ActivityPub::Activity::Announce do
end
end
context 'and the relay is disabled' do
context 'when the relay is disabled' do
before do
subject.perform
end

View File

@@ -31,7 +31,7 @@ RSpec.describe ActivityPub::Activity::Create do
subject.perform
end
context 'object has been edited' do
context 'when object has been edited' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -57,7 +57,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'object has update date equal to creation date' do
context 'when object has update date equal to creation date' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -83,7 +83,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'unknown object type' do
context 'with an unknown object type' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -97,7 +97,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'standalone' do
context 'with a standalone' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -121,7 +121,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'public with explicit public address' do
context 'when public with explicit public address' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -139,7 +139,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'public with as:Public' do
context 'when public with as:Public' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -157,7 +157,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'public with Public' do
context 'when public with Public' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -175,7 +175,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'unlisted with explicit public address' do
context 'when unlisted with explicit public address' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -193,7 +193,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'unlisted with as:Public' do
context 'when unlisted with as:Public' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -211,7 +211,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'unlisted with Public' do
context 'when unlisted with Public' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -229,7 +229,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'private' do
context 'when private' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -247,7 +247,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'private with inlined Collection in audience' do
context 'when private with inlined Collection in audience' do
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
@@ -269,7 +269,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'limited' do
context 'when limited' do
let(:recipient) { Fabricate(:account) }
let(:object_json) do
@@ -294,7 +294,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'limited when direct message assertion is false' do
context 'when directMessage attribute is false' do
let(:recipient) { Fabricate(:account) }
let(:object_json) do
@@ -311,7 +311,7 @@ RSpec.describe ActivityPub::Activity::Create do
}
end
it 'creates status' do
it 'creates status with limited visibility' do
status = sender.statuses.first
expect(status).to_not be_nil
@@ -319,7 +319,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'direct' do
context 'when direct' do
let(:recipient) { Fabricate(:account) }
let(:object_json) do
@@ -335,7 +335,7 @@ RSpec.describe ActivityPub::Activity::Create do
}
end
it 'creates status' do
it 'creates status with direct visibility' do
status = sender.statuses.first
expect(status).to_not be_nil
@@ -343,7 +343,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'direct when direct message assertion is true' do
context 'when directMessage attribute is true' do
let(:recipient) { Fabricate(:account) }
let(:object_json) do
@@ -364,7 +364,7 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'as a reply' do
context 'with a reply' do
let(:original_status) { Fabricate(:status) }
let(:object_json) do

View File

@@ -20,7 +20,7 @@ RSpec.describe ActivityPub::Activity::Follow do
subject { described_class.new(json, sender) }
context 'with no prior follow' do
context 'unlocked account' do
context 'with an unlocked account' do
before do
subject.perform
end
@@ -35,7 +35,7 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'silenced account following an unlocked account' do
context 'when silenced account following an unlocked account' do
before do
sender.touch(:silenced_at)
subject.perform
@@ -51,7 +51,7 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'unlocked account muting the sender' do
context 'with an unlocked account muting the sender' do
before do
recipient.mute!(sender)
subject.perform
@@ -67,7 +67,7 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'locked account' do
context 'when locked account' do
before do
recipient.update(locked: true)
subject.perform
@@ -89,7 +89,7 @@ RSpec.describe ActivityPub::Activity::Follow do
sender.active_relationships.create!(target_account: recipient, uri: 'bar')
end
context 'unlocked account' do
context 'with an unlocked account' do
before do
subject.perform
end
@@ -103,7 +103,7 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'silenced account following an unlocked account' do
context 'when silenced account following an unlocked account' do
before do
sender.touch(:silenced_at)
subject.perform
@@ -118,7 +118,7 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'unlocked account muting the sender' do
context 'with an unlocked account muting the sender' do
before do
recipient.mute!(sender)
subject.perform
@@ -133,7 +133,7 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'locked account' do
context 'when locked account' do
before do
recipient.update(locked: true)
subject.perform
@@ -154,7 +154,7 @@ RSpec.describe ActivityPub::Activity::Follow do
sender.follow_requests.create!(target_account: recipient, uri: 'bar')
end
context 'silenced account following an unlocked account' do
context 'when silenced account following an unlocked account' do
before do
sender.touch(:silenced_at)
subject.perform
@@ -170,7 +170,7 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'locked account' do
context 'when locked account' do
before do
recipient.update(locked: true)
subject.perform

View File

@@ -27,7 +27,7 @@ RSpec.describe ActivityPub::Activity::Reject do
describe '#perform' do
subject { described_class.new(json, sender) }
context 'rejecting a pending follow request by target' do
context 'when rejecting a pending follow request by target' do
before do
Fabricate(:follow_request, account: recipient, target_account: sender)
subject.perform
@@ -42,7 +42,7 @@ RSpec.describe ActivityPub::Activity::Reject do
end
end
context 'rejecting a pending follow request by uri' do
context 'when rejecting a pending follow request by uri' do
before do
Fabricate(:follow_request, account: recipient, target_account: sender, uri: 'bar')
subject.perform
@@ -57,7 +57,7 @@ RSpec.describe ActivityPub::Activity::Reject do
end
end
context 'rejecting a pending follow request by uri only' do
context 'when rejecting a pending follow request by uri only' do
let(:object_json) { 'bar' }
before do
@@ -74,7 +74,7 @@ RSpec.describe ActivityPub::Activity::Reject do
end
end
context 'rejecting an existing follow relationship by target' do
context 'when rejecting an existing follow relationship by target' do
before do
Fabricate(:follow, account: recipient, target_account: sender)
subject.perform
@@ -89,7 +89,7 @@ RSpec.describe ActivityPub::Activity::Reject do
end
end
context 'rejecting an existing follow relationship by uri' do
context 'when rejecting an existing follow relationship by uri' do
before do
Fabricate(:follow, account: recipient, target_account: sender, uri: 'bar')
subject.perform
@@ -104,7 +104,7 @@ RSpec.describe ActivityPub::Activity::Reject do
end
end
context 'rejecting an existing follow relationship by uri only' do
context 'when rejecting an existing follow relationship by uri only' do
let(:object_json) { 'bar' }
before do
@@ -122,7 +122,7 @@ RSpec.describe ActivityPub::Activity::Reject do
end
end
context 'given a relay' do
context 'when given a relay' do
subject { described_class.new(json, sender) }
let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') }

View File

@@ -3,43 +3,51 @@
require 'rails_helper'
RSpec.describe ActivityPub::Adapter do
class TestObject < ActiveModelSerializers::Model
attributes :foo
end
class TestWithBasicContextSerializer < ActivityPub::Serializer
attributes :foo
end
class TestWithNamedContextSerializer < ActivityPub::Serializer
context :security
attributes :foo
end
class TestWithNestedNamedContextSerializer < ActivityPub::Serializer
attributes :foo
has_one :virtual_object, key: :baz, serializer: TestWithNamedContextSerializer
def virtual_object
object
before do
test_object_class = Class.new(ActiveModelSerializers::Model) do
attributes :foo
end
end
stub_const('TestObject', test_object_class)
class TestWithContextExtensionSerializer < ActivityPub::Serializer
context_extensions :sensitive
attributes :foo
end
class TestWithNestedContextExtensionSerializer < ActivityPub::Serializer
context_extensions :manually_approves_followers
attributes :foo
has_one :virtual_object, key: :baz, serializer: TestWithContextExtensionSerializer
def virtual_object
object
test_with_basic_context_serializer = Class.new(ActivityPub::Serializer) do
attributes :foo
end
stub_const('TestWithBasicContextSerializer', test_with_basic_context_serializer)
test_with_named_context_serializer = Class.new(ActivityPub::Serializer) do
context :security
attributes :foo
end
stub_const('TestWithNamedContextSerializer', test_with_named_context_serializer)
test_with_nested_named_context_serializer = Class.new(ActivityPub::Serializer) do
attributes :foo
has_one :virtual_object, key: :baz, serializer: TestWithNamedContextSerializer
def virtual_object
object
end
end
stub_const('TestWithNestedNamedContextSerializer', test_with_nested_named_context_serializer)
test_with_context_extension_serializer = Class.new(ActivityPub::Serializer) do
context_extensions :sensitive
attributes :foo
end
stub_const('TestWithContextExtensionSerializer', test_with_context_extension_serializer)
test_with_nested_context_extension_serializer = Class.new(ActivityPub::Serializer) do
context_extensions :manually_approves_followers
attributes :foo
has_one :virtual_object, key: :baz, serializer: TestWithContextExtensionSerializer
def virtual_object
object
end
end
stub_const('TestWithNestedContextExtensionSerializer', test_with_nested_context_extension_serializer)
end
describe '#serializable_hash' do