Merge commit '74fc4dbacf5a9168074e91fc2d75309dc42ff1ed' into glitch-soc/merge-upstream
This commit is contained in:
commit
eeffe580d8
69 files changed
+523
-463
No files matched your search
@@ -3,10 +3,12 @@
|
||||
module Account::AttributionDomains
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ATTRIBUTION_DOMAINS_LIMIT = 100
|
||||
|
||||
included do
|
||||
normalizes :attribution_domains, with: ->(arr) { arr.filter_map { |str| str.to_s.strip.delete_prefix('http://').delete_prefix('https://').delete_prefix('*.').presence }.uniq }
|
||||
|
||||
validates :attribution_domains, domain: true, length: { maximum: 100 }, if: -> { local? && will_save_change_to_attribution_domains? }
|
||||
validates :attribution_domains, domain: true, length: { maximum: ATTRIBUTION_DOMAINS_LIMIT }, if: -> { local? && will_save_change_to_attribution_domains? }
|
||||
end
|
||||
|
||||
def can_be_attributed_from?(domain)
|
||||
|
||||
@@ -17,12 +17,14 @@ class CustomFilterStatus < ApplicationRecord
|
||||
belongs_to :custom_filter
|
||||
belongs_to :status
|
||||
|
||||
validates :status, uniqueness: { scope: :custom_filter }
|
||||
validate :validate_status_access
|
||||
validates :status_id, uniqueness: { scope: :custom_filter_id }
|
||||
validate :validate_status_access, if: [:custom_filter_account, :status]
|
||||
|
||||
delegate :account, to: :custom_filter, prefix: true, allow_nil: true
|
||||
|
||||
private
|
||||
|
||||
def validate_status_access
|
||||
errors.add(:status_id, :invalid) unless StatusPolicy.new(custom_filter.account, status).show?
|
||||
errors.add(:status_id, :invalid) unless StatusPolicy.new(custom_filter_account, status).show?
|
||||
end
|
||||
end
|
||||
@@ -14,7 +14,7 @@ class FollowRecommendationMute < ApplicationRecord
|
||||
belongs_to :account
|
||||
belongs_to :target_account, class_name: 'Account'
|
||||
|
||||
validates :target_account, uniqueness: { scope: :account_id }
|
||||
validates :target_account_id, uniqueness: { scope: :account_id }
|
||||
|
||||
after_commit :invalidate_follow_recommendations_cache
|
||||
|
||||
|
||||
+5
-1
@@ -31,7 +31,7 @@ class Quote < ApplicationRecord
|
||||
belongs_to :quoted_account, class_name: 'Account', optional: true
|
||||
|
||||
before_validation :set_accounts
|
||||
|
||||
before_validation :set_activity_uri, only: :create, if: -> { account.local? && quoted_account&.remote? }
|
||||
validates :activity_uri, presence: true, if: -> { account.local? && quoted_account&.remote? }
|
||||
validate :validate_visibility
|
||||
|
||||
@@ -69,4 +69,8 @@ class Quote < ApplicationRecord
|
||||
|
||||
errors.add(:quoted_status_id, :visibility_mismatch)
|
||||
end
|
||||
|
||||
def set_activity_uri
|
||||
self.activity_uri = [ActivityPub::TagManager.instance.uri_for(account), '/quote_requests/', SecureRandom.uuid].join
|
||||
end
|
||||
end
|
||||
@@ -90,6 +90,7 @@ class User < ApplicationRecord
|
||||
has_many :applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: nil
|
||||
has_many :backups, inverse_of: :user, dependent: nil
|
||||
has_many :invites, inverse_of: :user, dependent: nil
|
||||
has_many :login_activities, inverse_of: :user, dependent: :destroy
|
||||
has_many :markers, inverse_of: :user, dependent: :destroy
|
||||
has_many :webauthn_credentials, dependent: :destroy
|
||||
has_many :ips, class_name: 'UserIp', inverse_of: :user, dependent: nil
|
||||
|
||||
Reference in new issue
Block a user