diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-08-12 21:13:10 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-08-12 21:13:10 +0200 |
commit | bf9d6b55342dbb013bba612d4855271b582ae0ff (patch) | |
tree | da6bf1c92b87fc00b44cc4e224a56b0c898b39fb /src/mod_offline.erl | |
parent | mod_mam: Don't store messages of type "headline" (diff) |
Honor <store/> hint for any non-"error" message
XEP-0334 says: "A message containing the <store/> hint that is not of
type 'error' SHOULD be stored by the entity."
Diffstat (limited to 'src/mod_offline.erl')
-rw-r--r-- | src/mod_offline.erl | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 799605c69..87a136853 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -437,35 +437,36 @@ remove_msg_by_node(To, Seq) -> end. need_to_store(LServer, Packet) -> - Type = fxml:get_tag_attr_s(<<"type">>, Packet), - if (Type /= <<"error">>) and (Type /= <<"groupchat">>) - and (Type /= <<"headline">>) -> - case has_offline_tag(Packet) of - false -> - case check_store_hint(Packet) of - store -> + case has_offline_tag(Packet) of + false -> + case {check_store_hint(Packet), + fxml:get_tag_attr_s(<<"type">>, Packet)} of + {_Hint, <<"error">>} -> + false; + {store, _Type} -> + true; + {no_store, _Type} -> + false; + {none, <<"groupchat">>} -> + false; + {none, <<"headline">>} -> + false; + {none, _Type} -> + case gen_mod:get_module_opt( + LServer, ?MODULE, store_empty_body, + fun(V) when is_boolean(V) -> V; + (unless_chat_state) -> unless_chat_state + end, + unless_chat_state) of + true -> true; - no_store -> - false; - none -> - case gen_mod:get_module_opt( - LServer, ?MODULE, store_empty_body, - fun(V) when is_boolean(V) -> V; - (unless_chat_state) -> unless_chat_state - end, - unless_chat_state) of - false -> - fxml:get_subtag(Packet, <<"body">>) /= false; - unless_chat_state -> - not jlib:is_standalone_chat_state(Packet); - true -> - true - end - end; - true -> - false + false -> + fxml:get_subtag(Packet, <<"body">>) /= false; + unless_chat_state -> + not jlib:is_standalone_chat_state(Packet) + end end; - true -> + true -> false end. |