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)
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
= 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
#
# 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"
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