changeset 2276:1b12ccbbd9b2

mod_spam_reporting: Continue looking for spam reports even when one <item> does not have one
author Kim Alvefur <zash@zash.se>
date Sat, 20 Aug 2016 17:15:14 +0200
parents 7f228bf82fe5
children bad5dd466427
files mod_spam_reporting/mod_spam_reporting.lua
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mod_spam_reporting/mod_spam_reporting.lua	Sat Aug 20 17:13:43 2016 +0200
+++ b/mod_spam_reporting/mod_spam_reporting.lua	Sat Aug 20 17:15:14 2016 +0200
@@ -10,11 +10,12 @@
 	for item in event.stanza.tags[1]:childtags("item") do
 		local report = item:get_child("report", "urn:xmpp:reporting:0");
 		local jid = item.attr.jid;
-		if not report or not jid then return end
-		local type = report:get_child("spam") and "spam" or
-			report:get_child("abuse") and "abuse" or
-			"unknown";
-		local reason = report:get_child_text("reason") or "no reason given";
-		module:log("warn", "Received report of %s from JID '%s', %s", type, jid, reason);
+		if report and jid then
+			local type = report:get_child("spam") and "spam" or
+				report:get_child("abuse") and "abuse" or
+				"unknown";
+			local reason = report:get_child_text("reason") or "no reason given";
+			module:log("warn", "Received report of %s from JID '%s', %s", type, jid, reason);
+		end
 	end
 end, 1);