From f1867a73881444dfed9e093425435681ee764922 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 4 Apr 2018 21:47:39 +0200 Subject: Adjust privacy policy (#6666) * Adjust privacy policy to be more specific to Mastodon Fix #6613 * Change data retention of IP addresses from 5 years to 1 year * Add even more information * Remove all (now invalid) translations of the privacy policy * Add information about archive takeout, remove pointless consent section * Emphasis on DM privacy * Improve wording * Add line about data use for moderation purposes --- app/workers/scheduler/ip_cleanup_scheduler.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/workers') diff --git a/app/workers/scheduler/ip_cleanup_scheduler.rb b/app/workers/scheduler/ip_cleanup_scheduler.rb index 9f1593c91..a33ca031e 100644 --- a/app/workers/scheduler/ip_cleanup_scheduler.rb +++ b/app/workers/scheduler/ip_cleanup_scheduler.rb @@ -4,8 +4,10 @@ require 'sidekiq-scheduler' class Scheduler::IpCleanupScheduler include Sidekiq::Worker + RETENTION_PERIOD = 1.year + def perform - time_ago = 5.years.ago + time_ago = RETENTION_PERIOD.ago SessionActivation.where('updated_at < ?', time_ago).destroy_all User.where('last_sign_in_at < ?', time_ago).update_all(last_sign_in_ip: nil) end -- cgit From d4de2239b0ab04bf6a42db9f28d1fdd8e45f7d8b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 7 Apr 2018 21:36:58 +0200 Subject: Add a circuit breaker for ActivityPub deliveries (#7053) --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/workers/activitypub/delivery_worker.rb | 14 +++++++++----- config/initializers/stoplight.rb | 3 +++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 config/initializers/stoplight.rb (limited to 'app/workers') diff --git a/Gemfile b/Gemfile index 9e644e7ae..4a5a166bd 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,7 @@ gem 'devise-two-factor', '~> 3.0' group :pam_authentication, optional: true do gem 'devise_pam_authenticatable2', '~> 9.0' end + gem 'net-ldap', '~> 0.10' gem 'omniauth-cas', '~> 1.1' gem 'omniauth-saml', '~> 1.10' @@ -79,6 +80,7 @@ gem 'sidekiq-bulk', '~>0.1.1' gem 'simple-navigation', '~> 4.0' gem 'simple_form', '~> 3.4' gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie' +gem 'stoplight', '~> 2.1.3' gem 'strong_migrations' gem 'tty-command' gem 'tty-prompt' diff --git a/Gemfile.lock b/Gemfile.lock index a185a602e..0f5a1fb6a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -550,6 +550,7 @@ GEM net-scp (>= 1.1.2) net-ssh (>= 2.8.0) statsd-ruby (1.2.1) + stoplight (2.1.3) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) strong_migrations (0.1.9) @@ -716,6 +717,7 @@ DEPENDENCIES simple_form (~> 3.4) simplecov (~> 0.14) sprockets-rails (~> 3.2) + stoplight (~> 2.1.3) streamio-ffmpeg (~> 3.0) strong_migrations tty-command diff --git a/app/workers/activitypub/delivery_worker.rb b/app/workers/activitypub/delivery_worker.rb index e6cfd0d07..adffd1d3b 100644 --- a/app/workers/activitypub/delivery_worker.rb +++ b/app/workers/activitypub/delivery_worker.rb @@ -12,9 +12,7 @@ class ActivityPub::DeliveryWorker @source_account = Account.find(source_account_id) @inbox_url = inbox_url - perform_request do |response| - raise Mastodon::UnexpectedResponseError, response unless response_successful? response - end + perform_request failure_tracker.track_success! rescue => e @@ -30,8 +28,14 @@ class ActivityPub::DeliveryWorker request.add_headers(HEADERS) end - def perform_request(&block) - build_request.perform(&block) + def perform_request + light = Stoplight(@inbox_url) do + build_request.perform do |response| + raise Mastodon::UnexpectedResponseError, response unless response_successful?(response) + end + end + + light.run end def response_successful?(response) diff --git a/config/initializers/stoplight.rb b/config/initializers/stoplight.rb new file mode 100644 index 000000000..1bd4ee6e7 --- /dev/null +++ b/config/initializers/stoplight.rb @@ -0,0 +1,3 @@ +require 'stoplight' + +Stoplight::Light.default_data_store = Stoplight::DataStore::Redis.new(Redis.current) -- cgit