changeset 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
parents 7a5ca4b285cb
children d90ce7dc3f88
files mod_cloud_notify_encrypted/mod_cloud_notify_encrypted.lua
diffstat 1 files changed, 4 insertions(+), 9 deletions(-) [+]
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);