aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jlib.erl7
-rw-r--r--src/mod_offline.erl24
2 files changed, 25 insertions, 6 deletions
diff --git a/src/jlib.erl b/src/jlib.erl
index 7735d7dbc..be1da3fd0 100644
--- a/src/jlib.erl
+++ b/src/jlib.erl
@@ -798,7 +798,12 @@ base64_to_term(Base64) ->
-spec decode_base64(binary()) -> binary().
decode_base64(S) ->
- decode_base64_bin(S, <<>>).
+ case catch binary:last(S) of
+ C when C == $\n; C == $\s ->
+ decode_base64(binary:part(S, 0, byte_size(S) - 1));
+ _ ->
+ decode_base64_bin(S, <<>>)
+ end.
take_without_spaces(Bin, Count) ->
take_without_spaces(Bin, Count, <<>>).
diff --git a/src/mod_offline.erl b/src/mod_offline.erl
index 95c5881df..91d31a75d 100644
--- a/src/mod_offline.erl
+++ b/src/mod_offline.erl
@@ -293,12 +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),
- BodyElem = xml:get_path_s(Packet,[{elem, <<"body">>}]),
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
- and (Type /= <<"headline">>) and (<<>> /= BodyElem) ->
+ 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
@@ -316,7 +330,7 @@ store_packet(From, To, Packet) ->
end;
_ -> ok
end;
- true -> ok
+ false -> ok
end.
has_no_storage_hint(Packet) ->