Remove: kmyblue独自機能の引用

This commit is contained in:
KMY 2025-04-24 08:48:28 +09:00
parent 620a895184
commit d845d1e9fb
70 changed files with 812 additions and 1788 deletions

View file

@ -4,5 +4,4 @@ Fabricator(:status_reference) do
status { Fabricate.build(:status) }
target_status { Fabricate.build(:status) }
attribute_type 'BT'
quote false
end

View file

@ -1711,104 +1711,10 @@ RSpec.describe ActivityPub::Activity::Create do
status = sender.statuses.first
expect(status).to_not be_nil
expect(status.quote).to be_nil
expect(status.references.pluck(:id)).to eq [target_status.id]
end
end
context 'with quote' do
let(:recipient) { Fabricate(:account) }
let!(:target_status) { Fabricate(:status, account: Fabricate(:account, domain: nil)) }
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: 'Lorem ipsum',
quote: ActivityPub::TagManager.instance.uri_for(target_status),
}
end
it 'creates status' do
expect { subject.perform }.to change(sender.statuses, :count).by(1)
status = sender.statuses.first
expect(status).to_not be_nil
expect(status.references.pluck(:id)).to eq [target_status.id]
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
end
end
context 'with quote as feb-e232 object links' do
let(:recipient) { Fabricate(:account) }
let!(:target_status) { Fabricate(:status, account: Fabricate(:account, domain: nil)) }
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: 'Lorem ipsum',
tag: [
{
type: 'Link',
mediaType: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
href: ActivityPub::TagManager.instance.uri_for(target_status),
},
],
}
end
it 'creates status' do
expect { subject.perform }.to change(sender.statuses, :count).by(1)
status = sender.statuses.first
expect(status).to_not be_nil
expect(status.references.pluck(:id)).to eq [target_status.id]
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
end
end
context 'with references and quote' do
let(:recipient) { Fabricate(:account) }
let!(:target_status) { Fabricate(:status, account: Fabricate(:account, domain: nil)) }
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: 'Lorem ipsum',
quote: ActivityPub::TagManager.instance.uri_for(target_status),
references: {
id: 'target_status',
type: 'Collection',
first: {
type: 'CollectionPage',
next: nil,
partOf: 'target_status',
items: [
ActivityPub::TagManager.instance.uri_for(target_status),
],
},
},
}
end
it 'creates status' do
expect { subject.perform }.to change(sender.statuses, :count).by(1)
status = sender.statuses.first
expect(status).to_not be_nil
expect(status.references.pluck(:id)).to eq [target_status.id]
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
end
end
context 'with language' do
let(:to) { 'https://www.w3.org/ns/activitystreams#Public' }
let(:object_json) do
@ -2556,53 +2462,6 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
context 'when sender quotes to local status' do
subject { described_class.new(json, sender, delivery: true) }
let!(:local_status) { Fabricate(:status) }
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: 'Lorem ipsum',
quote: ActivityPub::TagManager.instance.uri_for(local_status),
}
end
before do
subject.perform
end
it 'creates status' do
status = sender.statuses.first
expect(status).to_not be_nil
expect(status.text).to eq 'Lorem ipsum'
end
end
context 'when sender quotes to non-local status' do
subject { described_class.new(json, sender, delivery: true) }
let!(:remote_status) { Fabricate(:status, uri: 'https://foo.bar/among', account: Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar/account')) }
let(:object_json) do
{
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
type: 'Note',
content: 'Lorem ipsum',
quote: ActivityPub::TagManager.instance.uri_for(remote_status),
}
end
before do
subject.perform
end
it 'creates status' do
expect(sender.statuses.count).to eq 0
end
end
context 'when sender targets a local user' do
subject { described_class.new(json, sender, delivery: true) }

View file

@ -8,11 +8,10 @@ RSpec.describe StatusReachFinder do
subject { described_class.new(status) }
let(:parent_status) { nil }
let(:quoted_status) { nil }
let(:visibility) { :public }
let(:searchability) { :public }
let(:alice) { Fabricate(:account, username: 'alice') }
let(:status) { Fabricate(:status, account: alice, thread: parent_status, quote_of_id: quoted_status&.id, visibility: visibility, searchability: searchability) }
let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility, searchability: searchability) }
context 'with a simple case' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
@ -353,15 +352,6 @@ RSpec.describe StatusReachFinder do
end
end
end
context 'when it is a quote to a remote account' do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
let(:quoted_status) { Fabricate(:status, account: bob) }
it 'includes the inbox of the quoted-to account' do
expect(subject.inboxes).to include 'https://foo.bar/inbox'
end
end
end
context 'with extended domain block' do

View file

