about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-05-15 18:44:21 +0200
committerGitHub <noreply@github.com>2019-05-15 18:44:21 +0200
commitc1cf8c1636e0a639cced585f0cb234547a64d417 (patch)
tree77b40e8bb0b1682bebaebebfa32d135ba406ac14 /app/services
parent4bab7d7640a72ffeb04c104a93ad6d3d5700c712 (diff)
parent6badf2d252a980d496b894c7258a778c57639953 (diff)
Merge pull request #1049 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/services')
-rw-r--r--app/services/activitypub/process_account_service.rb12
-rw-r--r--app/services/block_domain_service.rb6
-rw-r--r--app/services/post_status_service.rb2
-rw-r--r--app/services/process_mentions_service.rb2
-rw-r--r--app/services/resolve_account_service.rb6
-rw-r--r--app/services/subscribe_service.rb2
-rw-r--r--app/services/suspend_account_service.rb4
-rw-r--r--app/services/unblock_domain_service.rb15
8 files changed, 27 insertions, 22 deletions
diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb
index 6d0609ca0..ad22d37fe 100644
--- a/app/services/activitypub/process_account_service.rb
+++ b/app/services/activitypub/process_account_service.rb
@@ -50,12 +50,12 @@ class ActivityPub::ProcessAccountService < BaseService
 
   def create_account
     @account = Account.new
-    @account.protocol    = :activitypub
-    @account.username    = @username
-    @account.domain      = @domain
-    @account.suspended   = true if auto_suspend?
-    @account.silenced    = true if auto_silence?
-    @account.private_key = nil
+    @account.protocol     = :activitypub
+    @account.username     = @username
+    @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?
   end
 
   def update_account
diff --git a/app/services/block_domain_service.rb b/app/services/block_domain_service.rb
index a1fe93665..497f0394b 100644
--- a/app/services/block_domain_service.rb
+++ b/app/services/block_domain_service.rb
@@ -29,7 +29,7 @@ class BlockDomainService < BaseService
   end
 
   def silence_accounts!
-    blocked_domain_accounts.in_batches.update_all(silenced: true)
+    blocked_domain_accounts.without_silenced.in_batches.update_all(silenced_at: @domain_block.created_at)
   end
 
   def clear_media!
@@ -43,9 +43,9 @@ class BlockDomainService < BaseService
   end
 
   def suspend_accounts!
-    blocked_domain_accounts.where(suspended: false).reorder(nil).find_each do |account|
+    blocked_domain_accounts.without_suspended.reorder(nil).find_each do |account|
       UnsubscribeService.new.call(account) if account.subscribed?
-      SuspendAccountService.new.call(account)
+      SuspendAccountService.new.call(account, suspended_at: @domain_block.created_at)
     end
   end
 
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index 333bf88d8..d2cca145b 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -52,7 +52,7 @@ class PostStatusService < BaseService
      @text = @media.find(&:video?) ? '📹' : '🖼' if @media.size > 0
     end
     @visibility   = @options[:visibility] || @account.user&.setting_default_privacy
-    @visibility   = :unlisted if @visibility == :public && @account.silenced
+    @visibility   = :unlisted if @visibility == :public && @account.silenced?
     @scheduled_at = @options[:scheduled_at]&.to_datetime
     @scheduled_at = nil if scheduled_in_the_past?
   rescue ArgumentError
diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb
index 1d9448e21..989cc19a6 100644
--- a/app/services/process_mentions_service.rb
+++ b/app/services/process_mentions_service.rb
@@ -25,7 +25,7 @@ class ProcessMentionsService < BaseService
         end
       end
 
-      next match if mention_undeliverable?(mentioned_account) || mentioned_account&.suspended
+      next match if mention_undeliverable?(mentioned_account) || mentioned_account&.suspended?
 
       mentions << mentioned_account.mentions.where(status: status).first_or_create(status: status)
 
diff --git a/app/services/resolve_account_service.rb b/app/services/resolve_account_service.rb
index 4ff351c5f..11e33a83a 100644
--- a/app/services/resolve_account_service.rb
+++ b/app/services/resolve_account_service.rb
@@ -119,9 +119,9 @@ class ResolveAccountService < BaseService
     Rails.logger.debug "Creating new remote account for #{@username}@#{@domain}"
 
     @account = Account.new(username: @username, domain: @domain)
-    @account.suspended   = true if auto_suspend?
-    @account.silenced    = true if auto_silence?
-    @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.private_key  = nil
   end
 
   def update_account
diff --git a/app/services/subscribe_service.rb b/app/services/subscribe_service.rb
index 2893b5410..83fd64396 100644
--- a/app/services/subscribe_service.rb
+++ b/app/services/subscribe_service.rb
@@ -43,7 +43,7 @@ class SubscribeService < BaseService
   end
 
   def some_local_account
-    @some_local_account ||= Account.local.where(suspended: false).first
+    @some_local_account ||= Account.local.without_suspended.first
   end
 
   # Any response in the 3xx or 4xx range, except for 429 (rate limit)
diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb
index 6c2ecad30..412873f84 100644
--- a/app/services/suspend_account_service.rb
+++ b/app/services/suspend_account_service.rb
@@ -88,8 +88,8 @@ class SuspendAccountService < BaseService
 
     return if @options[:destroy]
 
-    @account.silenced         = false
-    @account.suspended        = true
+    @account.silenced_at      = nil
+    @account.suspended_at     = @options[:suspended_at] || Time.now.utc
     @account.locked           = false
     @account.display_name     = ''
     @account.note             = ''
diff --git a/app/services/unblock_domain_service.rb b/app/services/unblock_domain_service.rb
index 946b6d465..9b8526fbe 100644
--- a/app/services/unblock_domain_service.rb
+++ b/app/services/unblock_domain_service.rb
@@ -3,9 +3,9 @@
 class UnblockDomainService < BaseService
   attr_accessor :domain_block
 
-  def call(domain_block, retroactive)
+  def call(domain_block)
     @domain_block = domain_block
-    process_retroactive_updates if retroactive
+    process_retroactive_updates
     domain_block.destroy
   end
 
@@ -14,14 +14,19 @@ class UnblockDomainService < BaseService
   end
 
   def blocked_accounts
-    Account.where(domain: domain_block.domain)
+    scope = Account.where(domain: domain_block.domain)
+    if domain_block.silence?
+      scope.where(silenced_at: @domain_block.created_at)
+    else
+      scope.where(suspended_at: @domain_block.created_at)
+    end
   end
 
   def update_options
-    { domain_block_impact => false }
+    { domain_block_impact => nil }
   end
 
   def domain_block_impact
-    domain_block.silence? ? :silenced : :suspended
+    domain_block.silence? ? :silenced_at : :suspended_at
   end
 end