hidden accounts + stats hiding
parent
90d2280dfe
commit
6614d42c6e
|
@ -11,6 +11,7 @@ module AccountControllerConcern
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
before_action :check_account_approval
|
before_action :check_account_approval
|
||||||
before_action :check_account_suspension
|
before_action :check_account_suspension
|
||||||
|
before_action :check_account_hidden
|
||||||
before_action :set_instance_presenter
|
before_action :set_instance_presenter
|
||||||
before_action :set_link_headers
|
before_action :set_link_headers
|
||||||
end
|
end
|
||||||
|
@ -75,4 +76,8 @@ module AccountControllerConcern
|
||||||
gone
|
gone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_account_hidden
|
||||||
|
not_found if @account.hidden?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Settings::PreferencesController < Settings::BaseController
|
||||||
:setting_default_local,
|
:setting_default_local,
|
||||||
:setting_always_local,
|
:setting_always_local,
|
||||||
:setting_rawr_federated,
|
:setting_rawr_federated,
|
||||||
|
:setting_hide_stats,
|
||||||
:setting_default_sensitive,
|
:setting_default_sensitive,
|
||||||
:setting_default_language,
|
:setting_default_language,
|
||||||
:setting_unfollow_modal,
|
:setting_unfollow_modal,
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Settings::ProfilesController < Settings::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def account_params
|
def account_params
|
||||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :bot, :discoverable, fields_attributes: [:name, :value])
|
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :hidden, :bot, :discoverable, fields_attributes: [:name, :value])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
|
|
|
@ -64,7 +64,15 @@ module StreamEntriesHelper
|
||||||
Setting.hide_followers_count || account.user&.setting_hide_followers_count
|
Setting.hide_followers_count || account.user&.setting_hide_followers_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hide_stats?(account)
|
||||||
|
Setting.hide_stats || account.user&.setting_hide_stats
|
||||||
|
end
|
||||||
|
|
||||||
def account_description(account)
|
def account_description(account)
|
||||||
|
|
||||||
|
if hide_stats?(account)
|
||||||
|
prepend_stats = []
|
||||||
|
else
|
||||||
prepend_stats = [
|
prepend_stats = [
|
||||||
[
|
[
|
||||||
number_to_human(account.statuses_count, strip_insignificant_zeros: true),
|
number_to_human(account.statuses_count, strip_insignificant_zeros: true),
|
||||||
|
@ -83,6 +91,7 @@ module StreamEntriesHelper
|
||||||
I18n.t('accounts.followers', count: account.followers_count),
|
I18n.t('accounts.followers', count: account.followers_count),
|
||||||
].join(' ')
|
].join(' ')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
[prepend_stats.join(', '), account.note].join(' · ')
|
[prepend_stats.join(', '), account.note].join(' · ')
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,6 +21,7 @@ class UserSettingsDecorator
|
||||||
user.settings['default_local'] = default_local_preference if change?('setting_default_local')
|
user.settings['default_local'] = default_local_preference if change?('setting_default_local')
|
||||||
user.settings['always_local'] = always_local_preference if change?('setting_always_local')
|
user.settings['always_local'] = always_local_preference if change?('setting_always_local')
|
||||||
user.settings['rawr_federated'] = rawr_federated_preference if change?('setting_rawr_federated')
|
user.settings['rawr_federated'] = rawr_federated_preference if change?('setting_rawr_federated')
|
||||||
|
user.settings['hide_stats'] = hide_stats_preference if change?('setting_hide_stats')
|
||||||
user.settings['default_sensitive'] = default_sensitive_preference if change?('setting_default_sensitive')
|
user.settings['default_sensitive'] = default_sensitive_preference if change?('setting_default_sensitive')
|
||||||
user.settings['default_language'] = default_language_preference if change?('setting_default_language')
|
user.settings['default_language'] = default_language_preference if change?('setting_default_language')
|
||||||
user.settings['unfollow_modal'] = unfollow_modal_preference if change?('setting_unfollow_modal')
|
user.settings['unfollow_modal'] = unfollow_modal_preference if change?('setting_unfollow_modal')
|
||||||
|
@ -66,6 +67,10 @@ class UserSettingsDecorator
|
||||||
boolean_cast_setting 'setting_rawr_federated'
|
boolean_cast_setting 'setting_rawr_federated'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hide_stats_preference
|
||||||
|
boolean_cast_setting 'setting_hide_stats'
|
||||||
|
end
|
||||||
|
|
||||||
def default_sensitive_preference
|
def default_sensitive_preference
|
||||||
boolean_cast_setting 'setting_default_sensitive'
|
boolean_cast_setting 'setting_default_sensitive'
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
# also_known_as :string is an Array
|
# also_known_as :string is an Array
|
||||||
# silenced_at :datetime
|
# silenced_at :datetime
|
||||||
# suspended_at :datetime
|
# suspended_at :datetime
|
||||||
|
# hidden :boolean
|
||||||
#
|
#
|
||||||
|
|
||||||
class Account < ApplicationRecord
|
class Account < ApplicationRecord
|
||||||
|
|
|
@ -103,7 +103,7 @@ class User < ApplicationRecord
|
||||||
has_many :session_activations, dependent: :destroy
|
has_many :session_activations, dependent: :destroy
|
||||||
|
|
||||||
delegate :auto_play_gif, :default_local, :always_local, :rawr_federated, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
|
delegate :auto_play_gif, :default_local, :always_local, :rawr_federated, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
|
||||||
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
|
:hide_stats, :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
|
||||||
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :default_content_type, to: :settings, prefix: :setting, allow_nil: false
|
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :default_content_type, to: :settings, prefix: :setting, allow_nil: false
|
||||||
|
|
||||||
attr_reader :invite_code
|
attr_reader :invite_code
|
||||||
|
@ -200,6 +200,10 @@ class User < ApplicationRecord
|
||||||
settings.rawr_federated || false
|
settings.rawr_federated || false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setting_hide_stats
|
||||||
|
settings.hide_stats || false
|
||||||
|
end
|
||||||
|
|
||||||
def allows_digest_emails?
|
def allows_digest_emails?
|
||||||
settings.notification_emails['digest']
|
settings.notification_emails['digest']
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,17 +15,17 @@
|
||||||
.details-counters
|
.details-counters
|
||||||
.counter{ class: active_nav_class(short_account_url(account), short_account_with_replies_url(account), short_account_media_url(account)) }
|
.counter{ class: active_nav_class(short_account_url(account), short_account_with_replies_url(account), short_account_media_url(account)) }
|
||||||
= link_to short_account_url(account), class: 'u-url u-uid', title: number_with_delimiter(account.statuses_count) do
|
= link_to short_account_url(account), class: 'u-url u-uid', title: number_with_delimiter(account.statuses_count) do
|
||||||
%span.counter-number= number_to_human account.statuses_count, strip_insignificant_zeros: true
|
%span.counter-number= (number_to_human account.statuses_count, strip_insignificant_zeros: true) unless hide_stats?(account)
|
||||||
%span.counter-label= t('accounts.posts', count: account.statuses_count)
|
%span.counter-label= t('accounts.posts', count: account.statuses_count)
|
||||||
|
|
||||||
.counter{ class: active_nav_class(account_following_index_url(account)) }
|
.counter{ class: active_nav_class(account_following_index_url(account)) }
|
||||||
= link_to account_following_index_url(account), title: number_with_delimiter(account.following_count) do
|
= link_to account_following_index_url(account), title: hide_followers_count?(account) ? nil : number_with_delimiter(account.following_count) do
|
||||||
%span.counter-number= number_to_human account.following_count, strip_insignificant_zeros: true
|
%span.counter-number= (number_to_human account.following_count, strip_insignificant_zeros: true) unless hide_stats?(account)
|
||||||
%span.counter-label= t('accounts.following', count: account.following_count)
|
%span.counter-label= t('accounts.following', count: account.following_count)
|
||||||
|
|
||||||
.counter{ class: active_nav_class(account_followers_url(account)) }
|
.counter{ class: active_nav_class(account_followers_url(account)) }
|
||||||
= link_to account_followers_url(account), title: hide_followers_count?(account) ? nil : number_with_delimiter(account.followers_count) do
|
= link_to account_followers_url(account), title: hide_followers_count?(account) ? nil : number_with_delimiter(account.followers_count) do
|
||||||
%span.counter-number= hide_followers_count?(account) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true)
|
%span.counter-number= (number_to_human account.followers_count, strip_insignificant_zeros: true) unless hide_stats?(account) || hide_followers_count?(account)
|
||||||
%span.counter-label= t('accounts.followers', count: account.followers_count)
|
%span.counter-label= t('accounts.followers', count: account.followers_count)
|
||||||
.spacer
|
.spacer
|
||||||
.public-account-header__tabs__tabs__buttons
|
.public-account-header__tabs__tabs__buttons
|
||||||
|
@ -36,8 +36,8 @@
|
||||||
|
|
||||||
.public-account-header__extra__links
|
.public-account-header__extra__links
|
||||||
= link_to account_following_index_url(account) do
|
= link_to account_following_index_url(account) do
|
||||||
%strong= number_to_human account.following_count, strip_insignificant_zeros: true
|
%strong= (number_to_human account.following_count, strip_insignificant_zeros: true) unless hide_stats?(account)
|
||||||
= t('accounts.following', count: account.following_count)
|
= t('accounts.following', count: account.following_count)
|
||||||
= link_to account_followers_url(account) do
|
= link_to account_followers_url(account) do
|
||||||
%strong= hide_followers_count?(account) ? '-' : (number_to_human account.followers_count, strip_insignificant_zeros: true)
|
%strong= (number_to_human account.followers_count, strip_insignificant_zeros: true) unless hide_stats?(account) || hide_followers_count?(account)
|
||||||
= t('accounts.followers', count: account.followers_count)
|
= t('accounts.followers', count: account.followers_count)
|
||||||
|
|
|
@ -67,5 +67,9 @@
|
||||||
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
|
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
|
||||||
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
|
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :setting_hide_stats, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
= f.button :button, t('generic.save_changes'), type: :submit
|
= f.button :button, t('generic.save_changes'), type: :submit
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :locked, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.locked')
|
= f.input :locked, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.locked')
|
||||||
|
= f.input :hidden, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.hidden')
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot')
|
= f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot')
|
||||||
|
|
|
@ -23,6 +23,7 @@ en:
|
||||||
irreversible: Filtered roars will disappear irreversibly, even if filter is later removed
|
irreversible: Filtered roars will disappear irreversibly, even if filter is later removed
|
||||||
locale: The language of the creature interface, e-mails and push notifications
|
locale: The language of the creature interface, e-mails and push notifications
|
||||||
locked: Requires you to manually approve packmates
|
locked: Requires you to manually approve packmates
|
||||||
|
hidden: Toggles whether your public profile is browsable
|
||||||
password: Use at least 8 characters
|
password: Use at least 8 characters
|
||||||
phrase: Will be matched regardless of casing in text or content warning of a roar
|
phrase: Will be matched regardless of casing in text or content warning of a roar
|
||||||
scopes: Which APIs the application will be allowed to access. If you select a top-level scope, you don't need to select individual ones.
|
scopes: Which APIs the application will be allowed to access. If you select a top-level scope, you don't need to select individual ones.
|
||||||
|
@ -87,6 +88,7 @@ en:
|
||||||
irreversible: Drop instead of hide
|
irreversible: Drop instead of hide
|
||||||
locale: Interface language
|
locale: Interface language
|
||||||
locked: Lock account
|
locked: Lock account
|
||||||
|
hidden: Hide public profile
|
||||||
max_uses: Max number of uses
|
max_uses: Max number of uses
|
||||||
new_password: New password
|
new_password: New password
|
||||||
note: Bio
|
note: Bio
|
||||||
|
@ -105,6 +107,7 @@ en:
|
||||||
setting_default_local: Default to Monsterpit-only roars (in Glitch flavour)
|
setting_default_local: Default to Monsterpit-only roars (in Glitch flavour)
|
||||||
setting_always_local: Don't send your roars outside Monsterpit
|
setting_always_local: Don't send your roars outside Monsterpit
|
||||||
setting_rawr_federated: Show raw world timeline (may contain offensive content!)
|
setting_rawr_federated: Show raw world timeline (may contain offensive content!)
|
||||||
|
setting_hide_stats: Hide statistics
|
||||||
setting_default_sensitive: Always mark media as sensitive
|
setting_default_sensitive: Always mark media as sensitive
|
||||||
setting_delete_modal: Show confirmation dialog before deleting a roar
|
setting_delete_modal: Show confirmation dialog before deleting a roar
|
||||||
setting_display_media: Media display
|
setting_display_media: Media display
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddHiddenToAccounts < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :accounts, :hidden, :boolean
|
||||||
|
end
|
||||||
|
end
|
|
@ -148,6 +148,7 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
|
||||||
t.string "also_known_as", array: true
|
t.string "also_known_as", array: true
|
||||||
t.datetime "silenced_at"
|
t.datetime "silenced_at"
|
||||||
t.datetime "suspended_at"
|
t.datetime "suspended_at"
|
||||||
|
t.boolean "hidden"
|
||||||
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
|
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
|
||||||
t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
|
t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
|
||||||
t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
|
t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
|
||||||
|
|
Loading…
Reference in New Issue