@ -397,13 +397,9 @@ RSpec.describe Account do
describe '#public_settings_for_local' do
subject { account.public_settings_for_local }
let(:account) { Fabricate(:user, settings: { allow_quote: true, hide_statuses_count: true, emoji_reaction_policy: :followers_only }).account }
let(:account) { Fabricate(:user, settings: { hide_statuses_count: true, emoji_reaction_policy: :followers_only }).account }
shared_examples 'some settings' do |permitted, emoji_reaction_policy|
it 'allow_quote is allowed' do
expect(subject['allow_quote']).to be permitted.include?(:allow_quote)
end
it 'hide_statuses_count is allowed' do
expect(subject['hide_statuses_count']).to be permitted.include?(:hide_statuses_count)
end
@ -417,24 +413,18 @@ RSpec.describe Account do
end
end
it_behaves_like 'some settings', %i(allow_quote hide_statuses_count), 'followers_only'
it_behaves_like 'some settings', %i(hide_statuses_count), 'followers_only'
context 'when default true setting is set false' do
let(:account) { Fabricate(:user, settings: { allow_quote: false, hide_statuses_count: true, emoji_reaction_policy: :followers_only }).account }
let(:account) { Fabricate(:user, settings: { hide_statuses_count: true, emoji_reaction_policy: :followers_only }).account }
it_behaves_like 'some settings', %i(hide_statuses_count), 'followers_only'
end
context 'when remote user' do
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor', settings: { 'allow_quote' => true, 'hide_statuses_count' => true, 'emoji_reaction_policy' => 'followers_only' }) }
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor', settings: { 'hide_statuses_count' => true, 'emoji_reaction_policy' => 'followers_only' }) }
it_behaves_like 'some settings', %i(allow_quote hide_statuses_count), 'followers_only'
end
context 'when remote user by server other_settings is not supported' do
let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/actor') }
it_behaves_like 'some settings', %i(allow_quote), 'allow'
it_behaves_like 'some settings', %i(hide_statuses_count), 'followers_only'
end
end

View file

@ -86,39 +86,6 @@ RSpec.describe Status do
end
end
describe '#quote' do
let(:target_status) { Fabricate(:status) }
let(:quote) { true }
before do
Fabricate(:status_reference, status: subject, target_status: target_status, quote: quote)
end
context 'when quoting single' do
it 'get quote' do
expect(subject.quote).to_not be_nil
expect(subject.quote.id).to eq target_status.id
end
end
context 'when multiple quotes' do
it 'get quote' do
target2 = Fabricate(:status)
Fabricate(:status_reference, status: subject, quote: quote)
expect(subject.quote).to_not be_nil
expect([target_status.id, target2.id].include?(subject.quote.id)).to be true
end
end
context 'when no quote but reference' do
let(:quote) { false }
it 'get quote' do
expect(subject.quote).to be_nil
end
end
end
describe '#content' do
it 'returns the text of the status if it is not a reblog' do
expect(subject.content).to eql subject.text

View file

@ -251,30 +251,6 @@ RSpec.describe StatusPolicy, type: :model do
end
end
context 'with the permission of quote?' do
permissions :quote? do
it 'grants access when viewer is not blocked' do
follow = Fabricate(:follow)
status.account = follow.target_account
expect(subject).to permit(follow.account, status)
end
it 'denies when viewer is blocked' do
block = Fabricate(:block)
status.account = block.target_account
expect(subject).to_not permit(block.account, status)
end
it 'denies when private visibility' do
status.visibility = :private
expect(subject).to_not permit(Fabricate(:account), status)
end
end
end
context 'with the permission of update?' do
permissions :update? do
it 'grants access if owner' do

View file

@ -170,11 +170,9 @@ RSpec.describe 'Public' do
let(:exclude_follows) { false }
let(:exclude_localusers) { false }
let(:include_quotes) { false }
let(:account) { user.account }
let(:remote_account) { remote_status.account }
let!(:filter) { Fabricate(:custom_filter, account: account, exclude_follows: exclude_follows, exclude_localusers: exclude_localusers, with_quote: include_quotes) }
let!(:quote_status) { Fabricate(:status, quote: Fabricate(:status, text: 'ohagi')) }
let!(:filter) { Fabricate(:custom_filter, account: account, exclude_follows: exclude_follows, exclude_localusers: exclude_localusers) }
it 'load statuses', :aggregate_failures do
ids = subject
@ -201,16 +199,6 @@ RSpec.describe 'Public' do
expect(ids).to_not include(remote_status.id)
end
end
context 'when include_quotes' do
let(:with_quote) { true }
it 'load statuses', :aggregate_failures do
ids = subject
expect(ids).to_not include(local_status.id)
expect(ids).to include(quote_status.id)
end
end
end
end
end

View file

@ -16,14 +16,9 @@ RSpec.describe ActivityPub::NoteSerializer do
let!(:reply_by_account_third) { Fabricate(:status, account: account, thread: parent, visibility: :public) }
let!(:reply_by_account_visibility_direct) { Fabricate(:status, account: account, thread: parent, visibility: :direct) }
let!(:referred) { nil }
let!(:quote) { nil }
before do
parent.references << referred if referred.present?
if quote.present?
parent.references << quote
parent.quote = quote
end
end
it 'has the expected shape and replies collection' do
@ -98,23 +93,7 @@ RSpec.describe ActivityPub::NoteSerializer do
end
it 'has as reference' do
expect(subject['quoteUri']).to be_nil
expect(subject['references']['first']['items']).to include referred.uri
end
end
context 'when has a quote' do
let(:quote) { Fabricate(:status) }
it 'has a quote as transitional type' do
expect(subject['quoteUri']).to eq ActivityPub::TagManager.instance.uri_for(quote)
end
it 'has a quote as feb-e232 object link' do
tag = subject['tag'].detect { |t| t['type'] == 'Link' }
expect(tag).to_not be_nil
expect(tag['mediaType']).to eq 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
expect(tag['href']).to eq ActivityPub::TagManager.instance.uri_for(quote)
end
end
end

