Skip to content

Commit

Permalink
Merge pull request #418 from kmycode/kb-draft-5.13-lts
Browse files Browse the repository at this point in the history
Release: 5.13 LTS
  • Loading branch information
kmycode authored Jan 11, 2024
2 parents e227885 + b21c045 commit ad7f235
Show file tree
Hide file tree
Showing 29 changed files with 365 additions and 163 deletions.
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ Rails/SkipsModelValidations:
- 'db/migrate/20190511134027_add_silenced_at_suspended_at_to_accounts.rb'
- 'db/migrate/20191007013357_update_pt_locales.rb'
- 'db/migrate/20220316233212_update_kurdish_locales.rb'
- 'db/migrate/20240109035435_remove_hidden_anonymous_from_domain_blocks.rb'
- 'db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb'
- 'db/post_migrate/20200917193528_migrate_notifications_type.rb'
- 'db/post_migrate/20201017234926_fill_account_suspension_origin.rb'
Expand Down
Binary file added .yarn/install-state.gz
Binary file not shown.
12 changes: 6 additions & 6 deletions app/controllers/admin/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ def set_domain_block
end

def update_params
params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag,
:reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous)
params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag,
:reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
end

def resource_params
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag,
:reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous)
params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag,
:reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
end

def form_domain_block_batch_params
params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media,
:reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous])
params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers,
:reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden])
end

def action_from_button
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/v1/admin/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def filtered_domain_blocks
end

def domain_block_params
params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
:reject_new_follow, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous)
params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
:reject_new_follow, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden)
end

def insert_pagination_headers
Expand Down Expand Up @@ -102,7 +102,7 @@ def pagination_params(core_params)
end

def resource_params
params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
:reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous)
params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow,
:reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ def require_enabled_api!

def set_domain_blocks
@domain_blocks = DomainBlock.with_user_facing_limitations.by_severity
@domain_blocks = @domain_blocks.filter { |block| !block.hidden_anonymous } unless user_signed_in?
end
end
24 changes: 19 additions & 5 deletions app/lib/account_statuses_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ def results
available_searchabilities = [:public, :unlisted, :private, :direct, :limited, nil]
available_visibilities = [:public, :public_unlisted, :login, :unlisted, :private, :direct, :limited]

available_searchabilities = [:public] if domain_block&.reject_send_not_public_searchability
available_visibilities -= [:public_unlisted] if domain_block&.reject_send_public_unlisted || (domain_block&.detect_invalid_subscription && @account.user&.setting_reject_public_unlisted_subscription)
available_visibilities -= [:unlisted] if domain_block&.detect_invalid_subscription && @account.user&.setting_reject_unlisted_subscription
available_visibilities -= [:public_unlisted] if (domain_block&.detect_invalid_subscription || misskey_software?) && @account.user&.setting_reject_public_unlisted_subscription
available_visibilities -= [:unlisted] if (domain_block&.detect_invalid_subscription || misskey_software?) && @account.user&.setting_reject_unlisted_subscription
available_visibilities -= [:login] if current_account.nil?

scope.merge!(scope.where(spoiler_text: ['', nil])) if domain_block&.reject_send_sensitive
Expand All @@ -44,7 +43,7 @@ def results
private

def initial_scope
if (suspended? || (domain_block&.reject_send_dissubscribable && @account.dissubscribable)) || domain_block&.reject_send_media || blocked?
if suspended? || blocked?
Status.none
elsif anonymous?
account.statuses.where(visibility: %i(public unlisted public_unlisted))
Expand Down Expand Up @@ -156,6 +155,21 @@ def truthy_param?(key)
end

def domain_block
@domain_block = DomainBlock.find_by(domain: @account&.domain)
return nil if @account.nil? || @account.local?

@domain_block = DomainBlock.find_by(domain: @account.domain)
end

def misskey_software?
return false if @account.nil? || @account.local?
return false if instance_info.nil?

%w(misskey cherrypick).include?(instance_info.software)
end

def instance_info
return @instance_info if defined?(@instance_info)

@instance_info = InstanceInfo.find_by(domain: @account.domain)
end
end
4 changes: 0 additions & 4 deletions app/lib/status_reach_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ def banned_domains_of_status(status)
[]
else
blocks = DomainBlock.where(domain: nil)
blocks = blocks.or(DomainBlock.where(reject_send_not_public_searchability: true)) if status.compute_searchability != 'public'
blocks = blocks.or(DomainBlock.where(reject_send_public_unlisted: true)) if status.public_unlisted_visibility?
blocks = blocks.or(DomainBlock.where(reject_send_dissubscribable: true)) if status.account.dissubscribable
blocks = blocks.or(DomainBlock.where(reject_send_media: true)) if status.with_media?
blocks = blocks.or(DomainBlock.where(reject_send_sensitive: true)) if (status.with_media? && status.sensitive) || status.spoiler_text?
blocks.pluck(:domain).uniq
end
Expand Down
11 changes: 11 additions & 0 deletions app/lib/vacuum/feeds_vacuum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Vacuum::FeedsVacuum
def perform
vacuum_inactive_home_feeds!
vacuum_inactive_list_feeds!
vacuum_inactive_antenna_feeds!
end

