summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2014-10-27 14:14:52 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2014-10-27 14:18:09 +0300
commit74b67fa0dcdcc9a609b9dd5f9b3baec18a7980e2 (patch)
treea3d859d8fdf2e39101ef3f359b9f01db110ae710
parentMerge branch 'master' of github.com:processone/ejabberd (diff)
Add new option: store_empty_body
-rw-r--r--doc/guide.tex2
-rw-r--r--src/mod_offline.erl23
2 files changed, 21 insertions, 4 deletions
diff --git a/doc/guide.tex b/doc/guide.tex
index efebc252..2c20df95 100644
--- a/doc/guide.tex
+++ b/doc/guide.tex
@@ -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}.
Then you can define an access rule with a syntax similar to
\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}
This example allows power users to have as much as 5000 offline messages,
diff --git a/src/mod_offline.erl b/src/mod_offline.erl
index bb488f8c..91d31a75 100644
--- a/src/mod_offline.erl
+++ b/src/mod_offline.erl
@@ -293,11 +293,26 @@ get_sm_features(_Acc, _From, _To, ?NS_FEATURE_MSGOFFLINE, _Lang) ->
get_sm_features(Acc, _From, _To, _Node, _Lang) ->
Acc.
-
-store_packet(From, To, Packet) ->
+need_to_store(LServer, Packet) ->
Type = xml:get_tag_attr_s(<<"type">>, Packet),
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
false ->
case check_event(From, To, Packet) of
@@ -315,7 +330,7 @@ store_packet(From, To, Packet) ->
end;
_ -> ok
end;
- true -> ok
+ false -> ok
end.
has_no_storage_hint(Packet) ->