diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index c33567956cae93..a023b073b39e10 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -20,8 +20,8 @@ def update private def account_params - # params.require(:account).permit(:display_name, :note, :bio_markdown, :avatar, :header, :locked, :my_actor_type, :searchability, :dissubscribable, :group_allow_private_message, :discoverable, :discoverable_local, :hide_collections, fields_attributes: [:name, :value]) - params.require(:account).permit(:display_name, :note, :bio_markdown, :avatar, :header, :bot, :my_actor_type, :group_allow_private_message, :dissubscribable, fields_attributes: [:name, :value]) + # params.require(:account).permit(:display_name, :note, :bio_markdown, :avatar, :header, :locked, :my_actor_type, :searchability, :dissubscribable, :discoverable, :discoverable_local, :hide_collections, fields_attributes: [:name, :value]) + params.require(:account).permit(:display_name, :note, :bio_markdown, :avatar, :header, :bot, :my_actor_type, :dissubscribable, fields_attributes: [:name, :value]) end def set_account diff --git a/app/models/account.rb b/app/models/account.rb index 2d442a5ebe22fa..02d58e78089b0e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -50,7 +50,6 @@ # trendable :boolean # reviewed_at :datetime # requested_review_at :datetime -# group_allow_private_message :boolean # searchability :integer default("direct"), not null # settings :jsonb # indexable :boolean default(FALSE), not null diff --git a/app/models/account_stat.rb b/app/models/account_stat.rb index 622edb9c2212b4..0fea7732e9874c 100644 --- a/app/models/account_stat.rb +++ b/app/models/account_stat.rb @@ -4,15 +4,14 @@ # # 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 -# group_activitypub_count :integer +# 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 # class AccountStat < ApplicationRecord @@ -34,8 +33,4 @@ def followers_count def statuses_count [attributes['statuses_count'], 0].max end - - def group_activitypub_count - [attributes['group_activitypub_count'] || 0, 0].max - end end diff --git a/app/models/concerns/account/counters.rb b/app/models/concerns/account/counters.rb index bd1e19b7828bea..4488398128aab5 100644 --- a/app/models/concerns/account/counters.rb +++ b/app/models/concerns/account/counters.rb @@ -16,8 +16,6 @@ module Account::Counters :following_count=, :followers_count, :followers_count=, - :group_activitypub_count, - :group_activitypub_count=, :last_status_at, to: :account_stat diff --git a/app/models/ng_rule.rb b/app/models/ng_rule.rb index 78d2979c4038d0..6048275e90cdaf 100644 --- a/app/models/ng_rule.rb +++ b/app/models/ng_rule.rb @@ -29,8 +29,8 @@ # status_poll_state :integer default("optional"), not null # status_quote_state :integer default("optional"), not null # status_reply_state :integer default("optional"), not null -# status_mention_state :integer default(0), not null -# status_reference_state :integer default(0), not null +# status_mention_state :integer default("optional"), not null +# status_reference_state :integer default("optional"), not null # status_tag_threshold :integer default(-1), not null # status_media_threshold :integer default(-1), not null # status_poll_threshold :integer default(-1), not null diff --git a/app/services/group_reblog_service.rb b/app/services/group_reblog_service.rb index ad1bfed3cebfb6..b754391dda53c5 100644 --- a/app/services/group_reblog_service.rb +++ b/app/services/group_reblog_service.rb @@ -1,88 +1,19 @@ # frozen_string_literal: true class GroupReblogService < BaseService - include RoutingHelper - - ACTIVITYPUB_CONTINUOUS_SIZE = 30 - def call(status) return nil if status.account.group? visibility = status.visibility.to_sym - return nil unless %i(public public_unlisted unlisted login private direct).include?(visibility) + return nil unless %i(public public_unlisted unlisted login).include?(visibility) - accounts = status.mentions.map(&:account) | status.active_mentions.map(&:account) - transcription = %i(private direct).include?(visibility) - - accounts.each do |account| + status.mentions.map(&:account).each do |account| next unless account.local? 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? && ACTIVITYPUB_CONTINUOUS_SIZE.positive? - next if account.group_activitypub_count >= ACTIVITYPUB_CONTINUOUS_SIZE - - account.group_activitypub_count = account.group_activitypub_count + 1 - account.save! - elsif account.group_activitypub_count.positive? - account.group_activitypub_count = 0 - account.save! - end - - ReblogService.new.call(account, status, { visibility: status.visibility }) unless transcription - - next unless transcription - - username = status.account.local? ? status.account.username : "#{status.account.username}@#{status.account.domain}" - - media_attachments = status.media_attachments.map do |media| - media.needs_redownload? ? media_proxy_url(media.id, :original) : full_asset_url(media.file.url(:original)) - MediaAttachment.create( - account: account, - remote_url: media_url(media), - thumbnail_remote_url: media_preview_url(media) - ).tap do |attachment| - attachment.download_file! - attachment.save - end - end - - text = status.account.local? ? status.text : strip_tags(status.text.gsub('
', "\n").gsub(%r{
}, "\n").gsub(%r{

}, "\n\n").strip) - - PostStatusService.new.call( - account, - text: "Private message by @#{username}\n\\-\\-\\-\\-\n#{text}", - thread: status.thread, - media_ids: media_attachments.map(&:id), - sensitive: status.sensitive, - spoiler_text: status.spoiler_text, - visibility: :private, - language: status.language, - poll: status.poll, - with_rate_limit: true - ) - end - end - - def media_url(media) - if media.not_processed? - nil - elsif media.needs_redownload? - media_proxy_url(media.id, :original) - else - full_asset_url(media.file.url(:original)) - end - end - def media_preview_url(media) - if media.needs_redownload? - media_proxy_url(media.id, :small) - elsif media.thumbnail.present? - full_asset_url(media.thumbnail.url(:original)) - elsif media.file.styles.key?(:small) - full_asset_url(media.file.url(:small)) + ReblogService.new.call(account, status, { visibility: status.visibility }) end end end diff --git a/db/migrate/20240227033337_remove_group_attrs_from_accounts.rb b/db/migrate/20240227033337_remove_group_attrs_from_accounts.rb new file mode 100644 index 00000000000000..c339bf6efa0f61 --- /dev/null +++ b/db/migrate/20240227033337_remove_group_attrs_from_accounts.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class RemoveGroupAttrsFromAccounts < ActiveRecord::Migration[7.1] + def change + safety_assured do + remove_column :accounts, :group_allow_private_message, :boolean + remove_column :account_stats, :group_activitypub_count, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5f8e87bf0bc41d..aeb81e046ecfee 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_02_18_233621) do +ActiveRecord::Schema[7.1].define(version: 2024_02_27_033337) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -98,7 +98,6 @@ t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.datetime "last_status_at", precision: nil - t.integer "group_activitypub_count" t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true t.index ["last_status_at", "account_id"], name: "index_account_stats_on_last_status_at_and_account_id", order: { last_status_at: "DESC NULLS LAST" } end @@ -189,7 +188,6 @@ t.boolean "trendable" t.datetime "reviewed_at", precision: nil t.datetime "requested_review_at", precision: nil - t.boolean "group_allow_private_message" t.integer "searchability", default: 2, null: false t.jsonb "settings" t.boolean "indexable", default: false, null: false diff --git a/lib/tasks/dangerous.rake b/lib/tasks/dangerous.rake index 000be50911e434..ac3895811a0567 100644 --- a/lib/tasks/dangerous.rake +++ b/lib/tasks/dangerous.rake @@ -89,6 +89,7 @@ namespace :dangerous do 20240217093511 20240217230006 20240218233621 + 20240227033337 ) # Removed: account_groups target_tables = %w( @@ -115,14 +116,14 @@ namespace :dangerous do ) target_table_columns = [ # Removed: accounts dissubscribable - %w(accounts group_allow_private_message), + # Removed: accounts group_allow_private_message # Removed: accounts group_message_following_only %w(accounts master_settings), %w(accounts remote_pending), %w(accounts searchability), %w(accounts settings), # Removed: accounts stop_emoji_reaction_streaming - %w(account_stats group_activitypub_count), + # Removed: account_stats group_activitypub_count %w(account_statuses_cleanup_policies keep_self_emoji), %w(account_statuses_cleanup_policies min_emojis), %w(conversations ancestor_status_id),