Add account suspension

signup-info-prompt
Eugen Rochko 2016-12-05 22:59:30 +01:00
parent 64d109dc0e
commit 39cc9fde8a
7 changed files with 24 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -93,6 +93,8 @@ class ProcessFeedService < BaseService
account = @account
end
return if account.suspended?
status = Status.create!(
uri: id(entry),
url: url(entry),

View File

@ -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)

View File

@ -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

View File

@ -0,0 +1,5 @@
class AddSuspendedToAccounts < ActiveRecord::Migration[5.0]
def change
add_column :accounts, :suspended, :boolean, null: false, default: false
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161203164520) do
ActiveRecord::Schema.define(version: 20161205214545) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -41,6 +41,7 @@ ActiveRecord::Schema.define(version: 20161203164520) do
t.string "avatar_remote_url"
t.datetime "subscription_expires_at"
t.boolean "silenced", default: false, null: false
t.boolean "suspended", default: false, null: false
t.index ["username", "domain"], name: "index_accounts_on_username_and_domain", unique: true, using: :btree
end