Revert "FIX: When encrypt is enabled, secure message by default (#6)"

Revert “FIX: When encrypt is enabled, secure message by default (#6)”

This reverts commit 407bf155f63cffdf9f2f16c2191e90bf52501e4b.

We noticed drafts were being encrypted incorrectly.

diff --git a/assets/javascripts/discourse/initializers/hook-composer.js.es6 b/assets/javascripts/discourse/initializers/hook-composer.js.es6
index dd41453..070e960 100644
--- a/assets/javascripts/discourse/initializers/hook-composer.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-composer.js.es6
@@ -28,12 +28,12 @@ export default {
 
     // Check recipients and show encryption status in composer.
     Composer.reopen({
-      updateEncryptProperties({ newMessage }) {
+      updateEncryptProperties() {
         const encryptedTopic = this.topic && this.topic.encrypted_title;
         const canEncryptTopic = this.topic && hasTopicKey(this.topic.id);
         this.setProperties({
           /** @var Whether the current message is going to be encrypted. */
-          isEncrypted: (encryptedTopic && canEncryptTopic) || newMessage,
+          isEncrypted: encryptedTopic && canEncryptTopic,
           /** @var Disable encrypt indicator to enforce encrypted message, if
                    message is encrypted, or enforce decrypted message if one
                    of the recipients does not have encryption enabled. */
@@ -47,17 +47,17 @@ export default {
 
       @on("init")
       initEncrypt() {
-        this.updateEncryptProperties({ newMessage: true });
+        this.updateEncryptProperties();
       },
 
       @observes("creatingPrivateMessage", "topic")
       updateComposerEncrypt() {
-        this.updateEncryptProperties({ newMessage: false });
+        this.updateEncryptProperties();
       },
 
-      @observes("targetRecipients")
+      @observes("targetUsernames")
       checkKeys() {
-        if (!this.targetRecipients) {
+        if (!this.targetUsernames) {
           this.setProperties({
             isEncrypted: true,
             disableEncryptIndicator: false,
@@ -66,7 +66,7 @@ export default {
           return;
         }
 
-        const usernames = this.targetRecipients.split(",");
+        const usernames = this.targetUsernames.split(",");
         usernames.push(this.user.username);
 
         const groupNames = new Set(this.site.groups.map(g => g.name));
diff --git a/test/javascripts/acceptance/encrypt-test.js.es6 b/test/javascripts/acceptance/encrypt-test.js.es6
index 99a81b9..fcd7fc9 100644
--- a/test/javascripts/acceptance/encrypt-test.js.es6
+++ b/test/javascripts/acceptance/encrypt-test.js.es6
@@ -233,6 +233,7 @@ test("posting does not leak plaintext", async assert => {
   await click("#create-topic");
   await composerActions.expand();
   await composerActions.selectRowByValue("reply_as_private_message");
+  await click(".reply-details a");
   await fillIn("#private-message-users", "admin");
   await keyEvent("#private-message-users", "keydown", 8);
   await keyEvent("#private-message-users", "keydown", 13);

GitHub sha: a9327775

Was properly fixed in FIX: When encrypt is enabled, secure message by default (#7) · discourse/discourse-encrypt@029ef4a · GitHub.