25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Add new option: store_empty_body

This commit is contained in:
Evgeniy Khramtsov 2014-10-27 14:14:52 +03:00
parent 067958d705
commit 74b67fa0dc
2 changed files with 21 additions and 4 deletions

View File

@ -3819,6 +3819,8 @@ online again. Thus it is very similar to how email works. Note that
The default value is \term{max\_user\_offline\_messages}. The default value is \term{max\_user\_offline\_messages}.
Then you can define an access rule with a syntax similar to Then you can define an access rule with a syntax similar to
\term{max\_user\_sessions} (see \ref{configmaxsessions}). \term{max\_user\_sessions} (see \ref{configmaxsessions}).
\titem{store\_empty\_body: true|false}\ind{options!store\_empty\_body} Whether or not
to store messages with empty \term{<body/>} element. The default value is \term{true}.
\end{description} \end{description}
This example allows power users to have as much as 5000 offline messages, This example allows power users to have as much as 5000 offline messages,

View File

@ -293,11 +293,26 @@ get_sm_features(_Acc, _From, _To, ?NS_FEATURE_MSGOFFLINE, _Lang) ->
get_sm_features(Acc, _From, _To, _Node, _Lang) -> get_sm_features(Acc, _From, _To, _Node, _Lang) ->
Acc. Acc.
need_to_store(LServer, Packet) ->
store_packet(From, To, Packet) ->
Type = xml:get_tag_attr_s(<<"type">>, Packet), Type = xml:get_tag_attr_s(<<"type">>, Packet),
if (Type /= <<"error">>) and (Type /= <<"groupchat">>) if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
and (Type /= <<"headline">>) -> and (Type /= <<"headline">>) ->
case gen_mod:get_module_opt(
LServer, ?MODULE, store_empty_body,
fun(V) when is_boolean(V) -> V end,
true) of
false ->
xml:get_subtag(Packet, <<"body">>) /= false;
true ->
true
end;
true ->
false
end.
store_packet(From, To, Packet) ->
case need_to_store(To#jid.lserver, Packet) of
true ->
case has_no_storage_hint(Packet) of case has_no_storage_hint(Packet) of
false -> false ->
case check_event(From, To, Packet) of case check_event(From, To, Packet) of
@ -315,7 +330,7 @@ store_packet(From, To, Packet) ->
end; end;
_ -> ok _ -> ok
end; end;
true -> ok false -> ok
end. end.
has_no_storage_hint(Packet) -> has_no_storage_hint(Packet) ->