Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/controllers/home_controller.rb`: Upstream made it so `/web` is available to non-logged-in users and `/` redirects to `/web` instead of `/about`. Kept our version since glitch-soc's WebUI doesn't have what's needed yet and I think /about is still a much better landing page anyway. - `app/models/form/admin_settings.rb`: Upstream added new settings, and glitch-soc had an extra setting. Not really a conflict. Added upstream's new settings. - `app/serializers/initial_state_serializer.rb`: Upstream added a new `server` initial state object. Not really a conflict. Merged upstream's changes. - `app/views/admin/settings/edit.html.haml`: Upstream added new settings. Not really a conflict. Merged upstream's changes. - `app/workers/scheduler/feed_cleanup_scheduler.rb`: Upstream refactored that part and removed the file. Ported our relevant changes into `app/lib/vacuum/feeds_vacuum.rb` - `config/settings.yml`: Upstream added new settings. Not a real conflict. Added upstream's new settings.
This commit is contained in:
@ -37,7 +37,7 @@ class ActivityPub::DeliveryWorker
|
||||
|
||||
def build_request(http_client)
|
||||
Request.new(:post, @inbox_url, body: @json, http_client: http_client).tap do |request|
|
||||
request.on_behalf_of(@source_account, :uri, sign_with: @options[:sign_with])
|
||||
request.on_behalf_of(@source_account, sign_with: @options[:sign_with])
|
||||
request.add_headers(HEADERS)
|
||||
request.add_headers({ 'Collection-Synchronization' => synchronization_header }) if ENV['DISABLE_FOLLOWERS_SYNCHRONIZATION'] != 'true' && @options[:synchronize_followers]
|
||||
end
|
||||
|
@ -5,11 +5,15 @@ class ActivityPub::ProcessingWorker
|
||||
|
||||
sidekiq_options backtrace: true, retry: 8
|
||||
|
||||
def perform(account_id, body, delivered_to_account_id = nil)
|
||||
account = Account.find_by(id: account_id)
|
||||
return if account.nil?
|
||||
def perform(actor_id, body, delivered_to_account_id = nil, actor_type = 'Account')
|
||||
case actor_type
|
||||
when 'Account'
|
||||
actor = Account.find_by(id: actor_id)
|
||||
end
|
||||
|
||||
ActivityPub::ProcessCollectionService.new.call(body, account, override_timestamps: true, delivered_to_account_id: delivered_to_account_id, delivery: true)
|
||||
return if actor.nil?
|
||||
|
||||
ActivityPub::ProcessCollectionService.new.call(body, actor, override_timestamps: true, delivered_to_account_id: delivered_to_account_id, delivery: true)
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
Rails.logger.debug "Error processing incoming ActivityPub object: #{e}"
|
||||
end
|
||||
|
@ -10,8 +10,9 @@ class RefollowWorker
|
||||
return unless target_account.activitypub?
|
||||
|
||||
target_account.passive_relationships.where(account: Account.where(domain: nil)).includes(:account).reorder(nil).find_each do |follow|
|
||||
reblogs = follow.show_reblogs?
|
||||
notify = follow.notify?
|
||||
reblogs = follow.show_reblogs?
|
||||
notify = follow.notify?
|
||||
languages = follow.languages
|
||||
|
||||
# Locally unfollow remote account
|
||||
follower = follow.account
|
||||
@ -19,7 +20,7 @@ class RefollowWorker
|
||||
|
||||
# Schedule re-follow
|
||||
begin
|
||||
FollowService.new.call(follower, target_account, reblogs: reblogs, notify: notify, bypass_limit: true)
|
||||
FollowService.new.call(follower, target_account, reblogs: reblogs, notify: notify, languages: languages, bypass_limit: true)
|
||||
rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError
|
||||
next
|
||||
end
|
||||
|
@ -1,17 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::BackupCleanupScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
|
||||
def perform
|
||||
old_backups.reorder(nil).find_each(&:destroy!)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def old_backups
|
||||
Backup.where('created_at < ?', 7.days.ago)
|
||||
end
|
||||
end
|
@ -1,13 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::DoorkeeperCleanupScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
|
||||
def perform
|
||||
Doorkeeper::AccessToken.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all
|
||||
Doorkeeper::AccessGrant.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all
|
||||
SystemKey.expired.delete_all
|
||||
end
|
||||
end
|
@ -1,40 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::FeedCleanupScheduler
|
||||
include Sidekiq::Worker
|
||||
include Redisable
|
||||
|
||||
sidekiq_options retry: 0
|
||||
|
||||
def perform
|
||||
clean_home_feeds!
|
||||
clean_list_feeds!
|
||||
clean_direct_feeds!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clean_home_feeds!
|
||||
feed_manager.clean_feeds!(:home, inactive_account_ids)
|
||||
end
|
||||
|
||||
def clean_list_feeds!
|
||||
feed_manager.clean_feeds!(:list, inactive_list_ids)
|
||||
end
|
||||
|
||||
def clean_direct_feeds!
|
||||
feed_manager.clean_feeds!(:direct, inactive_account_ids)
|
||||
end
|
||||
|
||||
def inactive_account_ids
|
||||
@inactive_account_ids ||= User.confirmed.inactive.pluck(:account_id)
|
||||
end
|
||||
|
||||
def inactive_list_ids
|
||||
List.where(account_id: inactive_account_ids).pluck(:id)
|
||||
end
|
||||
|
||||
def feed_manager
|
||||
FeedManager.instance
|
||||
end
|
||||
end
|
@ -1,17 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::MediaCleanupScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
|
||||
def perform
|
||||
unattached_media.find_each(&:destroy)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def unattached_media
|
||||
MediaAttachment.reorder(nil).unattached.where('created_at < ?', 1.day.ago)
|
||||
end
|
||||
end
|
56
app/workers/scheduler/vacuum_scheduler.rb
Normal file
56
app/workers/scheduler/vacuum_scheduler.rb
Normal file
@ -0,0 +1,56 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::VacuumScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
|
||||
def perform
|
||||
vacuum_operations.each do |operation|
|
||||
operation.perform
|
||||
rescue => e
|
||||
Rails.logger.error("Error while running #{operation.class.name}: #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def vacuum_operations
|
||||
[
|
||||
statuses_vacuum,
|
||||
media_attachments_vacuum,
|
||||
preview_cards_vacuum,
|
||||
backups_vacuum,
|
||||
access_tokens_vacuum,
|
||||
feeds_vacuum,
|
||||
]
|
||||
end
|
||||
|
||||
def statuses_vacuum
|
||||
Vacuum::StatusesVacuum.new(content_retention_policy.content_cache_retention_period)
|
||||
end
|
||||
|
||||
def media_attachments_vacuum
|
||||
Vacuum::MediaAttachmentsVacuum.new(content_retention_policy.media_cache_retention_period)
|
||||
end
|
||||
|
||||
def preview_cards_vacuum
|
||||
Vacuum::PreviewCardsVacuum.new(content_retention_policy.media_cache_retention_period)
|
||||
end
|
||||
|
||||
def backups_vacuum
|
||||
Vacuum::BackupsVacuum.new(content_retention_policy.backups_retention_period)
|
||||
end
|
||||
|
||||
def access_tokens_vacuum
|
||||
Vacuum::AccessTokensVacuum.new
|
||||
end
|
||||
|
||||
def feeds_vacuum
|
||||
Vacuum::FeedsVacuum.new
|
||||
end
|
||||
|
||||
def content_retention_policy
|
||||
ContentRetentionPolicy.current
|
||||
end
|
||||
end
|
@ -10,11 +10,12 @@ class UnfollowFollowWorker
|
||||
old_target_account = Account.find(old_target_account_id)
|
||||
new_target_account = Account.find(new_target_account_id)
|
||||
|
||||
follow = follower_account.active_relationships.find_by(target_account: old_target_account)
|
||||
reblogs = follow&.show_reblogs?
|
||||
notify = follow&.notify?
|
||||
follow = follower_account.active_relationships.find_by(target_account: old_target_account)
|
||||
reblogs = follow&.show_reblogs?
|
||||
notify = follow&.notify?
|
||||
languages = follow&.languages
|
||||
|
||||
FollowService.new.call(follower_account, new_target_account, reblogs: reblogs, notify: notify, bypass_locked: bypass_locked, bypass_limit: true)
|
||||
FollowService.new.call(follower_account, new_target_account, reblogs: reblogs, notify: notify, languages: languages, bypass_locked: bypass_locked, bypass_limit: true)
|
||||
UnfollowService.new.call(follower_account, old_target_account, skip_unmerge: true)
|
||||
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
||||
true
|
||||
|
Reference in New Issue
Block a user