about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/accounts_controller.rb2
-rw-r--r--app/models/status.rb19
-rw-r--r--app/services/process_feed_service.rb2
-rw-r--r--app/services/process_interaction_service.rb2
-rw-r--r--app/views/admin/accounts/show.html.haml1
5 files changed, 17 insertions, 9 deletions
diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb
index 79fb37eb9..ff1989b52 100644
--- a/app/controllers/admin/accounts_controller.rb
+++ b/app/controllers/admin/accounts_controller.rb
@@ -33,6 +33,6 @@ class Admin::AccountsController < ApplicationController
   end
 
   def account_params
-    params.require(:account).permit(:silenced)
+    params.require(:account).permit(:silenced, :suspended)
   end
 end
diff --git a/app/models/status.rb b/app/models/status.rb
index 1f5cf9b46..9d1dae963 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -104,22 +104,20 @@ class Status < ApplicationRecord
     def as_public_timeline(account = nil)
       query = joins('LEFT OUTER JOIN accounts ON statuses.account_id = accounts.id')
               .where(visibility: :public)
-              .where('accounts.silenced = FALSE')
               .where('(statuses.in_reply_to_id IS NULL OR statuses.in_reply_to_account_id = statuses.account_id)')
               .where('statuses.reblog_of_id IS NULL')
-      query = filter_timeline(query, account) unless account.nil?
-      query
+
+      account.nil? ? filter_timeline_default(query) : filter_timeline(query, account)
     end
 
     def as_tag_timeline(tag, account = nil)
       query = tag.statuses
                  .joins('LEFT OUTER JOIN accounts ON statuses.account_id = accounts.id')
                  .where(visibility: :public)
-                 .where('accounts.silenced = FALSE')
                  .where('(statuses.in_reply_to_id IS NULL OR statuses.in_reply_to_account_id = statuses.account_id)')
                  .where('statuses.reblog_of_id IS NULL')
-      query = filter_timeline(query, account) unless account.nil?
-      query
+
+      account.nil? ? filter_timeline_default(query) : filter_timeline(query, account)
     end
 
     def favourites_map(status_ids, account_id)
@@ -150,8 +148,13 @@ class Status < ApplicationRecord
 
     def filter_timeline(query, account)
       blocked = Block.where(account: account).pluck(:target_account_id)
-      return query if blocked.empty?
-      query.where('statuses.account_id NOT IN (?)', blocked)
+      query   = query.where('statuses.account_id NOT IN (?)', blocked) unless blocked.empty?
+      query   = query.where('accounts.silenced = TRUE') if account.silenced?
+      query
+    end
+
+    def filter_timeline_default(query)
+      query.where('accounts.silenced = FALSE')
     end
   end
 
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index 3aa0ceff8..1a831fa73 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -93,6 +93,8 @@ class ProcessFeedService < BaseService
         account = @account
       end
 
+      return if account.suspended?
+
       status = Status.create!(
         uri: id(entry),
         url: url(entry),
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
index 129b2a2be..4e5487681 100644
--- a/app/services/process_interaction_service.rb
+++ b/app/services/process_interaction_service.rb
@@ -23,6 +23,8 @@ class ProcessInteractionService < BaseService
       account = follow_remote_account_service.call("#{username}@#{domain}")
     end
 
+    return if account.suspended?
+
     if salmon.verify(envelope, account.keypair)
       update_remote_profile_service.call(xml.at_xpath('/xmlns:entry', xmlns: TagManager::XMLNS), account, true)
 
diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml
index 02f7dcfe9..47f1e2308 100644
--- a/app/views/admin/accounts/show.html.haml
+++ b/app/views/admin/accounts/show.html.haml
@@ -29,6 +29,7 @@
   = render 'shared/error_messages', object: @account
 
   = f.input :silenced, as: :boolean, wrapper: :with_label
+  = f.input :suspended, as: :boolean, wrapper: :with_label
 
   .actions
     = f.button :button, t('generic.save_changes'), type: :submit