Changeset

6157:ddb0fac151ac

mod_anti_spam: Don't consider pre-approved contacts as strangers Also fixes a traceback introduced in the previous commit.
author Matthew Wild <mwild1@gmail.com>
date Fri, 17 Jan 2025 11:19:05 +0000
parents 6156:bcad6baa4fc3
children 6158:73c523248558
files mod_anti_spam/mod_anti_spam.lua
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mod_anti_spam/mod_anti_spam.lua	Fri Jan 17 10:20:00 2025 +0100
+++ b/mod_anti_spam/mod_anti_spam.lua	Fri Jan 17 11:19:05 2025 +0000
@@ -4,8 +4,7 @@
 local set = require "util.set";
 local sha256 = require "util.hashes".sha256;
 local st = require"util.stanza";
-local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
-local is_user_subscribed = require "core.rostermanager".is_user_subscribed;
+local rm = require "core.rostermanager";
 local full_sessions = prosody.full_sessions;
 
 local user_exists = require "core.usermanager".user_exists;
@@ -69,9 +68,10 @@
 	if to_session then return false; end
 
 	if not (
-		is_contact_subscribed(to_user, to_host, from_jid) or
-		is_user_subscribed(to_user, to_host, from_jid) or
-		is_contact_pending_out(to_user, to_host, from_jid)
+		rm.is_contact_subscribed(to_user, to_host, from_jid) or
+		rm.is_user_subscribed(to_user, to_host, from_jid) or
+		rm.is_contact_pending_out(to_user, to_host, from_jid) or
+		rm.is_contact_preapproved(to_user, to_host, from_jid)
 	) then
 		local from_user, from_host = jid_split(from_jid);
 
@@ -82,7 +82,7 @@
 		if to_resource and stanza.attr.type == "groupchat" then
 			return false; -- Pass through group chat messages
 		end
-		if is_contact_subscribed(to_user, to_host, from_host) then
+		if rm.is_contact_subscribed(to_user, to_host, from_host) then
 			-- If you have the sending domain in your roster,
 			-- allow through (probably a gateway)
 			return false;