FIX: Update to latest Composer API

FIX: Update to latest Composer API

diff --git a/assets/javascripts/discourse/initializers/hook-save.js.es6 b/assets/javascripts/discourse/initializers/hook-save.js.es6
index 1fef99c..3c16101 100644
--- a/assets/javascripts/discourse/initializers/hook-save.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-save.js.es6
@@ -113,8 +113,16 @@ export default {
           : Ember.RSVP.Promise.resolve();
 
         let encryptedKeysPromise = Ember.RSVP.Promise.resolve();
+
+        let usernames = [];
+        if (args.target_recipients) {
+          usernames = args.target_recipients.split(",");
+        }
         if (args.target_usernames) {
-          const usernames = args.target_usernames.split(",");
+          usernames = args.target_usernames.split(",");
+        }
+
+        if (usernames.length > 0) {
           usernames.push(User.current().username);
           const identitiesPromise = getUserIdentities(usernames);

GitHub sha: 92de4700

I still kind of want a followup here, we should have an integration test that catches this regression.

Also usernames.push(User.current().username); should this not be done unconditionally?

2 Likes

Another thought, we should probably reject stuff server side if someone tries to create an encrypted message with no keys, that protects us against future bugs cause the post would not save.

2 Likes