From b34f77d3c88c86250be9cb87d77febb79b7f5da2 Mon Sep 17 00:00:00 2001 From: Stefan Strigler Date: Wed, 8 Jan 2025 15:02:48 +0100 Subject: [PATCH] fix returned tuple from s2s_receive_packet handler If we return {{stop, drop}, State} we don't correctly stop the hook handler. Instead `stop` must be isolated and the returned value must be `{drop, State}`. --- mod_spam_filter/src/mod_spam_filter.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mod_spam_filter/src/mod_spam_filter.erl b/mod_spam_filter/src/mod_spam_filter.erl index 00b2dc6f..1542c219 100644 --- a/mod_spam_filter/src/mod_spam_filter.erl +++ b/mod_spam_filter/src/mod_spam_filter.erl @@ -286,9 +286,14 @@ code_change(_OldVsn, #state{host = Host} = State, _Extra) -> %% Hook callbacks. %%-------------------------------------------------------------------- -spec s2s_receive_packet({stanza() | drop, s2s_in_state()}) - -> {stanza() | drop | {stop, drop}, s2s_in_state()}. + -> {stanza() | drop, s2s_in_state()} | {stop, {drop, s2s_in_state()}}. s2s_receive_packet({A, State}) -> - {sm_receive_packet(A), State}. + case sm_receive_packet(A) of + {stop, drop} -> + {stop, {drop, State}}; + Result -> + {Result, State} + end. -spec sm_receive_packet(stanza() | drop) -> stanza() | drop | {stop, drop}. sm_receive_packet(drop = Acc) ->