Merge commit '563fc88821
' into kb_migration
This commit is contained in:
commit
5233e68f13
20 changed files with 183 additions and 22 deletions
|
@ -343,6 +343,7 @@ class Account < ApplicationRecord
|
|||
end
|
||||
|
||||
def emoji_reactions_must_following?
|
||||
return false unless Setting.enable_block_emoji_reaction_settings
|
||||
return user&.settings&.[]('emoji_reactions.must_be_following') || false if user.present?
|
||||
return settings['emoji_reactions_must_be_following'] || false if settings.present?
|
||||
|
||||
|
@ -350,6 +351,7 @@ class Account < ApplicationRecord
|
|||
end
|
||||
|
||||
def emoji_reactions_must_follower?
|
||||
return false unless Setting.enable_block_emoji_reaction_settings
|
||||
return user&.settings&.[]('emoji_reactions.must_be_follower') || false if user.present?
|
||||
return settings['emoji_reaction_must_be_follower'] || false if settings.present?
|
||||
|
||||
|
@ -357,6 +359,7 @@ class Account < ApplicationRecord
|
|||
end
|
||||
|
||||
def emoji_reactions_deny_from_all?
|
||||
return false unless Setting.enable_block_emoji_reaction_settings
|
||||
return user&.settings&.[]('emoji_reactions.deny_from_all') || false if user.present?
|
||||
return settings['emoji_reaction_deny_from_all'] || false if settings.present?
|
||||
|
||||
|
|
28
app/models/admin/ng_word.rb
Normal file
28
app/models/admin/ng_word.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Admin::NgWord
|
||||
class << self
|
||||
def reject?(text)
|
||||
ng_words.any? { |word| text.include?(word) }
|
||||
end
|
||||
|
||||
def hashtag_reject?(hashtag_count)
|
||||
post_hash_tags_max.positive? && post_hash_tags_max < hashtag_count
|
||||
end
|
||||
|
||||
def hashtag_reject_with_extractor?(text)
|
||||
hashtag_reject?(Extractor.extract_hashtags(text)&.size || 0)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ng_words
|
||||
Setting.ng_words
|
||||
end
|
||||
|
||||
def post_hash_tags_max
|
||||
value = Setting.post_hash_tags_max
|
||||
value.is_a?(Integer) && value.positive? ? value : 0
|
||||
end
|
||||
end
|
||||
end
|
|
@ -34,12 +34,17 @@ class Form::AdminSettings
|
|||
backups_retention_period
|
||||
status_page_url
|
||||
captcha_enabled
|
||||
ng_words
|
||||
enable_block_emoji_reaction_settings
|
||||
hide_local_users_for_anonymous
|
||||
post_hash_tags_max
|
||||
).freeze
|
||||
|
||||
INTEGER_KEYS = %i(
|
||||
media_cache_retention_period
|
||||
content_cache_retention_period
|
||||
backups_retention_period
|
||||
post_hash_tags_max
|
||||
).freeze
|
||||
|
||||
BOOLEAN_KEYS = %i(
|
||||
|
@ -54,6 +59,8 @@ class Form::AdminSettings
|
|||
noindex
|
||||
require_invite_text
|
||||
captcha_enabled
|
||||
enable_block_emoji_reaction_settings
|
||||
hide_local_users_for_anonymous
|
||||
).freeze
|
||||
|
||||
UPLOAD_KEYS = %i(
|
||||
|
@ -61,6 +68,10 @@ class Form::AdminSettings
|
|||
mascot
|
||||
).freeze
|
||||
|
||||
STRING_ARRAY_KEYS = %i(
|
||||
ng_words
|
||||
).freeze
|
||||
|
||||
attr_accessor(*KEYS)
|
||||
|
||||
validates :registrations_mode, inclusion: { in: %w(open approved none) }, if: -> { defined?(@registrations_mode) }
|
||||
|
@ -80,6 +91,8 @@ class Form::AdminSettings
|
|||
|
||||
stored_value = if UPLOAD_KEYS.include?(key)
|
||||
SiteUpload.where(var: key).first_or_initialize(var: key)
|
||||
elsif STRING_ARRAY_KEYS.include?(key)
|
||||
Setting.public_send(key)&.join("\n") || ''
|
||||
else
|
||||
Setting.public_send(key)
|
||||
end
|
||||
|
@ -122,6 +135,8 @@ class Form::AdminSettings
|
|||
value == '1'
|
||||
elsif INTEGER_KEYS.include?(key)
|
||||
value.blank? ? value : Integer(value)
|
||||
elsif STRING_ARRAY_KEYS.include?(key)
|
||||
value&.split(/\r\n|\r|\n/)&.filter(&:present?)&.uniq || []
|
||||
else
|
||||
value
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ class PublicFeed
|
|||
scope.merge!(without_replies_scope) unless with_replies?
|
||||
scope.merge!(without_reblogs_scope) unless with_reblogs?
|
||||
scope.merge!(local_only_scope) if local_only?
|
||||
scope.merge!(remote_only_scope) if remote_only?
|
||||
scope.merge!(remote_only_scope) if remote_only? || hide_local_users?
|
||||
scope.merge!(global_timeline_only_scope) if global_timeline?
|
||||
scope.merge!(account_filters_scope) if account?
|
||||
scope.merge!(media_only_scope) if media_only?
|
||||
|
@ -54,6 +54,10 @@ class PublicFeed
|
|||
options[:remote]
|
||||
end
|
||||
|
||||
def hide_local_users?
|
||||
@account.nil? && Setting.hide_local_users_for_anonymous
|
||||
end
|
||||
|
||||
def global_timeline?
|
||||
!options[:remote] && !options[:local]
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ class TagFeed < PublicFeed
|
|||
scope.merge!(tagged_with_all_scope)
|
||||
scope.merge!(tagged_with_none_scope)
|
||||
scope.merge!(local_only_scope) if local_only?
|
||||
scope.merge!(remote_only_scope) if remote_only?
|
||||
scope.merge!(remote_only_scope) if remote_only? || hide_local_users?
|
||||
scope.merge!(account_filters_scope) if account?
|
||||
scope.merge!(media_only_scope) if media_only?
|
||||
scope.merge!(anonymous_scope) unless account?
|
||||
|
|
|
@ -36,6 +36,7 @@ class UserRole < ApplicationRecord
|
|||
manage_roles: (1 << 17),
|
||||
manage_user_access: (1 << 18),
|
||||
delete_user_data: (1 << 19),
|
||||
manage_ng_words: (1 << 30),
|
||||
}.freeze
|
||||
|
||||
module Flags
|
||||
|
@ -61,6 +62,7 @@ class UserRole < ApplicationRecord
|
|||
manage_blocks
|
||||
manage_taxonomies
|
||||
manage_invites
|
||||
manage_ng_words
|
||||
).freeze,
|
||||
|
||||
administration: %w(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue