about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-08-24 13:34:51 +0200
committerThibaut Girka <thib@sitedethib.com>2018-08-24 15:10:34 +0200
commit246c313d457397f412f9fb5eed3ee02cf5d9a561 (patch)
tree4c8d12cc031476870a918bec3b3000f899101a32 /app/lib
parent0ddf439999b05b5dfd6d5a5257327fa7d3565e65 (diff)
parenta2cabf3f4af9271d8bfdb13c1ae2b7a8b4e6fb88 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
	app/controllers/application_controller.rb

Changed instance theme selection by instance flavour selection.
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/activitypub/activity/create.rb2
-rw-r--r--app/lib/settings/scoped_settings.rb16
2 files changed, 15 insertions, 3 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index 00479fd9a..79efc95d3 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -107,7 +107,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     updated   = tag['updated']
     emoji     = CustomEmoji.find_by(shortcode: shortcode, domain: @account.domain)
 
-    return unless emoji.nil? || emoji.updated_at >= updated
+    return unless emoji.nil? || image_url != emoji.image_remote_url || (updated && emoji.updated_at >= updated)
 
     emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: shortcode, uri: uri)
     emoji.image_remote_url = image_url
diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb
index de4af3009..70de7b792 100644
--- a/app/lib/settings/scoped_settings.rb
+++ b/app/lib/settings/scoped_settings.rb
@@ -2,6 +2,11 @@
 
 module Settings
   class ScopedSettings
+    DEFAULTING_TO_UNSCOPED = %w(
+      flavour
+      skin
+    ).freeze
+
     def initialize(object)
       @object = object
     end
@@ -50,15 +55,22 @@ module Settings
       Rails.cache.fetch(Setting.cache_key(key, @object)) do
         db_val = thing_scoped.find_by(var: key.to_s)
         if db_val
-          default_value = Setting.default_settings[key]
+          default_value = ScopedSettings.default_settings[key]
           return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
           db_val.value
         else
-          Setting.default_settings[key]
+          ScopedSettings.default_settings[key]
         end
       end
     end
 
+    class << self
+      def default_settings
+        defaulting = DEFAULTING_TO_UNSCOPED.map { |k| [k, Setting[k]] }.to_h
+        Setting.default_settings.merge!(defaulting)
+      end
+    end
+
     protected
 
     def thing_scoped