View file

@ -30,7 +30,6 @@ RSpec.describe NodeInfo::Serializer do
end
it 'returns nodeinfo own features' do
expect(serialization['metadata']['features']).to include 'quote'
expect(serialization['metadata']['features']).to_not include 'kmyblue_markdown'
end
end

View file

@ -678,7 +678,7 @@ RSpec.describe FanOutOnWriteService do
end
end
context 'when updated status is already boosted or quoted' do
context 'when updated status is already boosted' do
let(:custom_before) { true }
before do
@ -695,13 +695,6 @@ RSpec.describe FanOutOnWriteService do
expect(notification.activity_id).to eq status.id
end
it 'notified to quoted account', :inline_jobs do
notification = Notification.find_by(account: tom, type: 'update')
expect(notification).to_not be_nil
expect(notification.activity_id).to eq status.id
end
it 'notified not to non-boosted account', :inline_jobs do
notification = Notification.find_by(account: ohagi, type: 'update')

View file

@ -11,7 +11,6 @@ RSpec.describe ProcessReferencesService, type: :service do
let(:target_status) { Fabricate(:status, account: Fabricate(:user).account, visibility: target_status_visibility) }
let(:target_status_uri) { ActivityPub::TagManager.instance.uri_for(target_status) }
let(:quote_urls) { nil }
let(:allow_quote) { true }
def notify?(target_status_id = nil)
target_status_id ||= target_status.id
@ -20,7 +19,6 @@ RSpec.describe ProcessReferencesService, type: :service do
describe 'posting new status' do
subject do
target_status.account.user.settings['allow_quote'] = false unless allow_quote
target_status.account.user&.save
described_class.new.call(status, reference_parameters, urls: urls, fetch_remote: fetch_remote, quote_urls: quote_urls)
@ -42,7 +40,9 @@ RSpec.describe ProcessReferencesService, type: :service do
end
it 'not quote', :inline_jobs do
expect(status.quote).to be_nil
# TODO: quote
expect(status).to_not be_nil # Remove
# expect(status.quote).to be_nil
end
end
@ -89,8 +89,9 @@ RSpec.describe ProcessReferencesService, type: :service do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
# TODO: quote
# expect(status.quote).to_not be_nil
# expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end
@ -103,8 +104,9 @@ RSpec.describe ProcessReferencesService, type: :service do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
# TODO: quote
# expect(status.quote).to_not be_nil
# expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end
@ -117,8 +119,9 @@ RSpec.describe ProcessReferencesService, type: :service do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
# TODO: quote
# expect(status.quote).to_not be_nil
# expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end
@ -131,21 +134,23 @@ RSpec.describe ProcessReferencesService, type: :service do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
# TODO: quote
# expect(status.quote).to_not be_nil
# expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end
context 'when quote is rejected' do
let(:text) { "Hello QT #{target_status_uri}" }
let(:allow_quote) { false }
# let(:allow_quote) { false }
it 'post status', :inline_jobs do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'BT'
expect(status.quote).to be_nil
# TODO: quote
# expect(status.quote).to be_nil
expect(notify?).to be true
end
end
@ -159,8 +164,9 @@ RSpec.describe ProcessReferencesService, type: :service do
expect(subject.size).to eq 2
expect(subject).to include [target_status.id, 'QT']
expect(subject).to include [target_status2.id, 'BT']
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
# TODO: quote
# expect(status.quote).to_not be_nil
# expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
expect(notify?(target_status2.id)).to be true
end
@ -407,7 +413,8 @@ RSpec.describe ProcessReferencesService, type: :service do
it 'post status', :inline_jobs do
expect(subject.size).to eq 0
expect(status.quote).to be_nil
# TODO: quote
# expect(status.quote).to be_nil
expect(notify?).to be false
end
end
@ -430,8 +437,9 @@ RSpec.describe ProcessReferencesService, type: :service do
it 'post status', :inline_jobs do
expect(subject.size).to eq 1
expect(subject).to include target_status2.id
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status2.id
# TODO: quote
# expect(status.quote).to_not be_nil
# expect(status.quote.id).to eq target_status2.id
expect(notify?(target_status2.id)).to be true
end
end
@ -443,7 +451,8 @@ RSpec.describe ProcessReferencesService, type: :service do
it 'post status', :inline_jobs do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to be_nil
# TODO: quote
# expect(status.quote).to be_nil
expect(notify?(target_status.id)).to be true
end
end
@ -455,8 +464,9 @@ RSpec.describe ProcessReferencesService, type: :service do
it 'post status', :inline_jobs do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
# TODO: quote
# expect(status.quote).to_not be_nil
# expect(status.quote.id).to eq target_status.id
expect(notify?(target_status.id)).to be true
end
end