Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `config/i18n-tasks.yml`: Upstream added new ignored strings, glitch-soc has extra ignored strings because of the theming system. Added upstream's changes.
This commit is contained in:
@@ -88,8 +88,8 @@ class Account < ApplicationRecord
|
||||
validates :username, presence: true
|
||||
validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? }
|
||||
|
||||
# Remote user validations
|
||||
validates :username, format: { with: USERNAME_ONLY_RE }, if: -> { !local? && will_save_change_to_username? }
|
||||
# Remote user validations, also applies to internal actors
|
||||
validates :username, format: { with: USERNAME_ONLY_RE }, if: -> { (!local? || actor_type == 'Application') && will_save_change_to_username? }
|
||||
|
||||
# Local user validations
|
||||
validates :username, format: { with: /\A[a-z0-9_]+\z/i }, length: { maximum: 30 }, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
|
||||
|
@@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'csv'
|
||||
|
||||
# A non-activerecord helper class for csv upload
|
||||
class Admin::Import
|
||||
include ActiveModel::Model
|
||||
@@ -15,17 +17,46 @@ class Admin::Import
|
||||
data.original_filename
|
||||
end
|
||||
|
||||
def csv_rows
|
||||
csv_data.rewind
|
||||
|
||||
csv_data.take(ROWS_PROCESSING_LIMIT + 1)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def csv_data
|
||||
return @csv_data if defined?(@csv_data)
|
||||
|
||||
csv_converter = lambda do |field, field_info|
|
||||
case field_info.header
|
||||
when '#domain', '#public_comment'
|
||||
field&.strip
|
||||
when '#severity'
|
||||
field&.strip&.to_sym
|
||||
when '#reject_media', '#reject_reports', '#obfuscate'
|
||||
ActiveModel::Type::Boolean.new.cast(field)
|
||||
else
|
||||
field
|
||||
end
|
||||
end
|
||||
|
||||
@csv_data = CSV.open(data.path, encoding: 'UTF-8', skip_blanks: true, headers: true, converters: csv_converter)
|
||||
@csv_data.take(1) # Ensure the headers are read
|
||||
@csv_data = CSV.open(data.path, encoding: 'UTF-8', skip_blanks: true, headers: ['#domain'], converters: csv_converter) unless @csv_data.headers&.first == '#domain'
|
||||
@csv_data
|
||||
end
|
||||
|
||||
def csv_row_count
|
||||
return @csv_row_count if defined?(@csv_row_count)
|
||||
|
||||
csv_data.rewind
|
||||
@csv_row_count = csv_data.take(ROWS_PROCESSING_LIMIT + 2).count
|
||||
end
|
||||
|
||||
def validate_data
|
||||
return if data.blank?
|
||||
|
||||
csv_data = CSV.read(data.path, encoding: 'UTF-8')
|
||||
|
||||
row_count = csv_data.size
|
||||
row_count -= 1 if csv_data.first&.first == '#domain'
|
||||
|
||||
errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if row_count > ROWS_PROCESSING_LIMIT
|
||||
return if data.nil?
|
||||
errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if csv_row_count > ROWS_PROCESSING_LIMIT
|
||||
rescue CSV::MalformedCSVError => e
|
||||
errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message))
|
||||
end
|
||||
|
@@ -6,7 +6,8 @@ class Admin::StatusBatchAction
|
||||
include Authorization
|
||||
|
||||
attr_accessor :current_account, :type,
|
||||
:status_ids, :report_id
|
||||
:status_ids, :report_id,
|
||||
:text
|
||||
|
||||
attr_reader :send_email_notification
|
||||
|
||||
@@ -57,7 +58,8 @@ class Admin::StatusBatchAction
|
||||
action: :delete_statuses,
|
||||
account: current_account,
|
||||
report: report,
|
||||
status_ids: status_ids
|
||||
status_ids: status_ids,
|
||||
text: text
|
||||
)
|
||||
|
||||
statuses.each { |status| Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true) } unless target_account.local?
|
||||
@@ -95,7 +97,8 @@ class Admin::StatusBatchAction
|
||||
action: :mark_statuses_as_sensitive,
|
||||
account: current_account,
|
||||
report: report,
|
||||
status_ids: status_ids
|
||||
status_ids: status_ids,
|
||||
text: text
|
||||
)
|
||||
|
||||
UserMailer.warning(target_account.user, @warning).deliver_later! if warnable?
|
||||
|
@@ -13,9 +13,11 @@ module AccountFinderConcern
|
||||
end
|
||||
|
||||
def representative
|
||||
Account.find(-99).tap(&:ensure_keys!)
|
||||
actor = Account.find(-99).tap(&:ensure_keys!)
|
||||
actor.update!(username: 'mastodon.internal') if actor.username.include?(':')
|
||||
actor
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
|
||||
Account.create!(id: -99, actor_type: 'Application', locked: true, username: 'mastodon.internal')
|
||||
end
|
||||
|
||||
def find_local(username)
|
||||
|
@@ -28,6 +28,7 @@ class Form::AdminSettings
|
||||
show_reblogs_in_public_timelines
|
||||
show_replies_in_public_timelines
|
||||
trends
|
||||
trends_as_landing_page
|
||||
trendable_by_default
|
||||
trending_status_cw
|
||||
show_domain_blocks
|
||||
@@ -57,6 +58,7 @@ class Form::AdminSettings
|
||||
show_reblogs_in_public_timelines
|
||||
show_replies_in_public_timelines
|
||||
trends
|
||||
trends_as_landing_page
|
||||
trendable_by_default
|
||||
trending_status_cw
|
||||
noindex
|
||||
|
Reference in New Issue
Block a user