Merge branch 'master' into glitch-soc/merge-upstream
This commit is contained in:
@@ -508,7 +508,7 @@ class Account < ApplicationRecord
|
||||
end
|
||||
|
||||
def emojifiable_text
|
||||
[note, display_name, fields.map(&:value)].join(' ')
|
||||
[note, display_name, fields.map(&:name), fields.map(&:value)].join(' ')
|
||||
end
|
||||
|
||||
def clean_feed_manager
|
||||
|
@@ -15,7 +15,7 @@ class AccountDomainBlock < ApplicationRecord
|
||||
include DomainNormalizable
|
||||
|
||||
belongs_to :account
|
||||
validates :domain, presence: true, uniqueness: { scope: :account_id }
|
||||
validates :domain, presence: true, uniqueness: { scope: :account_id }, domain: true
|
||||
|
||||
after_commit :remove_blocking_cache
|
||||
after_commit :remove_relationship_cache
|
||||
|
@@ -4,7 +4,7 @@ module DomainNormalizable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_validation :normalize_domain
|
||||
before_save :normalize_domain
|
||||
end
|
||||
|
||||
private
|
||||
|
@@ -28,6 +28,8 @@ class CustomEmoji < ApplicationRecord
|
||||
:(#{SHORTCODE_RE_FRAGMENT}):
|
||||
(?=[^[:alnum:]:]|$)/x
|
||||
|
||||
IMAGE_MIME_TYPES = %w(image/png image/gif image/webp).freeze
|
||||
|
||||
belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
|
||||
has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode
|
||||
|
||||
@@ -35,7 +37,7 @@ class CustomEmoji < ApplicationRecord
|
||||
|
||||
before_validation :downcase_domain
|
||||
|
||||
validates_attachment :image, content_type: { content_type: 'image/png' }, presence: true, size: { less_than: LIMIT }
|
||||
validates_attachment :image, content_type: { content_type: IMAGE_MIME_TYPES }, presence: true, size: { less_than: LIMIT }
|
||||
validates :shortcode, uniqueness: { scope: :domain }, format: { with: /\A#{SHORTCODE_RE_FRAGMENT}\z/ }, length: { minimum: 2 }
|
||||
|
||||
scope :local, -> { where(domain: nil) }
|
||||
|
@@ -13,7 +13,7 @@
|
||||
class DomainAllow < ApplicationRecord
|
||||
include DomainNormalizable
|
||||
|
||||
validates :domain, presence: true, uniqueness: true
|
||||
validates :domain, presence: true, uniqueness: true, domain: true
|
||||
|
||||
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
|
||||
|
||||
|
@@ -19,7 +19,7 @@ class DomainBlock < ApplicationRecord
|
||||
|
||||
enum severity: [:silence, :suspend, :noop]
|
||||
|
||||
validates :domain, presence: true, uniqueness: true
|
||||
validates :domain, presence: true, uniqueness: true, domain: true
|
||||
|
||||
has_many :accounts, foreign_key: :domain, primary_key: :domain
|
||||
delegate :count, to: :accounts, prefix: true
|
||||
|
@@ -12,7 +12,7 @@
|
||||
class EmailDomainBlock < ApplicationRecord
|
||||
include DomainNormalizable
|
||||
|
||||
validates :domain, presence: true, uniqueness: true
|
||||
validates :domain, presence: true, uniqueness: true, domain: true
|
||||
|
||||
def self.block?(email)
|
||||
_, domain = email.split('@', 2)
|
||||
|
@@ -6,6 +6,7 @@ class TrendingTags
|
||||
EXPIRE_TRENDS_AFTER = 1.day.seconds
|
||||
THRESHOLD = 5
|
||||
LIMIT = 10
|
||||
REVIEW_THRESHOLD = 3
|
||||
|
||||
class << self
|
||||
include Redisable
|
||||
@@ -60,7 +61,7 @@ class TrendingTags
|
||||
old_rank = redis.zrevrank(key, tag.id)
|
||||
|
||||
redis.zadd(key, score, tag.id)
|
||||
request_review!(tag) if (old_rank.nil? || old_rank > LIMIT) && redis.zrevrank(key, tag.id) <= LIMIT && !tag.trendable? && tag.requires_review? && !tag.requested_review?
|
||||
request_review!(tag) if (old_rank.nil? || old_rank > REVIEW_THRESHOLD) && redis.zrevrank(key, tag.id) <= REVIEW_THRESHOLD && !tag.trendable? && tag.requires_review? && !tag.requested_review?
|
||||
end
|
||||
|
||||
redis.expire(key, EXPIRE_TRENDS_AFTER)
|
||||
|
Reference in New Issue
Block a user