FEATURE: Decrypt topic titles in notifications.

FEATURE: Decrypt topic titles in notifications.

diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
index 94c76be..322a704 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-topic.js.es6
@@ -52,11 +52,12 @@ function decryptElements(containerSelector, elementSelector) {
  * Decrypts all title elements.
  */
 export function decryptTitles() {
-  decryptElements("h1", ".fancy-title");
-  decryptElements(".topic-list-item, .latest-topic-list-item", ".title");
-  decryptElements("a.topic-link", "span");
-  decryptElements("a.topic-link");
-  decryptElements("a.raw-topic-link");
+  decryptElements("h1[data-topic-id]", ".fancy-title");
+  decryptElements(".topic-list-item[data-topic-id], .latest-topic-list-item[data-topic-id]", ".title");
+  decryptElements("a.topic-link[data-topic-id]", "span");
+  decryptElements("a.topic-link[data-topic-id]");
+  decryptElements("a.raw-topic-link[data-topic-id]");
+  decryptElements(".notifications span[data-topic-id]");
 }
 
 export default {
diff --git a/plugin.rb b/plugin.rb
index 7e01ec4..8735769 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -250,6 +250,14 @@ after_initialize do
     scope&.user.present? && object.private_message?
   end
 
+  add_to_serializer(:notification, :encrypted_title, false) do
+    object.topic.custom_fields['encrypted_title']
+  end
+
+  add_to_serializer(:notification, :include_encrypted_title?) do
+    scope&.user.present? && object.topic.private_message?
+  end
+
   # +topic_key+
   #
   # Topic's key encrypted with user's public key.
@@ -289,6 +297,14 @@ after_initialize do
     scope&.user.present? && object.private_message?
   end
 
+  add_to_serializer(:notification, :topic_key, false) do
+    DiscourseEncrypt::Store.get("key_#{object.topic.id}_#{scope.user.id}")
+  end
+
+  add_to_serializer(:notification, :include_topic_key?) do
+    scope&.user.present? && object.topic.private_message?
+  end
+
   DiscourseEncrypt::Engine.routes.draw do
     put  '/encrypt/keys'  => 'encrypt#update_keys'
     get  '/encrypt/user'  => 'encrypt#show_user'

GitHub sha: 83454ddc