Changeset

2142:d6fbb57a216c

mod_throttle_unsolicited: Skip checking messages to self
author Kim Alvefur <zash@zash.se>
date Wed, 30 Mar 2016 10:54:47 +0200
parents 2141:218a3d3f7f97
children 2143:7cab309a26b2
files mod_throttle_unsolicited/mod_throttle_unsolicited.lua
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_throttle_unsolicited/mod_throttle_unsolicited.lua	Tue Mar 29 19:47:08 2016 +0200
+++ b/mod_throttle_unsolicited/mod_throttle_unsolicited.lua	Wed Mar 30 10:54:47 2016 +0200
@@ -16,8 +16,14 @@
 	log("debug", "check_subscribed(%s)", stanza:top_tag());
 	if stanza.attr.type == "error" then return end
 
+	local to_orig = stanza.attr.to;
+	if to_orig == nil or to_orig == origin.full_jid then return end -- to self
+
+	local to_bare = jid_bare(to_orig);
+	local from_jid = jid_bare(stanza.attr.from);
+	if to_bare == from_jid then return end -- to own resource
+
 	-- Check if it's a message to a joined room
-	local to_bare = jid_bare(stanza.attr.to);
 	local rooms = origin.rooms_joined;
 	if rooms and rooms[to_bare] then
 		log("debug", "Message to joined room, no limit");
@@ -32,8 +38,7 @@
 		origin.throttle_unsolicited = lim;
 	end
 
-	local to_user, to_host = jid_split(stanza.attr.to);
-	local from_jid = jid_bare(stanza.attr.from);
+	local to_user, to_host = jid_split(to_orig);
 	if to_user and not is_contact_subscribed(to_user, to_host, from_jid) then
 		log("debug", "%s is not subscribed to %s@%s", from_jid, to_user, to_host);
 		if not lim:poll(1) then