FIX: Filter irrelevant fields in draft.

FIX: Filter irrelevant fields in draft.

diff --git a/assets/javascripts/discourse/initializers/hook-draft.js.es6 b/assets/javascripts/discourse/initializers/hook-draft.js.es6
index f304e93..93763a8 100644
--- a/assets/javascripts/discourse/initializers/hook-draft.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-draft.js.es6
@@ -7,6 +7,21 @@ import {
   ENCRYPT_ACTIVE
 } from "discourse/plugins/discourse-encrypt/lib/discourse";
 import { rsaEncrypt } from "discourse/plugins/discourse-encrypt/lib/keys";
+import { filterObjectKeys } from "discourse/plugins/discourse-encrypt/lib/utils";
+
+const ALLOWED_DRAFT_FIELDS = [
+  "action",
+  "archetypeId",
+  "categoryId",
+  "composerTime",
+  "noBump",
+  "postId",
+  "reply", // will be encrypted
+  "tags",
+  "title", // will be encrypted
+  "usernames",
+  "whisper"
+];
 
 export default {
   name: "hook-draft",
@@ -32,6 +47,8 @@ export default {
         }
 
         if (encrypted) {
+          data = filterObjectKeys(data, ALLOWED_DRAFT_FIELDS);
+
           const pk = getPublicKey();
           encTitle = data.title && pk.then(key => rsaEncrypt(key, data.title));
           encReply = data.reply && pk.then(key => rsaEncrypt(key, data.reply));
@@ -40,7 +57,7 @@ export default {
             ([title, reply]) => {
               data.title = title;
               data.reply = reply;
-              return _super.call(this, ...arguments);
+              return _super.call(this, draftKey, sequence, data);
             }
           );
         }
diff --git a/assets/javascripts/lib/utils.js.es6 b/assets/javascripts/lib/utils.js.es6
new file mode 100644
index 0000000..e8b9c46
--- /dev/null
+++ b/assets/javascripts/lib/utils.js.es6
@@ -0,0 +1,11 @@
+export function filterObjectKeys(obj, keys) {
+  const newObj = {};
+
+  keys.forEach(key => {
+    if (key in obj) {
+      newObj[key] = obj[key];
+    }
+  });
+
+  return newObj;
+}

GitHub sha: 36a94514