Merge remote-tracking branch 'parent/main' into upstream-20231124
This commit is contained in:
commit
c5e4020922
206 changed files with 1987 additions and 965 deletions
|
@ -129,6 +129,8 @@ module AccountSearch
|
|||
LIMIT :limit OFFSET :offset
|
||||
SQL
|
||||
|
||||
DEFAULT_LIMIT = 10
|
||||
|
||||
def searchable_text
|
||||
PlainTextFormatter.new(note, local?).to_s if discoverable?
|
||||
end
|
||||
|
@ -141,7 +143,7 @@ module AccountSearch
|
|||
end
|
||||
|
||||
class_methods do
|
||||
def search_for(terms, limit: 10, offset: 0)
|
||||
def search_for(terms, limit: DEFAULT_LIMIT, offset: 0)
|
||||
tsquery = generate_query_for_search(terms)
|
||||
|
||||
find_by_sql([BASIC_SEARCH_SQL, { limit: limit, offset: offset, tsquery: tsquery }]).tap do |records|
|
||||
|
@ -149,7 +151,7 @@ module AccountSearch
|
|||
end
|
||||
end
|
||||
|
||||
def advanced_search_for(terms, account, limit: 10, following: false, follower: false, offset: 0)
|
||||
def advanced_search_for(terms, account, limit: DEFAULT_LIMIT, following: false, follower: false, offset: 0)
|
||||
tsquery = generate_query_for_search(terms)
|
||||
sql_template = if following
|
||||
ADVANCED_SEARCH_WITH_FOLLOWING
|
||||
|
|
|
@ -40,7 +40,7 @@ class StatusEdit < ApplicationRecord
|
|||
belongs_to :status
|
||||
belongs_to :account, optional: true
|
||||
|
||||
default_scope { order(id: :asc) }
|
||||
scope :ordered, -> { order(id: :asc) }
|
||||
|
||||
delegate :local?, :application, :edited?, :edited_at, :language,
|
||||
:discarded?, :visibility, to: :status
|
||||
|
|
|
@ -98,11 +98,9 @@ class User < ApplicationRecord
|
|||
accepts_nested_attributes_for :invite_request, reject_if: ->(attributes) { attributes['text'].blank? && !Setting.require_invite_text }
|
||||
validates :invite_request, presence: true, on: :create, if: :invite_text_required?
|
||||
|
||||
validates :locale, inclusion: I18n.available_locales.map(&:to_s), if: :locale?
|
||||
validates_with BlacklistedEmailValidator, if: -> { ENV['EMAIL_DOMAIN_LISTS_APPLY_AFTER_CONFIRMATION'] == 'true' || !confirmed? }
|
||||
validates_with EmailMxValidator, if: :validate_email_dns?
|
||||
validates :agreement, acceptance: { allow_nil: false, accept: [true, 'true', '1'] }, on: :create
|
||||
validates :time_zone, inclusion: { in: ActiveSupport::TimeZone.all.map { |tz| tz.tzinfo.name } }, allow_blank: true
|
||||
|
||||
# Honeypot/anti-spam fields
|
||||
attr_accessor :registration_form_time, :website, :confirm_password
|
||||
|
@ -126,6 +124,8 @@ class User < ApplicationRecord
|
|||
|
||||
before_validation :sanitize_languages
|
||||
before_validation :sanitize_role
|
||||
before_validation :sanitize_time_zone
|
||||
before_validation :sanitize_locale
|
||||
before_create :set_approved
|
||||
after_commit :send_pending_devise_notifications
|
||||
after_create_commit :trigger_webhooks
|
||||
|
@ -453,9 +453,15 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def sanitize_role
|
||||
return if role.nil?
|
||||
self.role = nil if role.present? && role.everyone?
|
||||
end
|
||||
|
||||
self.role = nil if role.everyone?
|
||||
def sanitize_time_zone
|
||||
self.time_zone = nil if time_zone.present? && ActiveSupport::TimeZone[time_zone].nil?
|
||||
end
|
||||
|
||||
def sanitize_locale
|
||||
self.locale = nil if locale.present? && I18n.available_locales.exclude?(locale.to_sym)
|
||||
end
|
||||
|
||||
def prepare_new_user!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue