]> granicus.if.org Git - ejabberd/commitdiff
mod_push: Check for payload in encrypted messages
authorHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 11 Mar 2019 21:58:53 +0000 (22:58 +0100)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 11 Mar 2019 21:58:53 +0000 (22:58 +0100)
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.

src/mod_push.erl

index a6e8713757d2f2300e81f41a03b637796e55af35..2cf34f65fdd176a3df337f1bbfe3519e7325b4b3 100644 (file)
@@ -682,8 +682,13 @@ get_body_text(#message{body = Body} = Msg) ->
     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) ->