]> granicus.if.org Git - ejabberd/commitdiff
Add new option: store_empty_body
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Mon, 27 Oct 2014 11:14:52 +0000 (14:14 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Mon, 27 Oct 2014 11:18:09 +0000 (14:18 +0300)
doc/guide.tex
src/mod_offline.erl

index efebc2521708f677359ee94b44cb54d9841852d0..2c20df9534ff5c6d44c83f60468c6c5bc28638dc 100644 (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}.
   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,
index bb488f8c55212c6af4b77c04972bad6d9dd2c7a3..91d31a75d0680249f22f7d126fe43acf6bbf7cb7 100644 (file)
@@ -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) ->