Merge commit 'dfa5889fc0
' into kb_migration
This commit is contained in:
commit
4a19077534
285 changed files with 938 additions and 822 deletions
|
@ -378,11 +378,11 @@ class Account < ApplicationRecord
|
|||
end
|
||||
|
||||
def fields
|
||||
(self[:fields] || []).map do |f|
|
||||
(self[:fields] || []).filter_map do |f|
|
||||
Account::Field.new(self, f)
|
||||
rescue
|
||||
nil
|
||||
end.compact
|
||||
end
|
||||
end
|
||||
|
||||
def fields_attributes=(attributes)
|
||||
|
|
|
@ -123,12 +123,12 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
|
|||
private
|
||||
|
||||
def update_last_inspected
|
||||
if EXCEPTION_BOOLS.map { |name| attribute_change_to_be_saved(name) }.compact.include?([true, false])
|
||||
if EXCEPTION_BOOLS.filter_map { |name| attribute_change_to_be_saved(name) }.include?([true, false])
|
||||
# Policy has been widened in such a way that any previously-inspected status
|
||||
# may need to be deleted, so we'll have to start again.
|
||||
redis.del("account_cleanup:#{account_id}")
|
||||
end
|
||||
redis.del("account_cleanup:#{account_id}") if EXCEPTION_THRESHOLDS.map { |name| attribute_change_to_be_saved(name) }.compact.any? { |old, new| old.present? && (new.nil? || new > old) }
|
||||
redis.del("account_cleanup:#{account_id}") if EXCEPTION_THRESHOLDS.filter_map { |name| attribute_change_to_be_saved(name) }.any? { |old, new| old.present? && (new.nil? || new > old) }
|
||||
end
|
||||
|
||||
def validate_local_account
|
||||
|
|
|
@ -48,14 +48,14 @@ class AccountSuggestions::SettingSource < AccountSuggestions::Source
|
|||
end
|
||||
|
||||
def setting_to_usernames_and_domains
|
||||
setting.split(',').map do |str|
|
||||
setting.split(',').filter_map do |str|
|
||||
username, domain = str.strip.gsub(/\A@/, '').split('@', 2)
|
||||
domain = nil if TagManager.instance.local_domain?(domain)
|
||||
|
||||
next if username.blank?
|
||||
|
||||
[username.downcase, domain&.downcase]
|
||||
end.compact
|
||||
end
|
||||
end
|
||||
|
||||
def setting
|
||||
|
|
|
@ -20,7 +20,7 @@ class AccountSuggestions::Source
|
|||
|
||||
map = scope.index_by { |account| to_ordered_list_key(account) }
|
||||
|
||||
ordered_list.map { |ordered_list_key| map[ordered_list_key] }.compact.map do |account|
|
||||
ordered_list.filter_map { |ordered_list_key| map[ordered_list_key] }.map do |account|
|
||||
AccountSuggestions::Suggestion.new(
|
||||
account: account,
|
||||
source: key
|
||||
|
|
|
@ -22,7 +22,7 @@ class FollowRecommendationFilter
|
|||
account_ids = redis.zrevrange("follow_recommendations:#{@language}", 0, -1).map(&:to_i)
|
||||
accounts = Account.where(id: account_ids).index_by(&:id)
|
||||
|
||||
account_ids.map { |id| accounts[id] }.compact
|
||||
account_ids.filter_map { |id| accounts[id] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#
|
||||
|
||||
class Identity < ApplicationRecord
|
||||
belongs_to :user, dependent: :destroy
|
||||
belongs_to :user
|
||||
validates :uid, presence: true, uniqueness: { scope: :provider }
|
||||
validates :provider, presence: true
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ class Notification < ApplicationRecord
|
|||
ActiveRecord::Associations::Preloader.new.preload(grouped_notifications, associations)
|
||||
end
|
||||
|
||||
unique_target_statuses = notifications.map(&:target_status).compact.uniq
|
||||
unique_target_statuses = notifications.filter_map(&:target_status).uniq
|
||||
# Call cache_collection in block
|
||||
cached_statuses_by_id = yield(unique_target_statuses).index_by(&:id)
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ class UserRole < ApplicationRecord
|
|||
end
|
||||
|
||||
def permissions_as_keys=(value)
|
||||
self.permissions = value.map(&:presence).compact.reduce(Flags::NONE) { |bitmask, privilege| FLAGS.key?(privilege.to_sym) ? (bitmask | FLAGS[privilege.to_sym]) : bitmask }
|
||||
self.permissions = value.filter_map(&:presence).reduce(Flags::NONE) { |bitmask, privilege| FLAGS.key?(privilege.to_sym) ? (bitmask | FLAGS[privilege.to_sym]) : bitmask }
|
||||
end
|
||||
|
||||
def can?(*any_of_privileges)
|
||||
|
|
|
@ -53,7 +53,7 @@ class Webhook < ApplicationRecord
|
|||
end
|
||||
|
||||
def strip_events
|
||||
self.events = events.map { |str| str.strip.presence }.compact if events.present?
|
||||
self.events = events.filter_map { |str| str.strip.presence } if events.present?
|
||||
end
|
||||
|
||||
def generate_secret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue