diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-19 01:37:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-19 01:37:26 +0200 |
commit | a5a07da8926589647160ac642a8e082bbeca4451 (patch) | |
tree | 68930c791ce499eebf2c1bcd589d53c3b935d8ac | |
parent | 72108b20e215a866ae4ce54bd2113e36551ba2ef (diff) |
Correct OStatus inflection (Ostatus -> OStatus) (#4255)
23 files changed, 193 insertions, 192 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 37a1e540f40..c270eb000c4 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -13,7 +13,7 @@ class AccountsController < ApplicationController format.atom do @entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id]) - render xml: Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.feed(@account, @entries.to_a)) + render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.to_a)) end format.json do diff --git a/app/controllers/stream_entries_controller.rb b/app/controllers/stream_entries_controller.rb index e3db77caaa2..3eb91d8305a 100644 --- a/app/controllers/stream_entries_controller.rb +++ b/app/controllers/stream_entries_controller.rb @@ -19,7 +19,7 @@ class StreamEntriesController < ApplicationController end format.atom do - render xml: Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.entry(@stream_entry, true)) + render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.entry(@stream_entry, true)) end end end diff --git a/app/lib/ostatus/activity/base.rb b/app/lib/ostatus/activity/base.rb index f528815b3e1..e1477f0eb22 100644 --- a/app/lib/ostatus/activity/base.rb +++ b/app/lib/ostatus/activity/base.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Base +class OStatus::Activity::Base def initialize(xml, account = nil) @xml = xml @account = account diff --git a/app/lib/ostatus/activity/creation.rb b/app/lib/ostatus/activity/creation.rb index c54d64fd776..e22f746f2c8 100644 --- a/app/lib/ostatus/activity/creation.rb +++ b/app/lib/ostatus/activity/creation.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Creation < Ostatus::Activity::Base +class OStatus::Activity::Creation < OStatus::Activity::Base def perform if redis.exists("delete_upon_arrival:#{@account.id}:#{id}") Rails.logger.debug "Delete for status #{id} was queued, ignoring" diff --git a/app/lib/ostatus/activity/deletion.rb b/app/lib/ostatus/activity/deletion.rb index c4d05a4679f..860faf501e6 100644 --- a/app/lib/ostatus/activity/deletion.rb +++ b/app/lib/ostatus/activity/deletion.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Deletion < Ostatus::Activity::Base +class OStatus::Activity::Deletion < OStatus::Activity::Base def perform Rails.logger.debug "Deleting remote status #{id}" status = Status.find_by(uri: id, account: @account) diff --git a/app/lib/ostatus/activity/general.rb b/app/lib/ostatus/activity/general.rb index 3ff7a039a68..b3bef9861dc 100644 --- a/app/lib/ostatus/activity/general.rb +++ b/app/lib/ostatus/activity/general.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::General < Ostatus::Activity::Base +class OStatus::Activity::General < OStatus::Activity::Base def specialize special_class&.new(@xml, @account) end @@ -10,11 +10,11 @@ class Ostatus::Activity::General < Ostatus::Activity::Base def special_class case verb when :post - Ostatus::Activity::Post + OStatus::Activity::Post when :share - Ostatus::Activity::Share + OStatus::Activity::Share when :delete - Ostatus::Activity::Deletion + OStatus::Activity::Deletion end end end diff --git a/app/lib/ostatus/activity/post.rb b/app/lib/ostatus/activity/post.rb index 8028db2f8d5..755ed865639 100644 --- a/app/lib/ostatus/activity/post.rb +++ b/app/lib/ostatus/activity/post.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Post < Ostatus::Activity::Creation +class OStatus::Activity::Post < OStatus::Activity::Creation def perform status, just_created = super diff --git a/app/lib/ostatus/activity/remote.rb b/app/lib/ostatus/activity/remote.rb index 755f885e625..ecec6886c0e 100644 --- a/app/lib/ostatus/activity/remote.rb +++ b/app/lib/ostatus/activity/remote.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Remote < Ostatus::Activity::Base +class OStatus::Activity::Remote < OStatus::Activity::Base def perform find_status(id) || FetchRemoteStatusService.new.call(url) end diff --git a/app/lib/ostatus/activity/share.rb b/app/lib/ostatus/activity/share.rb index 73aac58ed27..29000802165 100644 --- a/app/lib/ostatus/activity/share.rb +++ b/app/lib/ostatus/activity/share.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::Activity::Share < Ostatus::Activity::Creation +class OStatus::Activity::Share < OStatus::Activity::Creation def perform return if reblog.nil? @@ -18,7 +18,7 @@ class Ostatus::Activity::Share < Ostatus::Activity::Creation def reblog return @reblog if defined? @reblog - original_status = Ostatus::Activity::Remote.new(object).perform + original_status = OStatus::Activity::Remote.new(object).perform return if original_status.nil? @reblog = original_status.reblog? ? original_status.reblog : original_status diff --git a/app/lib/ostatus/atom_serializer.rb b/app/lib/ostatus/atom_serializer.rb index 909d84df312..0d62361bec9 100644 --- a/app/lib/ostatus/atom_serializer.rb +++ b/app/lib/ostatus/atom_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Ostatus::AtomSerializer +class OStatus::AtomSerializer include RoutingHelper include ActionView::Helpers::SanitizeHelper diff --git a/app/services/authorize_follow_service.rb b/app/services/authorize_follow_service.rb index a25d11dbd51..41815a393e9 100644 --- a/app/services/authorize_follow_service.rb +++ b/app/services/authorize_follow_service.rb @@ -10,6 +10,6 @@ class AuthorizeFollowService < BaseService private def build_xml(follow_request) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.authorize_follow_request_salmon(follow_request)) end end diff --git a/app/services/block_service.rb b/app/services/block_service.rb index 15420e192d2..5d7bf6a3bc2 100644 --- a/app/services/block_service.rb +++ b/app/services/block_service.rb @@ -18,6 +18,6 @@ class BlockService < BaseService private def build_xml(block) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.block_salmon(block)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.block_salmon(block)) end end diff --git a/app/services/concerns/stream_entry_renderer.rb b/app/services/concerns/stream_entry_renderer.rb index d9c30c53cf3..9f6c8a082ae 100644 --- a/app/services/concerns/stream_entry_renderer.rb +++ b/app/services/concerns/stream_entry_renderer.rb @@ -2,6 +2,6 @@ module StreamEntryRenderer def stream_entry_to_xml(stream_entry) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.entry(stream_entry, true)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.entry(stream_entry, true)) end end diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index a08aba6380b..291f9e56ef1 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -28,6 +28,6 @@ class FavouriteService < BaseService private def build_xml(favourite) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.favourite_salmon(favourite)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.favourite_salmon(favourite)) end end diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index 7a7275b6e72..3155feaa498 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -57,10 +57,10 @@ class FollowService < BaseService end def build_follow_request_xml(follow_request) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.follow_request_salmon(follow_request)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_request_salmon(follow_request)) end def build_follow_xml(follow) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.follow_salmon(follow)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.follow_salmon(follow)) end end diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index b99048a068c..9fa8eda5192 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -20,7 +20,7 @@ class ProcessFeedService < BaseService end def process_entry(xml, account) - activity = Ostatus::Activity::General.new(xml, account) + activity = OStatus::Activity::General.new(xml, account) activity.specialize&.perform if activity.status? rescue ActiveRecord::RecordInvalid => e Rails.logger.debug "Nothing was saved for #{id} because: #{e}" diff --git a/app/services/reject_follow_service.rb b/app/services/reject_follow_service.rb index 87fc49b348c..fd7e66c2373 100644 --- a/app/services/reject_follow_service.rb +++ b/app/services/reject_follow_service.rb @@ -10,6 +10,6 @@ class RejectFollowService < BaseService private def build_xml(follow_request) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.reject_follow_request_salmon(follow_request)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.reject_follow_request_salmon(follow_request)) end end diff --git a/app/services/unblock_service.rb b/app/services/unblock_service.rb index 50c2dc2f01c..ff15c727548 100644 --- a/app/services/unblock_service.rb +++ b/app/services/unblock_service.rb @@ -11,6 +11,6 @@ class UnblockService < BaseService private def build_xml(block) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.unblock_salmon(block)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unblock_salmon(block)) end end diff --git a/app/services/unfavourite_service.rb b/app/services/unfavourite_service.rb index ede3caad17b..564aaee46a7 100644 --- a/app/services/unfavourite_service.rb +++ b/app/services/unfavourite_service.rb @@ -13,6 +13,6 @@ class UnfavouriteService < BaseService private def build_xml(favourite) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.unfavourite_salmon(favourite)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfavourite_salmon(favourite)) end end diff --git a/app/services/unfollow_service.rb b/app/services/unfollow_service.rb index 0c9a5f65771..388909586b2 100644 --- a/app/services/unfollow_service.rb +++ b/app/services/unfollow_service.rb @@ -14,6 +14,6 @@ class UnfollowService < BaseService private def build_xml(follow) - Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.unfollow_salmon(follow)) + OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.unfollow_salmon(follow)) end end diff --git a/app/workers/pubsubhubbub/distribution_worker.rb b/app/workers/pubsubhubbub/distribution_worker.rb index 9c1fa76cb9f..ce467d18b1d 100644 --- a/app/workers/pubsubhubbub/distribution_worker.rb +++ b/app/workers/pubsubhubbub/distribution_worker.rb @@ -22,7 +22,7 @@ class Pubsubhubbub::DistributionWorker def distribute_public!(stream_entries) return if stream_entries.empty? - @payload = Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.feed(@account, stream_entries)) + @payload = OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, stream_entries)) Pubsubhubbub::DeliveryWorker.push_bulk(@subscriptions) do |subscription| [subscription.id, @payload] @@ -32,7 +32,7 @@ class Pubsubhubbub::DistributionWorker def distribute_hidden!(stream_entries) return if stream_entries.empty? - @payload = Ostatus::AtomSerializer.render(Ostatus::AtomSerializer.new.feed(@account, stream_entries)) + @payload = OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, stream_entries)) @domains = @account.followers.domains Pubsubhubbub::DeliveryWorker.push_bulk(@subscriptions.reject { |s| !allowed_to_receive?(s.callback_url, s.domain) }) do |subscription| diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 26275d0928c..44e54c9f369 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -13,6 +13,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'StatsD' inflect.acronym 'OEmbed' + inflect.acronym 'OStatus' inflect.acronym 'ActivityPub' inflect.acronym 'PubSubHubbub' inflect.acronym 'ActivityStreams' diff --git a/spec/lib/ostatus/atom_serializer_spec.rb b/spec/lib/ostatus/atom_serializer_spec.rb index 8caef935545..b0cb8f019eb 100644 --- a/spec/lib/ostatus/atom_serializer_spec.rb +++ b/spec/lib/ostatus/atom_serializer_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Ostatus::AtomSerializer do +RSpec.describe OStatus::AtomSerializer do shared_examples 'follow request salmon' do it 'appends author element with account' do account = Fabricate(:account, domain: nil, username: 'username') @@ -108,7 +108,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns XML with emojis' do element = Ox::Element.new('tag') element << '💩' - xml = Ostatus::AtomSerializer.render(element) + xml = OStatus::AtomSerializer.render(element) expect(xml).to eq "<?xml version=\"1.0\"?>\n<tag>💩</tag>\n" end @@ -116,7 +116,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'returns XML, stripping invalid characters like \b and \v' do element = Ox::Element.new('tag') element << "im l33t\b haxo\b\vr" - xml = Ostatus::AtomSerializer.render(element) + xml = OStatus::AtomSerializer.render(element) expect(xml).to eq "<?xml version=\"1.0\"?>\n<tag>im l33t haxor</tag>\n" end @@ -127,7 +127,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends poco:note element with note for local account' do account = Fabricate(:account, domain: nil, note: '<p>note</p>') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) note = author.nodes.find { |node| node.name == 'poco:note' } expect(note.text).to eq '<p>note</p>' @@ -136,7 +136,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends poco:note element with tags-stripped note for remote account' do account = Fabricate(:account, domain: 'remote', note: '<p>note</p>') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) note = author.nodes.find { |node| node.name == 'poco:note' } expect(note.text).to eq 'note' @@ -144,7 +144,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends summary element with type attribute and simplified note if present' do account = Fabricate(:account, note: 'note') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.summary.text).to eq '<p>note</p>' expect(author.summary[:type]).to eq 'html' end @@ -153,27 +153,27 @@ RSpec.describe Ostatus::AtomSerializer do context 'when note is not present' do it 'does not append poco:note element' do account = Fabricate(:account, note: '') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each { |node| expect(node.name).not_to eq 'poco:note' } end it 'does not append summary element' do account = Fabricate(:account, note: '') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each { |node| expect(node.name).not_to eq 'summary' } end end it 'returns author element' do account = Fabricate(:account) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.name).to eq 'author' end it 'appends activity:object-type element with person type' do account = Fabricate(:account, domain: nil, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) object_type = author.nodes.find { |node| node.name == 'activity:object-type' } expect(object_type.text).to eq TagManager::TYPES[:person] @@ -181,20 +181,20 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends email element with username and domain for local account' do account = Fabricate(:account, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.email.text).to eq 'username@cb6e6126.ngrok.io' end it 'appends email element with username and domain for remote user' do account = Fabricate(:account, domain: 'domain', username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) expect(author.email.text).to eq 'username@domain' end it 'appends link element for an alternative' do account = Fabricate(:account, domain: nil, username: 'username') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) link = author.nodes.find { |node| node.name == 'link' && node[:rel] == 'alternate' } expect(link[:type]).to eq 'text/html' @@ -205,7 +205,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'has link element for avatar if present' do account = Fabricate(:account, avatar: attachment_fixture('avatar.gif')) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) link = author.nodes.find { |node| node.name == 'link' && node[:rel] == 'avatar' } expect(link[:type]).to eq 'image/gif' @@ -217,7 +217,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not have link element for avatar if not present' do account = Fabricate(:account, avatar: nil) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each do |node| expect(node[:rel]).not_to eq 'avatar' if node.name == 'link' @@ -227,7 +227,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends link element for header if present' do account = Fabricate(:account, header: attachment_fixture('avatar.gif')) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) link = author.nodes.find { |node| node.name == 'link' && node[:rel] == 'header' } expect(link[:type]).to eq 'image/gif' @@ -239,7 +239,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append link element for header if not present' do account = Fabricate(:account, header: nil) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each do |node| expect(node[:rel]).not_to eq 'header' if node.name == 'link' @@ -249,7 +249,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'appends poco:displayName element with display name if present' do account = Fabricate(:account, display_name: 'display name') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) display_name = author.nodes.find { |node| node.name == 'poco:displayName' } expect(display_name.text).to eq 'display name' @@ -257,14 +257,14 @@ RSpec.describe Ostatus::AtomSerializer do it 'does not append poco:displayName element with display name if not present' do account = Fabricate(:account, display_name: '') - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) author.nodes.each { |node| expect(node.name).not_to eq 'poco:displayName' } end it "appends mastodon:scope element with 'private' if locked" do account = Fabricate(:account, locked: true) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) scope = author.nodes.find { |node| node.name == 'mastodon:scope' } expect(scope.text).to eq 'private' @@ -273,7 +273,7 @@ RSpec.describe Ostatus::AtomSerializer do it "appends mastodon:scope element with 'public' if unlocked" do account = Fabricate(:account, locked: false) - author = Ostatus::AtomSerializer.new.author(account) + author = OStatus::AtomSerializer.new.author(account) scope = author.nodes.find { |node| node.name == 'mastodon:scope' } expect(scope.text).to eq 'public' @@ -282,7 +282,7 @@ RSpec.describe Ostatus::AtomSerializer do it 'includes URI' do account = Fabricate(:account, domain: nil, username: 'username') |