about summary refs log tree commit diff
path: root/app/services/unsuspend_account_service.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-11-08 14:20:35 +0100
committerThibaut Girka <thib@sitedethib.com>2020-11-08 14:20:35 +0100
commit0437d70628bcd852c303432562c74202554fe9cb (patch)
tree27b6ff5abf280517ae6a8abd585f15e02d35fd58 /app/services/unsuspend_account_service.rb
parentcfb16b9b70a50ec5451c9aebb2c35d3a44701311 (diff)
parent3134691948aeacb16b7386ed77bbea4581beec40 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/follower_accounts_controller.rb`:
  Conflict due to upstream changing suspension logic while
  glitch-soc has an extra option to hide followers count.
  Ported upstream changes.
Diffstat (limited to 'app/services/unsuspend_account_service.rb')
-rw-r--r--app/services/unsuspend_account_service.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/services/unsuspend_account_service.rb b/app/services/unsuspend_account_service.rb
index 91dbc9c18..a81d1ac4f 100644
--- a/app/services/unsuspend_account_service.rb
+++ b/app/services/unsuspend_account_service.rb
@@ -5,6 +5,10 @@ class UnsuspendAccountService < BaseService
     @account = account
 
     unsuspend!
+    refresh_remote_account!
+
+    return if @account.nil?
+
     merge_into_home_timelines!
     merge_into_list_timelines!
     publish_media_attachments!
@@ -16,6 +20,22 @@ class UnsuspendAccountService < BaseService
     @account.unsuspend! if @account.suspended?
   end
 
+  def refresh_remote_account!
+    return if @account.local?
+
+    # While we had the remote account suspended, it could be that
+    # it got suspended on its origin, too. So, we need to refresh
+    # it straight away so it gets marked as remotely suspended in
+    # that case.
+
+    @account.update!(last_webfingered_at: nil)
+    @account = ResolveAccountService.new.call(@account)
+
+    # Worth noting that it is possible that the remote has not only
+    # been suspended, but deleted permanently, in which case
+    # @account would now be nil.
+  end
+
   def merge_into_home_timelines!
     @account.followers_for_local_distribution.find_each do |follower|
       FeedManager.instance.merge_into_home(@account, follower)