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
|
private
|
||||||
|
|
||||||
def account_params
|
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
|
end
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
# trendable :boolean
|
# trendable :boolean
|
||||||
# reviewed_at :datetime
|
# reviewed_at :datetime
|
||||||
# requested_review_at :datetime
|
# requested_review_at :datetime
|
||||||
# group_message_following_only :boolean
|
|
||||||
# group_allow_private_message :boolean
|
# group_allow_private_message :boolean
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# last_status_at :datetime
|
# last_status_at :datetime
|
||||||
|
# group_activitypub_count :integer
|
||||||
#
|
#
|
||||||
|
|
||||||
class AccountStat < ApplicationRecord
|
class AccountStat < ApplicationRecord
|
||||||
|
@ -33,4 +34,8 @@ class AccountStat < ApplicationRecord
|
||||||
def statuses_count
|
def statuses_count
|
||||||
[attributes['statuses_count'], 0].max
|
[attributes['statuses_count'], 0].max
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def group_activitypub_count
|
||||||
|
[attributes['group_activitypub_count'], 0].max
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,8 @@ module AccountCounters
|
||||||
:following_count=,
|
:following_count=,
|
||||||
:followers_count,
|
:followers_count,
|
||||||
:followers_count=,
|
:followers_count=,
|
||||||
|
:group_activitypub_count,
|
||||||
|
:group_activitypub_count=,
|
||||||
:last_status_at,
|
:last_status_at,
|
||||||
to: :account_stat
|
to: :account_stat
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
class GroupReblogService < BaseService
|
class GroupReblogService < BaseService
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
CHECK_POSTS_DOMAIN_SIZE = 30
|
ACTIVITYPUB_CONTINUOUS_SIZE = 30
|
||||||
REQUESTED_LOCAL_POSTS = 5
|
|
||||||
|
|
||||||
def call(status)
|
def call(status)
|
||||||
visibility = status.visibility.to_sym
|
visibility = status.visibility.to_sym
|
||||||
|
@ -15,16 +14,20 @@ class GroupReblogService < BaseService
|
||||||
|
|
||||||
accounts.each do |account|
|
accounts.each do |account|
|
||||||
next unless account.local?
|
next unless account.local?
|
||||||
next if account.group_message_following_only && !account.following?(status.account)
|
|
||||||
next unless status.account.following?(account)
|
next unless status.account.following?(account)
|
||||||
next unless account.group?
|
next unless account.group?
|
||||||
next if account.id == status.account_id
|
next if account.id == status.account_id
|
||||||
next if transcription && !account.group_allow_private_message
|
next if transcription && !account.group_allow_private_message
|
||||||
|
|
||||||
if status.account.activitypub?
|
if status.account.activitypub? && ACTIVITYPUB_CONTINUOUS_SIZE > 0
|
||||||
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
|
next if account.group_activitypub_count >= ACTIVITYPUB_CONTINUOUS_SIZE
|
||||||
local_count = domains.where { |domain| !domain }.size
|
account.group_activitypub_count = account.group_activitypub_count + 1
|
||||||
next if local_count < REQUESTED_LOCAL_POSTS
|
account.save!
|
||||||
|
else
|
||||||
|
if account.group_activitypub_count > 0
|
||||||
|
account.group_activitypub_count = 0
|
||||||
|
account.save!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ReblogService.new.call(account, status, { visibility: status.visibility }) if !transcription
|
ReblogService.new.call(account, status, { visibility: status.visibility }) if !transcription
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
.fields-group
|
.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
|
= 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
|
.fields-group
|
||||||
= f.input :group_allow_private_message, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.group_allow_private_message')
|
= 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
|
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: 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_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
|
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
|
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
|
irreversible: Filtered posts will disappear irreversibly, even if filter is later removed
|
||||||
|
@ -185,7 +184,6 @@ en:
|
||||||
fields: Profile metadata
|
fields: Profile metadata
|
||||||
group: This is a group account
|
group: This is a group account
|
||||||
group_allow_private_message: For group accounts, duplicate private or direct message
|
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
|
header: Header
|
||||||
honeypot: "%{label} (do not fill in)"
|
honeypot: "%{label} (do not fill in)"
|
||||||
inbox_url: URL of the relay inbox
|
inbox_url: URL of the relay inbox
|
||||||
|
|
|
@ -42,7 +42,6 @@ ja:
|
||||||
fields: プロフィールに表として4つまでの項目を表示することができます
|
fields: プロフィールに表として4つまでの項目を表示することができます
|
||||||
group: このアカウントに送られたメンションは自動でBTされ、フォローしている全てのアカウントに配信されます
|
group: このアカウントに送られたメンションは自動でBTされ、フォローしている全てのアカウントに配信されます
|
||||||
group_allow_private_message: 投稿は複製されるため、投稿者が編集・削除することはできません
|
group_allow_private_message: 投稿は複製されるため、投稿者が編集・削除することはできません
|
||||||
group_message_following_only: 荒らし・スパム対策として有効ですが、加入者をフォローする手間が発生します
|
|
||||||
header: "%{size}までのPNG、GIF、JPGが利用可能です。 %{dimensions}pxまで縮小されます"
|
header: "%{size}までのPNG、GIF、JPGが利用可能です。 %{dimensions}pxまで縮小されます"
|
||||||
inbox_url: 使用したいリレーサーバーのトップページからURLをコピーします
|
inbox_url: 使用したいリレーサーバーのトップページからURLをコピーします
|
||||||
irreversible: フィルターが後で削除されても、除外された投稿は元に戻せなくなります
|
irreversible: フィルターが後で削除されても、除外された投稿は元に戻せなくなります
|
||||||
|
@ -185,7 +184,6 @@ ja:
|
||||||
fields: プロフィール補足情報
|
fields: プロフィール補足情報
|
||||||
group: これはグループアカウントです
|
group: これはグループアカウントです
|
||||||
group_allow_private_message: グループアカウントの場合、フォロワーのみ・ダイレクトのメンションを複製する
|
group_allow_private_message: グループアカウントの場合、フォロワーのみ・ダイレクトのメンションを複製する
|
||||||
group_message_following_only: グループアカウントの場合、自分がフォローしている相手からのメンションのみをBTする
|
|
||||||
header: ヘッダー
|
header: ヘッダー
|
||||||
honeypot: "%{label} (入力しない)"
|
honeypot: "%{label} (入力しない)"
|
||||||
inbox_url: リレーサーバーの inbox URL
|
inbox_url: リレーサーバーの inbox URL
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AddGroupMessageFollowingOnlyToAccounts < ActiveRecord::Migration[6.1]
|
class AddGroupMessageFollowingOnlyToAccounts < ActiveRecord::Migration[6.1]
|
||||||
def change
|
def change
|
||||||
add_column :accounts, :group_message_following_only, :boolean
|
add_column :accounts, :group_message_following_only, :boolean
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AddGroupAllowPrivateMessageToAccounts < ActiveRecord::Migration[6.1]
|
class AddGroupAllowPrivateMessageToAccounts < ActiveRecord::Migration[6.1]
|
||||||
def change
|
def change
|
||||||
add_column :accounts, :group_allow_private_message, :boolean
|
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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -99,6 +99,7 @@ ActiveRecord::Schema.define(version: 2023_03_14_081013) do
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.datetime "last_status_at"
|
t.datetime "last_status_at"
|
||||||
|
t.integer "group_activitypub_count"
|
||||||
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
|
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -186,7 +187,6 @@ ActiveRecord::Schema.define(version: 2023_03_14_081013) do
|
||||||
t.boolean "trendable"
|
t.boolean "trendable"
|
||||||
t.datetime "reviewed_at"
|
t.datetime "reviewed_at"
|
||||||
t.datetime "requested_review_at"
|
t.datetime "requested_review_at"
|
||||||
t.boolean "group_message_following_only"
|
|
||||||
t.boolean "group_allow_private_message"
|
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 "(((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 "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