FIX: Automatically add .encrypted to authorized extensions

FIX: Automatically add .encrypted to authorized extensions

For each authorized extension, it adds another one that ends in .encrypted.

diff --git a/lib/site_setting_extensions.rb b/lib/site_setting_extensions.rb
new file mode 100644
index 0000000..1d2fb0f
--- /dev/null
+++ b/lib/site_setting_extensions.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module SiteSettingExtensions
+  def authorized_extensions
+    original_extensions = super
+
+    if extensions = original_extensions.split("|")
+      if !extensions.include?("*")
+        extensions.reject! { |ext| ext.ends_with?(".encrypted") }
+        extensions += extensions.map { |ext| "#{ext}.encrypted" }
+
+        return extensions.uniq.join("|")
+      end
+    end
+
+    original_extensions
+  end
+
+  def authorized_extensions=(extensions)
+    extensions = extensions
+      .split("|")
+      .reject { |ext| ext.ends_with?(".encrypted") }
+      .join("|")
+
+    super(extensions)
+  end
+end
diff --git a/plugin.rb b/plugin.rb
index d018a4c..b05aeee 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -31,6 +31,7 @@ after_initialize do
   load File.expand_path('../lib/user_extensions.rb', __FILE__)
   load File.expand_path('../lib/email_sender_extensions.rb', __FILE__)
   load File.expand_path('../app/mailers/user_notifications_extensions.rb', __FILE__)
+  load File.expand_path('../lib/site_setting_extensions.rb', __FILE__)
 
   class DiscourseEncrypt::Engine < Rails::Engine
     engine_name DiscourseEncrypt::PLUGIN_NAME
@@ -56,6 +57,8 @@ after_initialize do
     User.class_eval              { prepend UserExtensions }
     Email::Sender.class_eval     { prepend EmailSenderExtensions }
     UserNotifications.class_eval { prepend UserNotificationsExtensions }
+
+    SiteSetting.singleton_class.prepend SiteSettingExtensions
   end
 
   # Send plugin-specific topic data to client via serializers.

GitHub sha: 7ad7dec8

Should we check whether the plugin is enabled here?