Add `CustomEmoji.enabled` scope (#31830)
This commit is contained in:
		
							parent
							
								
									e0c27a5047
								
							
						
					
					
						commit
						da07adfe6c
					
				| 
						 | 
					@ -27,7 +27,7 @@ class EntityCache
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unless uncached_ids.empty?
 | 
					    unless uncached_ids.empty?
 | 
				
			||||||
      uncached = CustomEmoji.where(shortcode: shortcodes, domain: domain, disabled: false).index_by(&:shortcode)
 | 
					      uncached = CustomEmoji.enabled.where(shortcode: shortcodes, domain: domain).index_by(&:shortcode)
 | 
				
			||||||
      uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
 | 
					      uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@ class AnnouncementReaction < ApplicationRecord
 | 
				
			||||||
  private
 | 
					  private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def set_custom_emoji
 | 
					  def set_custom_emoji
 | 
				
			||||||
    self.custom_emoji = CustomEmoji.local.find_by(disabled: false, shortcode: name) if name.present?
 | 
					    self.custom_emoji = CustomEmoji.local.enabled.find_by(shortcode: name) if name.present?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def queue_publish
 | 
					  def queue_publish
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,9 +48,10 @@ class CustomEmoji < ApplicationRecord
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  scope :local, -> { where(domain: nil) }
 | 
					  scope :local, -> { where(domain: nil) }
 | 
				
			||||||
  scope :remote, -> { where.not(domain: nil) }
 | 
					  scope :remote, -> { where.not(domain: nil) }
 | 
				
			||||||
 | 
					  scope :enabled, -> { where(disabled: false) }
 | 
				
			||||||
  scope :alphabetic, -> { order(domain: :asc, shortcode: :asc) }
 | 
					  scope :alphabetic, -> { order(domain: :asc, shortcode: :asc) }
 | 
				
			||||||
  scope :by_domain_and_subdomains, ->(domain) { where(domain: domain).or(where(arel_table[:domain].matches("%.#{domain}"))) }
 | 
					  scope :by_domain_and_subdomains, ->(domain) { where(domain: domain).or(where(arel_table[:domain].matches("%.#{domain}"))) }
 | 
				
			||||||
  scope :listed, -> { local.where(disabled: false).where(visible_in_picker: true) }
 | 
					  scope :listed, -> { local.enabled.where(visible_in_picker: true) }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  remotable_attachment :image, LIMIT
 | 
					  remotable_attachment :image, LIMIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue