From 6de079a5af328d26d7cbc8daf3367d16c311fddb Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 18 Dec 2016 12:17:45 +0100 Subject: [PATCH] Removing external hub completely, fix #333 fixing digit-only hashtags, removing web app capability from non-webapp pages --- README.md | 1 - app/models/tag.rb | 2 +- app/services/favourite_service.rb | 1 - app/services/follow_service.rb | 1 - app/services/post_status_service.rb | 1 - app/services/reblog_service.rb | 1 - app/services/remove_status_service.rb | 1 - app/views/accounts/show.atom.ruby | 1 - app/views/home/index.html.haml | 1 + app/views/layouts/application.html.haml | 1 - app/workers/hub_ping_worker.rb | 12 ------------ config/initializers/ostatus.rb | 1 - spec/controllers/api/v1/follows_controller_spec.rb | 5 ----- spec/services/reblog_service_spec.rb | 5 ----- 14 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 app/workers/hub_ping_worker.rb diff --git a/README.md b/README.md index 0eb9bbe3e78..3add104739e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,6 @@ If you would like, you can [support the development of this project on Patreon][ - `LOCAL_DOMAIN` should be the domain/hostname of your instance. This is **absolutely required** as it is used for generating unique IDs for everything federation-related - `LOCAL_HTTPS` set it to `true` if HTTPS works on your website. This is used to generate canonical URLs, which is also important when generating and parsing federation-related IDs -- `HUB_URL` should be the URL of the PubsubHubbub service that your instance is going to use. By default it is the open service of Superfeedr Consult the example configuration file, `.env.production.sample` for the full list. Among other things you need to set details for the SMTP server you are going to use. diff --git a/app/models/tag.rb b/app/models/tag.rb index e5b0511ae7e..77a73cce8b0 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -3,7 +3,7 @@ class Tag < ApplicationRecord has_and_belongs_to_many :statuses - HASHTAG_RE = /(?:^|[^\/\w])#([[:word:]_]+)/i + HASHTAG_RE = /(?:^|[^\/\w])#([[:word:]_]*[[:alpha:]_][[:word:]_]*)/i validates :name, presence: true, uniqueness: true diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index 2f280e03fe2..5c04cfee474 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -8,7 +8,6 @@ class FavouriteService < BaseService def call(account, status) favourite = Favourite.create!(account: account, status: status) - HubPingWorker.perform_async(account.id) Pubsubhubbub::DistributionWorker.perform_async(favourite.stream_entry.id) if status.local? diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index 423b833cfbd..ed9b624552c 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -20,7 +20,6 @@ class FollowService < BaseService merge_into_timeline(target_account, source_account) - HubPingWorker.perform_async(source_account.id) Pubsubhubbub::DistributionWorker.perform_async(follow.stream_entry.id) follow diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 9e0ced129cb..d5204151b00 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -16,7 +16,6 @@ class PostStatusService < BaseService process_hashtags_service.call(status) DistributionWorker.perform_async(status.id) - HubPingWorker.perform_async(account.id) Pubsubhubbub::DistributionWorker.perform_async(status.stream_entry.id) status diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 39fdb4ea7d6..7d0c90d2f65 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -9,7 +9,6 @@ class ReblogService < BaseService reblog = account.statuses.create!(reblog: reblogged_status, text: '') DistributionWorker.perform_async(reblog.id) - HubPingWorker.perform_async(account.id) Pubsubhubbub::DistributionWorker.perform_async(reblog.stream_entry.id) if reblogged_status.local? diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index fa55e668e92..836b8fdc594 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -13,7 +13,6 @@ class RemoveStatusService < BaseService return unless status.account.local? - HubPingWorker.perform_async(status.account.id) Pubsubhubbub::DistributionWorker.perform_async(status.stream_entry.id) end diff --git a/app/views/accounts/show.atom.ruby b/app/views/accounts/show.atom.ruby index b2903d189b5..a225683960c 100644 --- a/app/views/accounts/show.atom.ruby +++ b/app/views/accounts/show.atom.ruby @@ -15,7 +15,6 @@ Nokogiri::XML::Builder.new do |xml| link_alternate xml, TagManager.instance.url_for(@account) link_self xml, account_url(@account, format: 'atom') link_hub xml, api_push_url - link_hub xml, Rails.configuration.x.hub_url link_salmon xml, api_salmon_url(@account.id) @entries.each do |stream_entry| diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 498fae105c2..0adce05bf01 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,4 +1,5 @@ - content_for :header_tags do + %meta{:name => "apple-mobile-web-app-capable", :content => "yes"}/ = javascript_include_tag 'application' = react_component 'Mastodon', default_props, class: 'app-holder', prerender: false diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 87f98198c82..7e28d27ec2e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -9,7 +9,6 @@ %link{:rel => "manifest", :href => "/manifest.json"}/ %meta{:name => "msapplication-config", :content => "/browserconfig.xml"}/ %meta{:name => "theme-color", :content => "#2b90d9"}/ - %meta{:name => "apple-mobile-web-app-capable", :content => "yes"}/ %title = "#{yield(:page_title)} - " if content_for?(:page_title) diff --git a/app/workers/hub_ping_worker.rb b/app/workers/hub_ping_worker.rb deleted file mode 100644 index 14a151ba098..00000000000 --- a/app/workers/hub_ping_worker.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class HubPingWorker - include Sidekiq::Worker - include RoutingHelper - - def perform(account_id) - account = Account.find(account_id) - return unless account.local? - OStatus2::Publication.new(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url]).publish - end -end diff --git a/config/initializers/ostatus.rb b/config/initializers/ostatus.rb index c5723b2e948..faa9940b0b2 100644 --- a/config/initializers/ostatus.rb +++ b/config/initializers/ostatus.rb @@ -6,7 +6,6 @@ https = ENV['LOCAL_HTTPS'] == 'true' Rails.application.configure do config.x.local_domain = host - config.x.hub_url = ENV.fetch('HUB_URL') { 'https://pubsubhubbub.superfeedr.com' } config.x.use_https = https config.x.use_s3 = ENV['S3_ENABLED'] == 'true' diff --git a/spec/controllers/api/v1/follows_controller_spec.rb b/spec/controllers/api/v1/follows_controller_spec.rb index 1346141fa69..97d69ab7bff 100644 --- a/spec/controllers/api/v1/follows_controller_spec.rb +++ b/spec/controllers/api/v1/follows_controller_spec.rb @@ -18,7 +18,6 @@ RSpec.describe Api::V1::FollowsController, type: :controller do stub_request(:get, "https://quitter.no/avatar/7477-300-20160211190340.png").to_return(request_fixture('avatar.txt')) stub_request(:post, "https://quitter.no/main/push/hub").to_return(:status => 200, :body => "", :headers => {}) stub_request(:post, "https://quitter.no/main/salmon/user/7477").to_return(:status => 200, :body => "", :headers => {}) - stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {}) post :create, params: { uri: 'gargron@quitter.no' } end @@ -39,10 +38,6 @@ RSpec.describe Api::V1::FollowsController, type: :controller do expect(a_request(:post, "https://quitter.no/main/salmon/user/7477")).to have_been_made end - it 'notifies own hub' do - expect(a_request(:post, "https://pubsubhubbub.superfeedr.com/")).to have_been_made - end - it 'subscribes to remote hub' do expect(a_request(:post, "https://quitter.no/main/push/hub")).to have_been_made end diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index f0a40fe91c9..5f89169e9be 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -8,7 +8,6 @@ RSpec.describe ReblogService do subject { ReblogService.new } before do - stub_request(:post, Rails.configuration.x.hub_url) stub_request(:post, 'http://salmon.example.com') subject.(alice, status) @@ -18,10 +17,6 @@ RSpec.describe ReblogService do expect(status.reblogs.count).to eq 1 end - it 'pings PubSubHubbub hubs' do - expect(a_request(:post, Rails.configuration.x.hub_url)).to have_been_made - end - it 'sends a Salmon slap for a remote reblog' do expect(a_request(:post, 'http://salmon.example.com')).to have_been_made end