While distinguishing actual chat messages from other message types,
don't classify all <encrypted/> messages as chat messages, but only
those that have a <payload/> element.
end.
-spec body_is_encrypted(message()) -> boolean().
-body_is_encrypted(#message{sub_els = SubEls}) ->
- lists:keyfind(<<"encrypted">>, #xmlel.name, SubEls) /= false.
+body_is_encrypted(#message{sub_els = MsgEls}) ->
+ case lists:keyfind(<<"encrypted">>, #xmlel.name, MsgEls) of
+ #xmlel{children = EncEls} ->
+ lists:keyfind(<<"payload">>, #xmlel.name, EncEls) /= false;
+ false ->
+ false
+ end.
-spec inspect_error(iq()) -> {atom(), binary()}.
inspect_error(IQ) ->