From 7fc500dae6c7c2c8db95e56607f179aa9f00dd9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Wed, 13 Jan 2021 20:57:03 +0100 Subject: Don't include empty in messages sent by send_message Please refer issue #3485 --- src/mod_admin_extra.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index a90a22ce..60d2686b 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -1494,10 +1494,15 @@ send_message(Type, From, To, Subject, Body) -> #xmlel{name = <<"body">>, children = [{xmlcdata, Body}]}]}, ?NS_CLIENT, CodecOpts) of - #message{from = JID} = Msg -> + #message{from = JID, subject = Subject, body = Body} = Msg -> + Msg2 = case {xmpp:get_text(Subject), xmpp:get_text(Body)} of + {_, <<>>} -> Msg; + {<<>>, _} -> Msg#message{subject = []}; + _ -> Msg + end, State = #{jid => JID}, - ejabberd_hooks:run_fold(user_send_packet, JID#jid.lserver, {Msg, State}, []), - ejabberd_router:route(Msg) + ejabberd_hooks:run_fold(user_send_packet, JID#jid.lserver, {Msg2, State}, []), + ejabberd_router:route(Msg2) catch _:{xmpp_codec, Why} -> {error, xmpp:format_error(Why)} end. -- cgit v1.2.3