mod_mam_mnesia: Never store error messages
Don't store messages of type "error", even if it has a <store/> hint.
This commit is contained in:
parent
91e4c56e67
commit
8e43a20f12
|
@ -327,21 +327,10 @@ is_desired(Route, JID, To, Message) ->
|
||||||
-spec looks_interesting(xmlel()) -> boolean().
|
-spec looks_interesting(xmlel()) -> boolean().
|
||||||
|
|
||||||
looks_interesting(Message) ->
|
looks_interesting(Message) ->
|
||||||
(is_chat_or_normal_message(Message) andalso has_non_empty_body(Message))
|
Type = message_type(Message),
|
||||||
orelse has_store_hint(Message).
|
(is_chat_or_normal(Type) andalso has_non_empty_body(Message))
|
||||||
|
orelse
|
||||||
-spec is_chat_or_normal_message(xmlel()) -> boolean().
|
(has_store_hint(Message) andalso not is_error(Type)).
|
||||||
|
|
||||||
is_chat_or_normal_message(#xmlel{name = <<"message">>} = Message) ->
|
|
||||||
case message_type(Message) of
|
|
||||||
<<"chat">> ->
|
|
||||||
true;
|
|
||||||
<<"normal">> ->
|
|
||||||
true;
|
|
||||||
_ ->
|
|
||||||
false
|
|
||||||
end;
|
|
||||||
is_chat_or_normal_message(_Message) -> false.
|
|
||||||
|
|
||||||
-spec message_type(xmlel()) -> binary().
|
-spec message_type(xmlel()) -> binary().
|
||||||
|
|
||||||
|
@ -353,6 +342,17 @@ message_type(#xmlel{attrs = Attrs}) ->
|
||||||
<<"normal">>
|
<<"normal">>
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec is_chat_or_normal(binary()) -> boolean().
|
||||||
|
|
||||||
|
is_chat_or_normal(<<"chat">>) -> true;
|
||||||
|
is_chat_or_normal(<<"normal">>) -> true;
|
||||||
|
is_chat_or_normal(_Type) -> false.
|
||||||
|
|
||||||
|
-spec is_error(binary()) -> boolean().
|
||||||
|
|
||||||
|
is_error(<<"error">>) -> true;
|
||||||
|
is_error(_Type) -> false.
|
||||||
|
|
||||||
-spec has_non_empty_body(xmlel()) -> boolean().
|
-spec has_non_empty_body(xmlel()) -> boolean().
|
||||||
|
|
||||||
has_non_empty_body(Message) ->
|
has_non_empty_body(Message) ->
|
||||||
|
|
Loading…
Reference in New Issue