Adding public timeline silencing
This commit is contained in:
parent
e5565a7e4a
commit
909d0d5e88
|
@ -86,7 +86,12 @@ class Status < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.as_public_timeline(account)
|
||||
joins('LEFT OUTER JOIN statuses AS reblogs ON statuses.reblog_of_id = reblogs.id').where('(reblogs.account_id IS NULL OR reblogs.account_id NOT IN (SELECT target_account_id FROM blocks WHERE account_id = ?)) AND statuses.account_id NOT IN (SELECT target_account_id FROM blocks WHERE account_id = ?)', account.id, account.id).with_includes.with_counters
|
||||
joins('LEFT OUTER JOIN statuses AS reblogs ON statuses.reblog_of_id = reblogs.id')
|
||||
.joins('LEFT OUTER JOIN accounts ON statuses.account_id = accounts.id')
|
||||
.where('accounts.silenced = FALSE')
|
||||
.where('(reblogs.account_id IS NULL OR reblogs.account_id NOT IN (SELECT target_account_id FROM blocks WHERE account_id = ?)) AND statuses.account_id NOT IN (SELECT target_account_id FROM blocks WHERE account_id = ?)', account.id, account.id)
|
||||
.with_includes
|
||||
.with_counters
|
||||
end
|
||||
|
||||
def self.favourites_map(status_ids, account_id)
|
||||
|
|
|
@ -30,6 +30,7 @@ class FanOutOnWriteService < BaseService
|
|||
end
|
||||
|
||||
def deliver_to_public(status)
|
||||
return if status.account.silenced?
|
||||
FeedManager.instance.broadcast(:public, id: status.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddSilencedToAccounts < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :accounts, :silenced, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20161009120834) do
|
||||
ActiveRecord::Schema.define(version: 20161027172456) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -40,6 +40,7 @@ ActiveRecord::Schema.define(version: 20161009120834) do
|
|||
t.datetime "header_updated_at"
|
||||
t.string "avatar_remote_url"
|
||||
t.datetime "subscription_expires_at"
|
||||
t.boolean "silenced", default: false, null: false
|
||||
t.index ["username", "domain"], name: "index_accounts_on_username_and_domain", unique: true, using: :btree
|
||||
end
|
||||
|
||||
|
|
Reference in New Issue