Remove group following limitations
This commit is contained in:
parent
cbe29bcdee
commit
bef078a87a
13 changed files with 48 additions and 26 deletions
|
@ -20,7 +20,7 @@ class Settings::ProfilesController < Settings::BaseController
|
|||
private
|
||||
|
||||
def account_params
|
||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :group_message_following_only, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
|
||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
|
||||
end
|
||||
|
||||
def set_account
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
# trendable :boolean
|
||||
# reviewed_at :datetime
|
||||
# requested_review_at :datetime
|
||||
# group_message_following_only :boolean
|
||||
# group_allow_private_message :boolean
|
||||
#
|
||||
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
#
|
||||
# Table name: account_stats
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8) not null
|
||||
# statuses_count :bigint(8) default(0), not null
|
||||
# following_count :bigint(8) default(0), not null
|
||||
# followers_count :bigint(8) default(0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# last_status_at :datetime
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8) not null
|
||||
# statuses_count :bigint(8) default(0), not null
|
||||
# following_count :bigint(8) default(0), not null
|
||||
# followers_count :bigint(8) default(0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# last_status_at :datetime
|
||||
# group_activitypub_count :integer
|
||||
#
|
||||
|
||||
class AccountStat < ApplicationRecord
|
||||
|
@ -33,4 +34,8 @@ class AccountStat < ApplicationRecord
|
|||
def statuses_count
|
||||
[attributes['statuses_count'], 0].max
|
||||
end
|
||||
|
||||
def group_activitypub_count
|
||||
[attributes['group_activitypub_count'], 0].max
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ module AccountCounters
|
|||
:following_count=,
|
||||
:followers_count,
|
||||
:followers_count=,
|
||||
:group_activitypub_count,
|
||||
:group_activitypub_count=,
|
||||
:last_status_at,
|
||||
to: :account_stat
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
class GroupReblogService < BaseService
|
||||
include RoutingHelper
|
||||
|
||||
CHECK_POSTS_DOMAIN_SIZE = 30
|
||||
REQUESTED_LOCAL_POSTS = 5
|
||||
ACTIVITYPUB_CONTINUOUS_SIZE = 30
|
||||
|
||||
def call(status)
|
||||
visibility = status.visibility.to_sym
|
||||
|
@ -15,16 +14,20 @@ class GroupReblogService < BaseService
|
|||
|
||||
accounts.each do |account|
|
||||
next unless account.local?
|
||||
next if account.group_message_following_only && !account.following?(status.account)
|
||||
next unless status.account.following?(account)
|
||||
next unless account.group?
|
||||
next if account.id == status.account_id
|
||||
next if transcription && !account.group_allow_private_message
|
||||
|
||||
if status.account.activitypub?
|
||||
domains = account.statuses.order(created_at: 'DESC').where('reblog_of_id > 0').map(&:reblog).map(&:account).map(&:domain).take(CHECK_POSTS_DOMAIN_SIZE).to_a
|
||||
local_count = domains.where { |domain| !domain }.size
|
||||
next if local_count < REQUESTED_LOCAL_POSTS
|
||||
if status.account.activitypub? && ACTIVITYPUB_CONTINUOUS_SIZE > 0
|
||||
next if account.group_activitypub_count >= ACTIVITYPUB_CONTINUOUS_SIZE
|
||||
account.group_activitypub_count = account.group_activitypub_count + 1
|
||||
account.save!
|
||||
else
|
||||
if account.group_activitypub_count > 0
|
||||
account.group_activitypub_count = 0
|
||||
account.save!
|
||||
end
|
||||
end
|
||||
|
||||
ReblogService.new.call(account, status, { visibility: status.visibility }) if !transcription
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
.fields-group
|
||||
= f.input :my_actor_type, collection: ['person', 'bot', 'group'],label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.#{item}"), content_tag(:span, I18n.t("simple_form.hints.defaults.#{item}"), class: 'hint')]) }, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label
|
||||
|
||||
.fields-group
|
||||
= f.input :group_message_following_only, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.group_message_following_only')
|
||||
|
||||
.fields-group
|
||||
= f.input :group_allow_private_message, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.group_allow_private_message')
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ en:
|
|||
fields: You can have up to 4 items displayed as a table on your profile
|
||||
group: Reps sent to this account will be automatically BT'd and distributed to all accounts you follow!
|
||||
group_allow_private_message: Posts are duplicated and cannot be edited or deleted by the post
|
||||
group_message_following_only: Effective as an anti-troll/spam measure, but requires the effort to follow up with subscribers
|
||||
header: PNG, GIF or JPG. At most %{size}. Will be downscaled to %{dimensions}px
|
||||
inbox_url: Copy the URL from the frontpage of the relay you want to use
|
||||
irreversible: Filtered posts will disappear irreversibly, even if filter is later removed
|
||||
|
@ -185,7 +184,6 @@ en:
|
|||
fields: Profile metadata
|
||||
group: This is a group account
|
||||
group_allow_private_message: For group accounts, duplicate private or direct message
|
||||
group_message_following_only: For group accounts, BT only mentions from people you are following
|
||||
header: Header
|
||||
honeypot: "%{label} (do not fill in)"
|
||||
inbox_url: URL of the relay inbox
|
||||
|
|
|
@ -42,7 +42,6 @@ ja:
|
|||
fields: プロフィールに表として4つまでの項目を表示することができます
|
||||
group: このアカウントに送られたメンションは自動でBTされ、フォローしている全てのアカウントに配信されます
|
||||
group_allow_private_message: 投稿は複製されるため、投稿者が編集・削除することはできません
|
||||
group_message_following_only: 荒らし・スパム対策として有効ですが、加入者をフォローする手間が発生します
|
||||
header: "%{size}までのPNG、GIF、JPGが利用可能です。 %{dimensions}pxまで縮小されます"
|
||||
inbox_url: 使用したいリレーサーバーのトップページからURLをコピーします
|
||||
irreversible: フィルターが後で削除されても、除外された投稿は元に戻せなくなります
|
||||
|
@ -185,7 +184,6 @@ ja:
|
|||
fields: プロフィール補足情報
|
||||
group: これはグループアカウントです
|
||||
group_allow_private_message: グループアカウントの場合、フォロワーのみ・ダイレクトのメンションを複製する
|
||||
group_message_following_only: グループアカウントの場合、自分がフォローしている相手からのメンションのみをBTする
|
||||
header: ヘッダー
|
||||
honeypot: "%{label} (入力しない)"
|
||||
inbox_url: リレーサーバーの inbox URL
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupMessageFollowingOnlyToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :group_message_following_only, :boolean
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupAllowPrivateMessageToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :group_allow_private_message, :boolean
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupActivityPubCountToAccountStats < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :account_stats, :group_activitypub_count, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveGroupMessageFollowingOnlyFromAccounts < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured { remove_column :accounts, :group_message_following_only, :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: 2023_03_14_081013) do
|
||||
ActiveRecord::Schema.define(version: 2023_03_14_121142) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -99,6 +99,7 @@ ActiveRecord::Schema.define(version: 2023_03_14_081013) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "last_status_at"
|
||||
t.integer "group_activitypub_count"
|
||||
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
|
||||
end
|
||||
|
||||
|
@ -186,7 +187,6 @@ ActiveRecord::Schema.define(version: 2023_03_14_081013) do
|
|||
t.boolean "trendable"
|
||||
t.datetime "reviewed_at"
|
||||
t.datetime "requested_review_at"
|
||||
t.boolean "group_message_following_only"
|
||||
t.boolean "group_allow_private_message"
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue