Diff

mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua @ 4333:97f369745ec7

mod_cloud_notify_encrypted: Use new direct access to notification element
author Matthew Wild <mwild1@gmail.com>
date Wed, 13 Jan 2021 15:01:59 +0000
parent 4331:2e355540f8c8
child 4373:41ac0941b217
line wrap: on
line diff
--- a/mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua	Wed Jan 13 15:00:41 2021 +0000
+++ b/mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua	Wed Jan 13 15:01:59 2021 +0000
@@ -94,15 +94,10 @@
 	local encrypted_payload = base64.encode(ciphers.new("AES-128-GCM"):encrypt(key_binary, iv):final(push_json)..string.rep("\0", 16));
 	local encrypted_element = st.stanza("encrypted", { xmlns = xmlns_push_encrypt, iv = base64.encode(iv) })
 		:text(encrypted_payload);
-	-- Replace the unencrypted notification with the encrypted one
-	event.notification_stanza
-		:get_child("pubsub", "http://jabber.org/protocol/pubsub")
-		:get_child("publish")
-		:get_child("item")
-		:remove_children("notification", xmlns_push)
-		:tag("notification", { xmlns = xmlns_push })
-			:add_child(encrypted_element)
-			:up();
+	-- Replace the unencrypted notification data with the encrypted one
+	event.notification_payload
+		:remove_children("x", "jabber:x:data")
+		:add_child(encrypted_element);
 end
 
 module:hook("cloud_notify/registration", handle_register);