private
Expand All @@ -20,6 +21,12 @@ def vacuum_inactive_list_feeds!
end
end

def vacuum_inactive_antenna_feeds!
inactive_users_antennas.select(:id).in_batches do |antennas|
feed_manager.clean_feeds!(:antenna, antennas.ids)
end
end

def inactive_users
User.confirmed.inactive
end
Expand All @@ -28,6 +35,10 @@ def inactive_users_lists
List.where(account_id: inactive_users.select(:account_id))
end

def inactive_users_antennas
Antenna.where(account_id: inactive_users.select(:account_id))
end

def feed_manager
FeedManager.instance
end
Expand Down
8 changes: 8 additions & 0 deletions app/models/antenna.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ class Antenna < ApplicationRecord
scope :available_stls, -> { where(available: true, stl: true) }
scope :available_ltls, -> { where(available: true, stl: false, ltl: true) }

validates :title, presence: true

validate :list_owner
validate :validate_limit
validate :validate_stl_limit
validate :validate_ltl_limit

before_destroy :clean_feed_manager

def list_owner
raise Mastodon::ValidationError, I18n.t('antennas.errors.invalid_list_owner') if !list_id.zero? && list.present? && list.account != account
end
Expand Down Expand Up @@ -121,4 +125,8 @@ def validate_ltl_limit
ltls.any? { |tl| !tl.insert_feeds }
end
end

def clean_feed_manager
FeedManager.instance.clean_feeds!(:antenna, [id])
end
end
5 changes: 0 additions & 5 deletions app/models/domain_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
# reject_straight_follow :boolean default(FALSE), not null
# reject_new_follow :boolean default(FALSE), not null
# hidden :boolean default(FALSE), not null
# hidden_anonymous :boolean default(FALSE), not null
# detect_invalid_subscription :boolean default(FALSE), not null
# reject_reply_exclude_followers :boolean default(FALSE), not null
#
Expand Down Expand Up @@ -60,10 +59,6 @@ def policies
reject_favourite? ? :reject_favourite : nil,
reject_reply? ? :reject_reply : nil,
reject_reply_exclude_followers? ? :reject_reply_exclude_followers : nil,
reject_send_not_public_searchability? ? :reject_send_not_public_searchability : nil,
reject_send_public_unlisted? ? :reject_send_public_unlisted : nil,
reject_send_dissubscribable? ? :reject_send_dissubscribable : nil,
reject_send_media? ? :reject_send_media : nil,
reject_send_sensitive? ? :reject_send_sensitive : nil,
reject_hashtag? ? :reject_hashtag : nil,
reject_straight_follow? ? :reject_straight_follow : nil,
Expand Down
6 changes: 1 addition & 5 deletions app/policies/status_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,8 @@ def server_blocking_domain_of_status?(status)
(@domain_block.detect_invalid_subscription && status.public_unlisted_visibility? && status.account.user&.setting_reject_public_unlisted_subscription) ||
(@domain_block.detect_invalid_subscription && status.public_visibility? && status.account.user&.setting_reject_unlisted_subscription)
else
(@domain_block.reject_send_not_public_searchability && status.compute_searchability != 'public') ||
(@domain_block.reject_send_public_unlisted && status.public_unlisted_visibility?) ||
(@domain_block.reject_send_dissubscribable && status.account.dissubscribable) ||
(@domain_block.detect_invalid_subscription && status.public_unlisted_visibility? && status.account.user&.setting_reject_public_unlisted_subscription) ||
(@domain_block.detect_invalid_subscription && status.public_unlisted_visibility? && status.account.user&.setting_reject_public_unlisted_subscription) ||
(@domain_block.detect_invalid_subscription && status.public_visibility? && status.account.user&.setting_reject_unlisted_subscription) ||
(@domain_block.reject_send_media && status.with_media?) ||
(@domain_block.reject_send_sensitive && ((status.with_media? && status.sensitive) || status.spoiler_text?))
end
else
Expand Down
6 changes: 5 additions & 1 deletion app/serializers/nodeinfo/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def version
end

def software
{ name: 'mastodon', version: Mastodon::Version.to_s }
{ name: 'kmyblue', version: Mastodon::Version.to_s }
end

def services
Expand Down Expand Up @@ -41,6 +41,10 @@ def open_registrations
def metadata
{
features: fedibird_capabilities,
upstream: {
name: 'Mastodon',
version: Mastodon::Version.to_s_of_mastodon,
},
}
end

