FIX: Warn users that uploads are not encrypted.

FIX: Warn users that uploads are not encrypted.

diff --git a/assets/javascripts/discourse/initializers/hook-uploads.js.es6 b/assets/javascripts/discourse/initializers/hook-uploads.js.es6
new file mode 100644
index 0000000..b8fa5d0
--- /dev/null
+++ b/assets/javascripts/discourse/initializers/hook-uploads.js.es6
@@ -0,0 +1,23 @@
+import { withPluginApi } from "discourse/lib/plugin-api";
+
+export default {
+  name: "hook-uploads",
+
+  initialize(container) {
+    const siteSettings = container.lookup("site-settings:main");
+    if (!siteSettings.encrypt_enabled) {
+      return;
+    }
+
+    withPluginApi("0.8.27", api => {
+      api.addComposerUploadHandler([".*"], () => {
+        const controller = container.lookup("controller:composer");
+        if (controller.get("model.isEncrypted")) {
+          bootbox.alert(I18n.t("encrypt.encrypted_uploads"));
+          return false;
+        }
+        return true;
+      });
+    });
+  }
+};
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 132dfa0..c346bb5 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -8,6 +8,8 @@ en:
       encrypted_topic_title: "A secret message"
       encrypted_icon_title: "This message is end-to-end encrypted."
 
+      encrypted_uploads: "Uploads cannot be encrypted at this time."
+
       checkbox:
         checked: "This message will be end-to-end encrypted."
         unchecked: "Click the lock symbol to encrypt this message."

GitHub sha: 0cd30eea