Merge commit '4b65740722' into kb_development

This commit is contained in:
KMY 2023-07-25 15:25:28 +09:00
commit 83065ff389
398 changed files with 3376 additions and 2449 deletions

View file

@ -94,12 +94,19 @@ class Account < ApplicationRecord
# 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? }
# Remote user validations
validates :uri, presence: true, unless: :local?, on: :create
# 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' }
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? }
validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
validates :fields, length: { maximum: 6 }, if: -> { local? && will_save_change_to_fields? }
validates :uri, absence: true, if: :local?, on: :create
validates :inbox_url, absence: true, if: :local?, on: :create
validates :shared_inbox_url, absence: true, if: :local?, on: :create
validates :followers_url, absence: true, if: :local?, on: :create
scope :remote, -> { where.not(domain: nil) }
scope :local, -> { where(domain: nil) }

View file

@ -5,6 +5,8 @@ class ApplicationRecord < ActiveRecord::Base
include Remotable
connects_to database: { writing: :primary, reading: ENV['DB_REPLICA_NAME'] || ENV['READ_DATABASE_URL'] ? :read : :primary }
class << self
def update_index(_type_name, *_args, &_block)
super if Chewy.enabled?

View file

@ -151,10 +151,6 @@ module HasUserSettings
settings['web.trends']
end
def setting_crop_images
settings['web.crop_images']
end
def setting_disable_swiping
settings['web.disable_swiping']
end

View file

@ -58,7 +58,8 @@ class Report < ApplicationRecord
before_validation :set_uri, only: :create
after_create_commit :trigger_webhooks
after_create_commit :trigger_create_webhooks
after_update_commit :trigger_update_webhooks
def object_type
:flag
@ -155,7 +156,11 @@ class Report < ApplicationRecord
errors.add(:rule_ids, I18n.t('reports.errors.invalid_rules')) unless rules.size == rule_ids&.size
end
def trigger_webhooks
def trigger_create_webhooks
TriggerWebhookWorker.perform_async('report.created', 'Report', id)
end
def trigger_update_webhooks
TriggerWebhookWorker.perform_async('report.updated', 'Report', id)
end
end

View file

@ -32,7 +32,6 @@ class UserSettings
setting :emoji_reaction_streaming_notify_impl2, default: false
namespace :web do
setting :crop_images, default: true
setting :advanced_layout, default: false
setting :trends, default: true
setting :use_blurhash, default: true

View file

@ -20,6 +20,7 @@ class Webhook < ApplicationRecord
account.created
account.updated
report.created
report.updated
status.created
status.updated
).freeze
@ -59,7 +60,7 @@ class Webhook < ApplicationRecord
case event
when 'account.approved', 'account.created', 'account.updated'
:manage_users
when 'report.created'
when 'report.created', 'report.updated'
:manage_reports
when 'status.created', 'status.updated'
:view_devops