about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-12-16 15:26:50 +0100
committerGitHub <noreply@github.com>2018-12-16 15:26:50 +0100
commit396c5dea87f259255f3676bb7b30f5cfdfec9d4e (patch)
tree33c64f250983b0d8c07bad2a0ec970539e78b1d6 /app/models
parentf0505a5b2e727da73c8aa651b804508a8187a3c4 (diff)
parent7238e4ea5f4f619396f73009032844d95bdf809c (diff)
Merge pull request #856 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models')
-rw-r--r--app/models/custom_emoji.rb6
-rw-r--r--app/models/custom_emoji_filter.rb2
-rw-r--r--app/models/form/admin_settings.rb2
-rw-r--r--app/models/user.rb6
4 files changed, 14 insertions, 2 deletions
diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb
index b99ed01f0..d3cc70504 100644
--- a/app/models/custom_emoji.rb
+++ b/app/models/custom_emoji.rb
@@ -31,6 +31,8 @@ class CustomEmoji < ApplicationRecord
 
   has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce -strip' } }
 
+  before_validation :downcase_domain
+
   validates_attachment :image, content_type: { content_type: 'image/png' }, presence: true, size: { less_than: LIMIT }
   validates :shortcode, uniqueness: { scope: :domain }, format: { with: /\A#{SHORTCODE_RE_FRAGMENT}\z/ }, length: { minimum: 2 }
 
@@ -73,4 +75,8 @@ class CustomEmoji < ApplicationRecord
   def remove_entity_cache
     Rails.cache.delete(EntityCache.instance.to_key(:emoji, shortcode, domain))
   end
+
+  def downcase_domain
+    self.domain = domain.downcase unless domain.nil?
+  end
 end
diff --git a/app/models/custom_emoji_filter.rb b/app/models/custom_emoji_filter.rb
index c4bc310bb..7649055d2 100644
--- a/app/models/custom_emoji_filter.rb
+++ b/app/models/custom_emoji_filter.rb
@@ -26,7 +26,7 @@ class CustomEmojiFilter
     when 'remote'
       CustomEmoji.remote
     when 'by_domain'
-      CustomEmoji.where(domain: value)
+      CustomEmoji.where(domain: value.downcase)
     when 'shortcode'
       CustomEmoji.search(value)
     else
diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb
index 8a39e09b7..34c75e3bf 100644
--- a/app/models/form/admin_settings.rb
+++ b/app/models/form/admin_settings.rb
@@ -46,6 +46,8 @@ class Form::AdminSettings
     :preview_sensitive_media=,
     :custom_css,
     :custom_css=,
+    :profile_directory,
+    :profile_directory=,
     to: Setting
   )
 
diff --git a/app/models/user.rb b/app/models/user.rb
index 5a21419bf..66896257a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -73,7 +73,7 @@ class User < ApplicationRecord
 
   validates :locale, inclusion: I18n.available_locales.map(&:to_s), if: :locale?
   validates_with BlacklistedEmailValidator, if: :email_changed?
-  validates_with EmailMxValidator, if: :email_changed?
+  validates_with EmailMxValidator, if: :validate_email_dns?
 
   scope :recent, -> { order(id: :desc) }
   scope :admins, -> { where(admin: true) }
@@ -360,4 +360,8 @@ class User < ApplicationRecord
   def needs_feed_update?
     last_sign_in_at < ACTIVE_DURATION.ago
   end
+
+  def validate_email_dns?
+    email_changed? && !(Rails.env.test? || Rails.env.development?)
+  end
 end