mod_spam_filter: Check recipient's domain

Don't crash if the module isn't loaded for the 'to' domain.  This would
otherwise happen for stanzas sent to subdomains (e.g., MUC messages).

Thanks to Nico Wellpott for reporting the bug and testing the fix.
This commit is contained in:
Holger Weiss 2019-04-09 01:21:55 +02:00
parent 83117240d2
commit 8f63b2cbae
1 changed files with 14 additions and 8 deletions

View File

@ -293,14 +293,20 @@ s2s_in_handle_info(State, _) ->
%%--------------------------------------------------------------------
-spec needs_checking(jid(), jid()) -> boolean().
needs_checking(From, #jid{lserver = LServer} = To) ->
Access = gen_mod:get_module_opt(LServer, ?MODULE, access_spam),
case acl:match_rule(LServer, Access, To) of
allow ->
?DEBUG("Spam not filtered for ~s", [jid:encode(To)]),
false;
deny ->
?DEBUG("Spam is filtered for ~s", [jid:encode(To)]),
not mod_roster:is_subscribed(From, To)
case gen_mod:is_loaded(LServer, ?MODULE) of
true ->
Access = gen_mod:get_module_opt(LServer, ?MODULE, access_spam),
case acl:match_rule(LServer, Access, To) of
allow ->
?DEBUG("Spam not filtered for ~s", [jid:encode(To)]),
false;
deny ->
?DEBUG("Spam is filtered for ~s", [jid:encode(To)]),
not mod_roster:is_subscribed(From, To)
end;
false ->
?DEBUG("~s not loaded for ~s", [?MODULE, LServer]),
false
end.
-spec check_from(binary(), jid()) -> ham | spam.