From 7964bfccdb0bc30c4f15db092b66a6f8d57f1262 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 23 Jul 2017 01:15:04 +0200 Subject: Add rake task mastodon:feeds:build to regenerate all active users' feeds (#4303) --- lib/tasks/mastodon.rake | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index bceeeaf01..edfa3a4ac 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -143,6 +143,13 @@ namespace :mastodon do task clear_all: :environment do Redis.current.keys('feed:*').each { |key| Redis.current.del(key) } end + + desc 'Generates home timelines for users who logged in in the past two weeks' + task build: :environment do + User.active.includes(:account).find_each do |u| + PrecomputeFeedService.new.call(u.account) + end + end end namespace :emails do -- cgit From 467456f7a19371fe4d50f25751a1d32a63e9f75c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 24 Jul 2017 16:17:55 +0200 Subject: Move clean up of unconfirmed users to sidekiq-scheduler (#4336) * Move clean up of unconfirmed users to sidekiq-scheduler * mastodon:daily is now deprecated --- app/workers/scheduler/user_cleanup_scheduler.rb | 13 +++++++++++++ config/sidekiq.yml | 3 +++ lib/tasks/mastodon.rake | 24 ++++++------------------ 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 app/workers/scheduler/user_cleanup_scheduler.rb (limited to 'lib') diff --git a/app/workers/scheduler/user_cleanup_scheduler.rb b/app/workers/scheduler/user_cleanup_scheduler.rb new file mode 100644 index 000000000..a8f8fbd83 --- /dev/null +++ b/app/workers/scheduler/user_cleanup_scheduler.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true +require 'sidekiq-scheduler' + +class Scheduler::UserCleanupScheduler + include Sidekiq::Worker + + def perform + User.where('confirmed_at is NULL AND confirmation_sent_at <= ?', 2.days.ago).find_in_batches do |batch| + Account.where(id: batch.map(&:account_id)).delete_all + User.where(id: batch.map(&:id)).delete_all + end + end +end diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 78aaa311c..8273c1201 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -18,3 +18,6 @@ doorkeeper_cleanup_scheduler: cron: '1 1 * * 0' class: Scheduler::DoorkeeperCleanupScheduler + user_cleanup_scheduler: + cron: '4 5 * * *' + class: Scheduler::UserCleanupScheduler diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index edfa3a4ac..226523554 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -1,18 +1,10 @@ # frozen_string_literal: true namespace :mastodon do - desc 'Execute daily tasks' + desc 'Execute daily tasks (deprecated)' task :daily do - %w( - mastodon:feeds:clear - mastodon:media:clear - mastodon:users:clear - mastodon:push:refresh - ).each do |task| - puts "Starting #{task} at #{Time.now.utc}" - Rake::Task[task].invoke - end - puts "Completed daily tasks at #{Time.now.utc}" + # No-op + # All of these tasks are now executed via sidekiq-scheduler end desc 'Turn a user into an admin, identified by the USERNAME environment variable' @@ -162,14 +154,10 @@ namespace :mastodon do end namespace :users do - desc 'Clear out unconfirmed users' + desc 'Clear out unconfirmed users (deprecated)' task clear: :environment do - # Users that never confirmed e-mail never signed in, means they - # only have a user record and an avatar record, with no files uploaded - User.where('confirmed_at is NULL AND confirmation_sent_at <= ?', 2.days.ago).find_in_batches do |batch| - Account.where(id: batch.map(&:account_id)).delete_all - User.where(id: batch.map(&:id)).delete_all - end + # No-op + # This task is now executed via sidekiq-scheduler end desc 'List e-mails of all admin users' -- cgit From a549d1ae6b33d93743a0c0c3fb1575f07a58492a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 24 Jul 2017 16:21:08 +0200 Subject: Bump to 1.5.0rc1 (#4318) --- lib/mastodon/version.rb | 10 +++++++--- spec/workers/pubsubhubbub/confirmation_worker_spec.rb | 2 +- spec/workers/pubsubhubbub/delivery_worker_spec.rb | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 3c92ce417..07969aff4 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -9,23 +9,27 @@ module Mastodon end def minor - 4 + 5 end def patch - 7 + 0 end def pre nil end + def flags + 'rc1' + end + def to_a [major, minor, patch, pre].compact end def to_s - to_a.join('.') + [to_a.join('.'), flags].join end end end diff --git a/spec/workers/pubsubhubbub/confirmation_worker_spec.rb b/spec/workers/pubsubhubbub/confirmation_worker_spec.rb index 8f66b4520..1eecdd2b5 100644 --- a/spec/workers/pubsubhubbub/confirmation_worker_spec.rb +++ b/spec/workers/pubsubhubbub/confirmation_worker_spec.rb @@ -83,6 +83,6 @@ describe Pubsubhubbub::ConfirmationWorker do end def http_headers - { 'Connection' => 'close', 'Host' => 'example.com', 'User-Agent' => 'http.rb/2.2.2 (Mastodon/1.4.7; +https://cb6e6126.ngrok.io/)' } + { 'Connection' => 'close', 'Host' => 'example.com' } end end diff --git a/spec/workers/pubsubhubbub/delivery_worker_spec.rb b/spec/workers/pubsubhubbub/delivery_worker_spec.rb index b72001568..c0e0d5186 100644 --- a/spec/workers/pubsubhubbub/delivery_worker_spec.rb +++ b/spec/workers/pubsubhubbub/delivery_worker_spec.rb @@ -59,7 +59,6 @@ describe Pubsubhubbub::DeliveryWorker do 'Content-Type' => 'application/atom+xml', 'Host' => 'example.com', 'Link' => "; rel=\"hub\", ; rel=\"self\"", - 'User-Agent' => 'http.rb/2.2.2 (Mastodon/1.4.7; +https://cb6e6126.ngrok.io/)', }.tap do |basic| known_digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), subscription.secret.to_s, payload) basic.merge('X-Hub-Signature' => "sha1=#{known_digest}") if subscription.secret? -- cgit