Expand Down
4 changes: 2 additions & 2 deletions app/serializers/rest/admin/domain_block_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class REST::Admin::DomainBlockSerializer < ActiveModel::Serializer
attributes :id, :domain, :created_at, :severity,
:reject_media, :reject_favourite, :reject_reply, :reject_reports,
:reject_send_not_public_searchability, :reject_reply_exclude_followers,
:reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive,
:reject_reply_exclude_followers,
:reject_send_sensitive,
:reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription,
:private_comment, :public_comment, :obfuscate

Expand Down
15 changes: 0 additions & 15 deletions app/views/admin/domain_blocks/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
.fields-group
= f.input :reject_reply_exclude_followers, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply_exclude_followers'), hint: I18n.t('admin.domain_blocks.reject_reply_exclude_followers_hint')

.fields-group
= f.input :reject_send_not_public_searchability, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_not_public_searchability'), hint: I18n.t('admin.domain_blocks.reject_send_not_public_searchability_hint')

.fields-group
= f.input :reject_send_dissubscribable, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_dissubscribable'), hint: I18n.t('admin.domain_blocks.reject_send_dissubscribable_hint')

.fields-group
= f.input :reject_send_public_unlisted, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_public_unlisted'), hint: I18n.t('admin.domain_blocks.reject_send_public_unlisted_hint')

.fields-group
= f.input :reject_send_media, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_media'), hint: I18n.t('admin.domain_blocks.reject_send_media_hint')

.fields-group
= f.input :reject_send_sensitive, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_sensitive'), hint: I18n.t('admin.domain_blocks.reject_send_sensitive_hint')

Expand Down Expand Up @@ -65,8 +53,5 @@
.fields-group
= f.input :hidden, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.hidden'), hint: I18n.t('admin.domain_blocks.hidden_hint')

.fields-group
= f.input :hidden_anonymous, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.hidden_anonymous'), hint: I18n.t('admin.domain_blocks.hidden_anonymous_hint')

.actions
= f.button :button, t('generic.save_changes'), type: :submit
15 changes: 0 additions & 15 deletions app/views/admin/domain_blocks/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
.fields-group
= f.input :reject_reply_exclude_followers, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply_exclude_followers'), hint: I18n.t('admin.domain_blocks.reject_reply_exclude_followers_hint')

.fields-group
= f.input :reject_send_not_public_searchability, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_not_public_searchability'), hint: I18n.t('admin.domain_blocks.reject_send_not_public_searchability_hint')

.fields-group
= f.input :reject_send_dissubscribable, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_dissubscribable'), hint: I18n.t('admin.domain_blocks.reject_send_dissubscribable_hint')

.fields-group
= f.input :reject_send_public_unlisted, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_public_unlisted'), hint: I18n.t('admin.domain_blocks.reject_send_public_unlisted_hint')

.fields-group
= f.input :reject_send_media, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_media'), hint: I18n.t('admin.domain_blocks.reject_send_media_hint')

.fields-group
= f.input :reject_send_sensitive, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_sensitive'), hint: I18n.t('admin.domain_blocks.reject_send_sensitive_hint')

Expand Down Expand Up @@ -65,8 +53,5 @@
.fields-group
= f.input :hidden, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.hidden'), hint: I18n.t('admin.domain_blocks.hidden_hint')

.fields-group
= f.input :hidden_anonymous, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.hidden_anonymous'), hint: I18n.t('admin.domain_blocks.hidden_anonymous_hint')

.actions
= f.button :button, t('.create'), type: :submit
4 changes: 0 additions & 4 deletions app/views/admin/export_domain_blocks/_domain_block.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
= f.hidden_field :reject_favourite
= f.hidden_field :reject_reply
= f.hidden_field :reject_reply_exclude_followers
= f.hidden_field :reject_send_not_public_searchability
= f.hidden_field :reject_send_public_unlisted
= f.hidden_field :reject_send_dissubscribable
= f.hidden_field :reject_send_media
= f.hidden_field :reject_send_sensitive
= f.hidden_field :reject_hashtag
= f.hidden_field :reject_straight_follow
Expand Down
12 changes: 0 additions & 12 deletions app/workers/scheduler/sidekiq_health_scheduler.rb

This file was deleted.

8 changes: 0 additions & 8 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,6 @@ en:
reject_reply_exclude_followers_hint: Reject replies exclude followers in the future
reject_reports: Reject reports
reject_reports_hint: Ignore all reports coming from this domain. Irrelevant for suspensions
reject_send_dissubscribable: 購読拒否アカウントの投稿を配送しない
reject_send_dissubscribable_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です
reject_send_media: 画像付き投稿を配送しない
reject_send_media_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です
reject_send_not_public_searchability: 検索許可が「誰でも」でない投稿を配送しない
reject_send_not_public_searchability_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です
reject_send_public_unlisted: ローカル公開投稿を配送しない
reject_send_public_unlisted_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です
reject_send_sensitive: センシティブな投稿を配送しない
reject_send_sensitive_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です
reject_send_unlisted_dissubscribable: 購読拒否アカウントの未収載投稿を配送しない
Expand Down
Loading

0 comments on commit ad7f235

Please sign in to comment.