Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/services/resolve_url_service.rb`: The private toot search by URL hack has been revamped upstream. Took upstream's version.
This commit is contained in:
@ -104,6 +104,7 @@ class Account < ApplicationRecord
|
||||
scope :sensitized, -> { where.not(sensitized_at: nil) }
|
||||
scope :without_suspended, -> { where(suspended_at: nil) }
|
||||
scope :without_silenced, -> { where(silenced_at: nil) }
|
||||
scope :without_instance_actor, -> { where.not(id: -99) }
|
||||
scope :recent, -> { reorder(id: :desc) }
|
||||
scope :bots, -> { where(actor_type: %w(Application Service)) }
|
||||
scope :groups, -> { where(actor_type: 'Group') }
|
||||
@ -226,7 +227,7 @@ class Account < ApplicationRecord
|
||||
end
|
||||
|
||||
def suspended?
|
||||
suspended_at.present?
|
||||
suspended_at.present? && !instance_actor?
|
||||
end
|
||||
|
||||
def suspended_permanently?
|
||||
|
@ -45,7 +45,7 @@ class AccountFilter
|
||||
def scope_for(key, value)
|
||||
case key.to_s
|
||||
when 'local'
|
||||
Account.local
|
||||
Account.local.without_instance_actor
|
||||
when 'remote'
|
||||
Account.remote
|
||||
when 'by_domain'
|
||||
|
@ -12,6 +12,7 @@
|
||||
# reject_reports :boolean default(FALSE), not null
|
||||
# private_comment :text
|
||||
# public_comment :text
|
||||
# obfuscate :boolean default(FALSE), not null
|
||||
#
|
||||
|
||||
class DomainBlock < ApplicationRecord
|
||||
@ -73,4 +74,23 @@ class DomainBlock < ApplicationRecord
|
||||
scope = suspend? ? accounts.where(suspended_at: created_at) : accounts.where(silenced_at: created_at)
|
||||
scope.count
|
||||
end
|
||||
|
||||
def public_domain
|
||||
return domain unless obfuscate?
|
||||
|
||||
length = domain.size
|
||||
visible_ratio = length / 4
|
||||
|
||||
domain.chars.map.with_index do |chr, i|
|
||||
if i > visible_ratio && i < length - visible_ratio && chr != '.'
|
||||
'*'
|
||||
else
|
||||
chr
|
||||
end
|
||||
end.join
|
||||
end
|
||||
|
||||
def domain_digest
|
||||
Digest::SHA256.hexdigest(domain)
|
||||
end
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ class Follow < ApplicationRecord
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
validates_with FollowLimitValidator, on: :create
|
||||
validates_with FollowLimitValidator, on: :create, if: :rate_limit?
|
||||
|
||||
scope :recent, -> { reorder(id: :desc) }
|
||||
|
||||
|
@ -26,7 +26,7 @@ class FollowRequest < ApplicationRecord
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
validates_with FollowLimitValidator, on: :create
|
||||
validates_with FollowLimitValidator, on: :create, if: :rate_limit?
|
||||
|
||||
def authorize!
|
||||
account.follow!(target_account, reblogs: show_reblogs, notify: notify, uri: uri)
|
||||
|
@ -27,6 +27,7 @@ class Import < ApplicationRecord
|
||||
enum type: [:following, :blocking, :muting, :domain_blocking, :bookmarks]
|
||||
|
||||
validates :type, presence: true
|
||||
validates_with ImportValidator, on: :create
|
||||
|
||||
has_attached_file :data
|
||||
validates_attachment_content_type :data, content_type: FILE_TYPES
|
||||
|
Reference in New Issue
Block a user