diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 4cb5f409014..8fed00c00bb 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1651,6 +1651,9 @@ send_element_from_server_jid(Acc, StateData, #xmlel{} = El) -> %% @doc This is the termination point - from here stanza is sent to the user -spec send_element(mongoose_acc:t(), exml:element(), state()) -> mongoose_acc:t(). +send_element(Acc, El, #state{host_type = undefined} = StateData) -> + Res = do_send_element(El, StateData), + mongoose_acc:set(c2s, send_result, Res, Acc); send_element(Acc, El, #state{host_type = HostType} = StateData) -> Acc1 = mongoose_hooks:xmpp_send_element(HostType, Acc, El), Res = do_send_element(El, StateData), diff --git a/test/ejabberd_c2s_SUITE.erl b/test/ejabberd_c2s_SUITE.erl index 45e8032f5b7..e7d7e4aba0d 100644 --- a/test/ejabberd_c2s_SUITE.erl +++ b/test/ejabberd_c2s_SUITE.erl @@ -44,10 +44,14 @@ c2s_start_stop_test(_) -> stream_error_when_invalid_domain(_) -> + ok = meck:new(mongoose_hooks, [passthrough]), {ok, C2SPid} = given_c2s_started(), C2Sactions = when_stream_is_opened(C2SPid, stream_header(<<"badhost">>)), [StreamStart, StreamError, StreamEnd, CloseSocket] = C2Sactions, + History = meck:history(mongoose_hooks), + HookRes = [ok || {_, {mongoose_hooks, xmpp_send_element, [undefined, #{host_type := undefined} | _]}, _} <- History], + ?am([], HookRes), ?am({send, [_P, <<"", "