Merge tag 'v2.9.3' into hometown-2.9.3

This commit is contained in:
Darius Kazemi
2019-08-19 14:28:19 -07:00
98 changed files with 852 additions and 270 deletions

View File

@ -15,6 +15,8 @@ class ActivityPub::ProcessAccountService < BaseService
@domain = domain
@collections = {}
return if auto_suspend?
RedisLock.acquire(lock_options) do |lock|
if lock.acquired?
@account = Account.find_remote(@username, @domain)
@ -55,7 +57,7 @@ class ActivityPub::ProcessAccountService < BaseService
@account.domain = @domain
@account.private_key = nil
@account.suspended_at = domain_block.created_at if auto_suspend?
@account.silenced_at = domain_block.created_at if auto_silence?
@account.silenced_at = domain_block.created_at if auto_silence?
end
def update_account

View File

@ -10,12 +10,24 @@ class AfterBlockDomainFromAccountService < BaseService
@account = account
@domain = domain
clear_notifications!
remove_follows!
reject_existing_followers!
reject_pending_follow_requests!
end
private
def remove_follows!
@account.active_relationships.where(account: Account.where(domain: @domain)).includes(:target_account).reorder(nil).find_each do |follow|
UnfollowService.new.call(@account, follow.target_account)
end
end
def clear_notifications!
Notification.where(account: @account).where(from_account: Account.where(domain: @domain)).in_batches.delete_all
end
def reject_existing_followers!
@account.passive_relationships.where(account: Account.where(domain: @domain)).includes(:account).reorder(nil).find_each do |follow|
reject_follow!(follow)

View File

@ -2,43 +2,25 @@
class AfterBlockService < BaseService
def call(account, target_account)
clear_home_feed(account, target_account)
clear_notifications(account, target_account)
clear_conversations(account, target_account)
@account = account
@target_account = target_account
clear_home_feed!
clear_notifications!
clear_conversations!
end
private
def clear_home_feed(account, target_account)
FeedManager.instance.clear_from_timeline(account, target_account)
def clear_home_feed!
FeedManager.instance.clear_from_timeline(@account, @target_account)
end
def clear_conversations(account, target_account)
AccountConversation.where(account: account)
.where('? = ANY(participant_account_ids)', target_account.id)
.in_batches
.destroy_all
def clear_conversations!
AccountConversation.where(account: @account).where('? = ANY(participant_account_ids)', @target_account.id).in_batches.destroy_all
end
def clear_notifications(account, target_account)
Notification.where(account: account)
.joins(:follow)
.where(activity_type: 'Follow', follows: { account_id: target_account.id })
.delete_all
Notification.where(account: account)
.joins(mention: :status)
.where(activity_type: 'Mention', statuses: { account_id: target_account.id })
.delete_all
Notification.where(account: account)
.joins(:favourite)
.where(activity_type: 'Favourite', favourites: { account_id: target_account.id })
.delete_all
Notification.where(account: account)
.joins(:status)
.where(activity_type: 'Status', statuses: { account_id: target_account.id })
.delete_all
def clear_notifications!
Notification.where(account: @account).where(from_account: @target_account).in_batches.delete_all
end
end

View File

@ -142,5 +142,7 @@ class BackupService < BaseService
io.write(buffer)
end
end
rescue Errno::ENOENT
Rails.logger.warn "Could not backup file #{filename}: file not found"
end
end

View File

@ -8,7 +8,7 @@ class BlockService < BaseService
UnfollowService.new.call(account, target_account) if account.following?(target_account)
UnfollowService.new.call(target_account, account) if target_account.following?(account)
RejectFollowService.new.call(account, target_account) if target_account.requested?(account)
RejectFollowService.new.call(target_account, account) if target_account.requested?(account)
block = account.block!(target_account)

View File

@ -13,7 +13,7 @@ class FollowService < BaseService
target_account = ResolveAccountService.new.call(target_account, skip_webfinger: true)
raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
raise Mastodon::NotPermittedError if target_account.blocking?(source_account) || source_account.blocking?(target_account) || target_account.moved?
raise Mastodon::NotPermittedError if target_account.blocking?(source_account) || source_account.blocking?(target_account) || target_account.moved? || source_account.domain_blocking?(target_account.domain)
if source_account.following?(target_account)
# We're already following this account, but we'll call follow! again to

View File

@ -48,7 +48,7 @@ class ResolveAccountService < BaseService
return
end
return if links_missing?
return if links_missing? || auto_suspend?
return Account.find_local(@username) if TagManager.instance.local_domain?(@domain)
RedisLock.acquire(lock_options) do |lock|

View File

@ -66,6 +66,7 @@ class SuspendAccountService < BaseService
@account.user.destroy
else
@account.user.disable!
@account.user.invites.where(uses: 0).destroy_all
end
end