Add fedibird hide followers count support
This commit is contained in:
parent
56245f4ef8
commit
9818f6a0e1
10 changed files with 31 additions and 6 deletions
|
@ -24,6 +24,7 @@ module ContextHelper
|
|||
emoji_reactions: { 'fedibird' => 'http://fedibird.com/ns#', 'emojiReactions' => { '@id' => 'fedibird:emojiReactions', '@type' => '@id' } },
|
||||
searchable_by: { 'fedibird' => 'http://fedibird.com/ns#', 'searchableBy' => { '@id' => 'fedibird:searchableBy', '@type' => '@id' } },
|
||||
subscribable_by: { 'kmyblue' => 'http://kmy.blue/ns#', 'subscribableBy' => { '@id' => 'kmyblue:subscribableBy', '@type' => '@id' } },
|
||||
other_setting: { 'fedibird' => 'http://fedibird.com/ns#', 'otherSetting' => 'fedibird:otherSetting' },
|
||||
olm: { 'toot' => 'http://joinmastodon.org/ns#', 'Device' => 'toot:Device', 'Ed25519Signature' => 'toot:Ed25519Signature', 'Ed25519Key' => 'toot:Ed25519Key', 'Curve25519Key' => 'toot:Curve25519Key', 'EncryptedMessage' => 'toot:EncryptedMessage', 'publicKeyBase64' => 'toot:publicKeyBase64', 'deviceId' => 'toot:deviceId', 'claim' => { '@type' => '@id', '@id' => 'toot:claim' }, 'fingerprintKey' => { '@type' => '@id', '@id' => 'toot:fingerprintKey' }, 'identityKey' => { '@type' => '@id', '@id' => 'toot:identityKey' }, 'devices' => { '@type' => '@id', '@id' => 'toot:devices' }, 'messageFranking' => 'toot:messageFranking', 'messageType' => 'toot:messageType', 'cipherText' => 'toot:cipherText' },
|
||||
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
||||
}.freeze
|
||||
|
|
|
@ -152,7 +152,7 @@ class Account extends ImmutablePureComponent {
|
|||
|
||||
<div>
|
||||
<DisplayName account={account} />
|
||||
{!minimal && <><ShortNumber value={account.get('followers_count')} renderer={counterRenderer('followers')} /> {verification} {muteTimeRemaining}</>}
|
||||
{!minimal && <><ShortNumber value={account.get('followers_count')} isHide={account.getIn(['other_settings', 'hide_followers_count']) || false} renderer={counterRenderer('followers')} /> {verification} {muteTimeRemaining}</>}
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import { FormattedMessage, FormattedNumber } from 'react-intl';
|
|||
* @param {ShortNumberProps} param0 Props for the component
|
||||
* @returns {JSX.Element} Rendered number
|
||||
*/
|
||||
function ShortNumber({ value, renderer, children }) {
|
||||
function ShortNumber({ value, isHide, renderer, children }) {
|
||||
const shortNumber = toShortNumber(value);
|
||||
const [, division] = shortNumber;
|
||||
|
||||
|
@ -37,7 +37,7 @@ function ShortNumber({ value, renderer, children }) {
|
|||
|
||||
const customRenderer = children != null ? children : renderer;
|
||||
|
||||
const displayNumber = <ShortNumberCounter value={shortNumber} />;
|
||||
const displayNumber = !isHide ? <ShortNumberCounter value={shortNumber} /> : <span>-</span>;
|
||||
|
||||
return customRenderer != null
|
||||
? customRenderer(displayNumber, pluralReady(value, division))
|
||||
|
@ -46,6 +46,7 @@ function ShortNumber({ value, renderer, children }) {
|
|||
|
||||
ShortNumber.propTypes = {
|
||||
value: PropTypes.number.isRequired,
|
||||
isHide: PropTypes.bool,
|
||||
renderer: PropTypes.func,
|
||||
children: PropTypes.func,
|
||||
};
|
||||
|
|
|
@ -451,6 +451,7 @@ class Header extends ImmutablePureComponent {
|
|||
<NavLink isActive={this.isStatusesPageActive} activeClassName='active' to={`/@${account.get('acct')}`} title={intl.formatNumber(account.get('statuses_count'))}>
|
||||
<ShortNumber
|
||||
value={account.get('statuses_count')}
|
||||
isHide={account.getIn(['other_settings', 'hide_statuses_count']) || false}
|
||||
renderer={counterRenderer('statuses')}
|
||||
/>
|
||||
</NavLink>
|
||||
|
@ -458,6 +459,7 @@ class Header extends ImmutablePureComponent {
|
|||
<NavLink exact activeClassName='active' to={`/@${account.get('acct')}/following`} title={intl.formatNumber(account.get('following_count'))}>
|
||||
<ShortNumber
|
||||
value={account.get('following_count')}
|
||||
isHide={account.getIn(['other_settings', 'hide_following_count']) || false}
|
||||
renderer={counterRenderer('following')}
|
||||
/>
|
||||
</NavLink>
|
||||
|
@ -465,6 +467,7 @@ class Header extends ImmutablePureComponent {
|
|||
<NavLink exact activeClassName='active' to={`/@${account.get('acct')}/followers`} title={intl.formatNumber(account.get('followers_count'))}>
|
||||
<ShortNumber
|
||||
value={account.get('followers_count')}
|
||||
isHide={account.getIn(['other_settings', 'hide_followers_count']) || false}
|
||||
renderer={counterRenderer('followers')}
|
||||
/>
|
||||
</NavLink>
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
# group_allow_private_message :boolean
|
||||
# searchability :integer default("private"), not null
|
||||
# dissubscribable :boolean default(FALSE), not null
|
||||
# settings :jsonb
|
||||
#
|
||||
|
||||
class Account < ApplicationRecord
|
||||
|
|
|
@ -13,7 +13,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
:inbox, :outbox, :featured, :featured_tags,
|
||||
:preferred_username, :name, :summary,
|
||||
:url, :manually_approves_followers,
|
||||
:discoverable, :published, :searchable_by, :subscribable_by
|
||||
:discoverable, :published, :searchable_by, :subscribable_by, :obher_setting
|
||||
|
||||
has_one :public_key, serializer: ActivityPub::PublicKeySerializer
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
|||
|
||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :group, :created_at,
|
||||
:note, :url, :avatar, :avatar_static, :header, :header_static, :searchability, :subscribable,
|
||||
:followers_count, :following_count, :statuses_count, :last_status_at
|
||||
:followers_count, :following_count, :statuses_count, :last_status_at, :other_settings
|
||||
|
||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||
|
||||
|
@ -123,6 +123,10 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
|||
object.suspended? ? [] : object.fields
|
||||
end
|
||||
|
||||
def other_settings
|
||||
object.suspended? || object.settings.nil? ? {} : object.settings
|
||||
end
|
||||
|
||||
def suspended
|
||||
object.suspended?
|
||||
end
|
||||
|
|
|
@ -117,6 +117,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
@account.discoverable = @json['discoverable'] || false
|
||||
@account.searchability = searchability_from_audience
|
||||
@account.dissubscribable = !subscribable(@account.note)
|
||||
@account.settings = other_settings
|
||||
end
|
||||
|
||||
def set_fetchable_key!
|
||||
|
@ -265,6 +266,12 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
def other_settings
|
||||
return {} unless @json['otherSetting'].is_a?(Array)
|
||||
|
||||
@json['otherSetting'].each_with_object({}) { |v, h| h.merge!({ v['name'] => v['value'] }) if v['type'] == 'PropertyValue' }
|
||||
end
|
||||
|
||||
def property_values
|
||||
return unless @json['attachment'].is_a?(Array)
|
||||
|
||||
|
|
7
db/migrate/20230514030455_add_settings_to_accounts.rb
Normal file
7
db/migrate/20230514030455_add_settings_to_accounts.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSettingsToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :settings, :jsonb
|
||||
end
|
||||
end
|
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2023_05_12_122757) do
|
||||
ActiveRecord::Schema.define(version: 2023_05_14_030455) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -194,6 +194,7 @@ ActiveRecord::Schema.define(version: 2023_05_12_122757) do
|
|||
t.boolean "group_allow_private_message"
|
||||
t.integer "searchability", default: 2, null: false
|
||||
t.boolean "dissubscribable", default: false, null: false
|
||||
t.jsonb "settings"
|
||||
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), COALESCE(lower((domain)::text), ''::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", where: "(moved_to_account_id IS NOT NULL)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue