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:
parent
83117240d2
commit
8f63b2cbae
|
@ -293,6 +293,8 @@ s2s_in_handle_info(State, _) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-spec needs_checking(jid(), jid()) -> boolean().
|
-spec needs_checking(jid(), jid()) -> boolean().
|
||||||
needs_checking(From, #jid{lserver = LServer} = To) ->
|
needs_checking(From, #jid{lserver = LServer} = To) ->
|
||||||
|
case gen_mod:is_loaded(LServer, ?MODULE) of
|
||||||
|
true ->
|
||||||
Access = gen_mod:get_module_opt(LServer, ?MODULE, access_spam),
|
Access = gen_mod:get_module_opt(LServer, ?MODULE, access_spam),
|
||||||
case acl:match_rule(LServer, Access, To) of
|
case acl:match_rule(LServer, Access, To) of
|
||||||
allow ->
|
allow ->
|
||||||
|
@ -301,6 +303,10 @@ needs_checking(From, #jid{lserver = LServer} = To) ->
|
||||||
deny ->
|
deny ->
|
||||||
?DEBUG("Spam is filtered for ~s", [jid:encode(To)]),
|
?DEBUG("Spam is filtered for ~s", [jid:encode(To)]),
|
||||||
not mod_roster:is_subscribed(From, To)
|
not mod_roster:is_subscribed(From, To)
|
||||||
|
end;
|
||||||
|
false ->
|
||||||
|
?DEBUG("~s not loaded for ~s", [?MODULE, LServer]),
|
||||||
|
false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec check_from(binary(), jid()) -> ham | spam.
|
-spec check_from(binary(), jid()) -> ham | spam.
|
||||||
|
|
Loading…
Reference in New Issue