rework hide boosts / show only packmates options to work with timeline streaming
parent
32d998b623
commit
82f98a770b
|
@ -23,7 +23,7 @@ class Api::V1::Timelines::HomeController < Api::BaseController
|
|||
end
|
||||
|
||||
def cached_home_statuses
|
||||
if current_account&.user&.hides_boosts?
|
||||
if current_account&.user&.hide_boosts
|
||||
cache_collection home_statuses.without_reblogs, Status
|
||||
else
|
||||
cache_collection home_statuses, Status
|
||||
|
|
|
@ -25,7 +25,7 @@ class Api::V1::Timelines::ListController < Api::BaseController
|
|||
end
|
||||
|
||||
def cached_list_statuses
|
||||
if current_account&.user&.hides_boosts?
|
||||
if current_account&.user&.hide_boosts
|
||||
cache_collection list_statuses.without_reblogs, Status
|
||||
else
|
||||
cache_collection list_statuses, Status
|
||||
|
|
|
@ -27,6 +27,8 @@ class Settings::PreferencesController < Settings::BaseController
|
|||
def user_params
|
||||
params.require(:user).permit(
|
||||
:locale,
|
||||
:hide_boosts,
|
||||
:only_known,
|
||||
chosen_languages: []
|
||||
)
|
||||
end
|
||||
|
@ -51,8 +53,6 @@ class Settings::PreferencesController < Settings::BaseController
|
|||
:setting_hide_mntions_blocked,
|
||||
:setting_hide_mntions_blocker,
|
||||
:setting_hide_mntions_packm8,
|
||||
:setting_hide_boosts,
|
||||
:setting_only_known,
|
||||
:setting_gently_kobolds,
|
||||
:setting_user_is_kobold,
|
||||
:setting_hide_mascot,
|
||||
|
|
|
@ -393,7 +393,7 @@ class Status < ApplicationRecord
|
|||
|
||||
def as_home_timeline(account)
|
||||
query = where(account: [account] + account.following, visibility: [:public, :unlisted, :local, :private])
|
||||
query = query.without_reblogs if account.present? && account&.user&.hides_boosts?
|
||||
query = query.without_reblogs if account.present? && account&.user&.hide_boosts
|
||||
query
|
||||
end
|
||||
|
||||
|
@ -448,8 +448,8 @@ class Status < ApplicationRecord
|
|||
query = query.without_replies unless Setting.show_replies_in_public_timelines
|
||||
|
||||
if account.present? && account.local?
|
||||
query = query.without_reblogs if account&.user&.hides_boosts?
|
||||
query = query.only_followers_of(account) if account&.user&.shows_only_known?
|
||||
query = query.without_reblogs if account&.user&.hide_boosts
|
||||
query = query.only_followers_of(account) if account&.user&.only_known
|
||||
end
|
||||
|
||||
apply_timeline_filters(query, account, local_only)
|
||||
|
@ -457,7 +457,7 @@ class Status < ApplicationRecord
|
|||
|
||||
def as_tag_timeline(tag, account = nil, local_only = false, priv = false)
|
||||
query = tag_timeline_scope(account, local_only, priv).tagged_with(tag)
|
||||
query = query.only_followers_of(account) if account.present? && account.local? && account&.user&.shows_only_known?
|
||||
query = query.only_followers_of(account) if account.present? && account.local? && account&.user&.only_known?
|
||||
apply_timeline_filters(query, account, local_only, true)
|
||||
end
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
# created_by_application_id :bigint(8)
|
||||
# approved :boolean default(TRUE), not null
|
||||
# vars :jsonb not null
|
||||
# hide_boosts :boolean
|
||||
# only_known :boolean
|
||||
#
|
||||
|
||||
class User < ApplicationRecord
|
||||
|
@ -132,8 +134,6 @@ class User < ApplicationRecord
|
|||
:hide_mntions_blocker,
|
||||
:hide_mntions_packm8,
|
||||
:hide_mascot,
|
||||
:hide_boosts,
|
||||
:only_known,
|
||||
:hide_interactions,
|
||||
:hide_public_profile,
|
||||
:hide_public_outbox,
|
||||
|
@ -307,14 +307,6 @@ class User < ApplicationRecord
|
|||
@hides_mascot ||= (settings.hide_mascot || false)
|
||||
end
|
||||
|
||||
def hides_boosts?
|
||||
@hides_boosts ||= (settings.hide_boosts || false)
|
||||
end
|
||||
|
||||
def shows_only_known?
|
||||
@only_known ||= (settings.only_known || false)
|
||||
end
|
||||
|
||||
def hides_interactions?
|
||||
@hides_interactions ||= (settings.hide_interactions || false)
|
||||
end
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
|
||||
.fields-group
|
||||
= f.input :setting_rawr_federated, as: :boolean, wrapper: :with_label
|
||||
= f.input :setting_hide_boosts, as: :boolean, wrapper: :with_label
|
||||
= f.input :setting_only_known, as: :boolean, wrapper: :with_label
|
||||
= f.input :hide_boosts, as: :boolean, wrapper: :with_label
|
||||
= f.input :only_known, as: :boolean, wrapper: :with_label
|
||||
|
||||
%hr/
|
||||
|
||||
|
|
|
@ -155,8 +155,6 @@ en:
|
|||
setting_hide_mntions_packm8: Filter group chat branches addressed to participants you aren't a packmate of
|
||||
setting_hide_mascot: Don't show the mascot image
|
||||
setting_hide_interactions: Make your roar interaction lists private
|
||||
setting_hide_boosts: Don't show boosts on any timeline
|
||||
setting_only_known: Only show posts from packmates on all timelines
|
||||
setting_aggregate_reblogs: Group repeats in timelines
|
||||
setting_auto_play_gif: Auto-play animated GIFs
|
||||
setting_boost_modal: Show confirmation dialog before repeating
|
||||
|
@ -182,6 +180,8 @@ en:
|
|||
setting_system_font_ui: Use system's default font
|
||||
setting_theme: Site theme
|
||||
setting_unfollow_modal: Show confirmation dialog before unfollowing someone
|
||||
hide_boosts: Don't show boosts on any timeline
|
||||
only_known: Only show posts from packmates on all timelines
|
||||
severity: Severity
|
||||
type: Import type
|
||||
username: Username
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddHideBoostsToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :hide_boosts, :boolean
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddOnlyKnownToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :only_known, :boolean
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_12_12_043419) do
|
||||
ActiveRecord::Schema.define(version: 2019_12_20_020441) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_trgm"
|
||||
|
@ -807,6 +807,8 @@ ActiveRecord::Schema.define(version: 2019_12_12_043419) do
|
|||
t.bigint "created_by_application_id"
|
||||
t.boolean "approved", default: true, null: false
|
||||
t.jsonb "vars", default: {}, null: false
|
||||
t.boolean "hide_boosts"
|
||||
t.boolean "only_known"
|
||||
t.index ["account_id"], name: "index_users_on_account_id"
|
||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
|
||||
|
|
|
@ -202,7 +202,7 @@ const startWorker = (workerId) => {
|
|||
return;
|
||||
}
|
||||
|
||||
client.query('SELECT oauth_access_tokens.resource_owner_id, users.account_id, users.chosen_languages, oauth_access_tokens.scopes FROM oauth_access_tokens INNER JOIN users ON oauth_access_tokens.resource_owner_id = users.id WHERE oauth_access_tokens.token = $1 AND oauth_access_tokens.revoked_at IS NULL LIMIT 1', [token], (err, result) => {
|
||||
client.query('SELECT oauth_access_tokens.resource_owner_id, users.account_id, users.chosen_languages, users.hide_boosts, users.only_known, oauth_access_tokens.scopes FROM oauth_access_tokens INNER JOIN users ON oauth_access_tokens.resource_owner_id = users.id WHERE oauth_access_tokens.token = $1 AND oauth_access_tokens.revoked_at IS NULL LIMIT 1', [token], (err, result) => {
|
||||
done();
|
||||
|
||||
if (err) {
|
||||
|
@ -230,6 +230,8 @@ const startWorker = (workerId) => {
|
|||
|
||||
req.accountId = result.rows[0].account_id;
|
||||
req.chosenLanguages = result.rows[0].chosen_languages;
|
||||
req.hideBoosts = result.rows[0].hide_boosts;
|
||||
req.onlyKnown = result.rows[0].only_known;
|
||||
req.allowNotifications = scopes.some(scope => ['read', 'read:notifications'].includes(scope));
|
||||
|
||||
next();
|
||||
|
@ -393,6 +395,10 @@ const startWorker = (workerId) => {
|
|||
const targetAccountIds = [unpackedPayload.account.id].concat(unpackedPayload.mentions.map(item => item.id));
|
||||
const accountDomain = unpackedPayload.account.acct.split('@')[1];
|
||||
|
||||
if (req.hideBoosts && (unpackedPayload.in_reply_to !== undefined || unpackedPayload.in_reply_to !== null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(req.chosenLanguages) && unpackedPayload.language !== null && req.chosenLanguages.indexOf(unpackedPayload.language) === -1) {
|
||||
log.silly(req.requestId, `Message ${unpackedPayload.id} filtered by language (${unpackedPayload.language})`);
|
||||
return;
|
||||
|
@ -424,6 +430,10 @@ const startWorker = (workerId) => {
|
|||
queries.push(client.query('SELECT 1 FROM account_domain_blocks WHERE account_id = $1 AND domain = $2', [req.accountId, accountDomain]));
|
||||
}
|
||||
|
||||
if (req.onlyKnown) {
|
||||
queries.push(client.query('SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM follows WHERE account_id = $1 AND target_account_id = $2)', [req.accountId, unpackedPayload.account.id]));
|
||||
}
|
||||
|
||||
Promise.all(queries).then(values => {
|
||||
done();
|
||||
|
||||
|
|
Loading…
Reference in New Issue