mod_mam: Reduce line count using new util.stanza attr method
authorKim Alvefur <zash@zash.se>
Sun, 12 Sep 2021 20:17:26 +0200
changeset 11799 41af102c7190
parent 11798 5d925f340ae6
child 11800 71c20650a0b4
mod_mam: Reduce line count using new util.stanza attr method Since this stanza-id was generated elsewhere in mod_mam, there should be no need for normalization.
plugins/mod_mam/mod_mam.lua
--- a/plugins/mod_mam/mod_mam.lua	Sun Sep 12 17:03:02 2021 +0200
+++ b/plugins/mod_mam/mod_mam.lua	Sun Sep 12 20:17:26 2021 +0200
@@ -481,10 +481,8 @@
 module:hook("message/offline/handle", function(event)
 	local stanza = event.stanza;
 	local user = event.username .. "@" .. host;
-	for st_id in stanza:childtags("stanza-id", xmlns_st_id) do
-		if st_id.attr.by == user then
-			return true;
-		end
+	if stanza:get_child_with_attr("stanza-id", xmlns_st_id, "by", user) then
+		return true;
 	end
 end, -2);