]> granicus.if.org Git - ejabberd/commitdiff
Fix tests that use #forwarded
authorPaweł Chmielowski <pchmielowski@process-one.net>
Tue, 15 Nov 2016 08:59:40 +0000 (09:59 +0100)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Tue, 15 Nov 2016 09:02:21 +0000 (10:02 +0100)
test/ejabberd_SUITE.erl
test/suite.erl
test/suite.hrl

index 121719cdfb862d1c06efc093b3ea5f7cc336fcbc..3ac12953cab058b769cc45ff7465dd8b091488c7 100644 (file)
@@ -2083,7 +2083,7 @@ retrieve_messages_from_room_via_mam(Config, Range) ->
                         xmlns = ?NS_MAM_1,
                         queryid = QID,
                         sub_els =
-                            [#forwarded{
+                            [#forwarded_decoded{
                                 delay = #delay{},
                                 sub_els = [#message{
                                               from = MyNickJID,
@@ -2411,7 +2411,7 @@ carbons_slave(Config) ->
        #message{from = MyBareJID, to = MyJID, type = chat,
                sub_els =
                    [#carbons_sent{
-                       forwarded = #forwarded{
+                       forwarded = #forwarded_decoded{
                                       sub_els =
                                           [#message{from = Peer,
                                                     to = MyBareJID,
@@ -2420,7 +2420,7 @@ carbons_slave(Config) ->
        #message{from = MyBareJID, to = MyJID, type = chat,
                sub_els =
                    [#carbons_sent{
-                       forwarded = #forwarded{
+                       forwarded = #forwarded_decoded{
                                       sub_els =
                                           [#message{from = Peer,
                                                     to = Peer,
@@ -2429,7 +2429,7 @@ carbons_slave(Config) ->
        #message{from = MyBareJID, to = MyJID, type = chat,
                sub_els =
                    [#carbons_received{
-                       forwarded = #forwarded{
+                       forwarded = #forwarded_decoded{
                                       sub_els =
                                           [#message{from = Peer,
                                                     to = MyBareJID,
@@ -2438,7 +2438,7 @@ carbons_slave(Config) ->
        #message{from = MyBareJID, to = MyJID, type = chat,
                sub_els =
                    [#carbons_received{
-                       forwarded = #forwarded{
+                       forwarded = #forwarded_decoded{
                                       sub_els =
                                           [#message{from = Peer,
                                                     to = Peer,
@@ -2560,7 +2560,7 @@ mam_query_all(Config, NS) ->
                            [#mam_result{
                                queryid = QID,
                                sub_els =
-                                   [#forwarded{
+                                  [#forwarded_decoded{
                                        delay = #delay{},
                                        sub_els =
                                            [#message{
@@ -2599,7 +2599,7 @@ mam_query_with(Config, JID, NS) ->
                        sub_els =
                            [#mam_result{
                                sub_els =
-                                   [#forwarded{
+                                  [#forwarded_decoded{
                                        delay = #delay{},
                                        sub_els =
                                            [#message{
@@ -2640,7 +2640,7 @@ mam_query_rsm(Config, NS) ->
                            [#mam_result{
                               xmlns = NS,
                                sub_els =
-                                   [#forwarded{
+                                  [#forwarded_decoded{
                                        delay = #delay{},
                                        sub_els =
                                            [#message{
@@ -2677,7 +2677,7 @@ mam_query_rsm(Config, NS) ->
                            [#mam_result{
                               xmlns = NS,
                                sub_els =
-                                   [#forwarded{
+                                  [#forwarded_decoded{
                                        delay = #delay{},
                                        sub_els =
                                            [#message{
@@ -2717,7 +2717,7 @@ mam_query_rsm(Config, NS) ->
                            [#mam_result{
                               xmlns = NS,
                                sub_els =
-                                   [#forwarded{
+                                  [#forwarded_decoded{
                                        delay = #delay{},
                                        sub_els =
                                            [#message{
@@ -2773,7 +2773,7 @@ mam_query_rsm(Config, NS) ->
                           [#mam_result{
                               xmlns = NS,
                               sub_els =
-                                  [#forwarded{
+                                  [#forwarded_decoded{
                                       delay = #delay{},
                                       sub_els =
                                           [#message{
index 52c030df117f7d7ddce09d30f3d165ca3bb7f845..3c46e8f6bd3fbf6188dc3dee2d89fc943ac1e43b 100644 (file)
@@ -481,9 +481,22 @@ format_element(El) ->
        false -> io_lib:format(" ~s~n", El)
     end.
 
+substitute_forwarded(#mam_result{sub_els = Sub} = El) ->
+    El#mam_result{sub_els = [substitute_forwarded(SEl) || SEl <- Sub]};
+substitute_forwarded(#carbons_sent{forwarded = Sub} = El) ->
+    El#carbons_sent{forwarded = [substitute_forwarded(SEl) || SEl <- Sub]};
+substitute_forwarded(#message{sub_els = Sub} = El) ->
+    El#message{sub_els = [substitute_forwarded(SEl) || SEl <- Sub]};
+substitute_forwarded(#forwarded{delay = Delay, xml_els = Sub}) ->
+    #forwarded_decoded{delay = Delay, sub_els = [xmpp:decode(SEl) || SEl <- Sub]};
+substitute_forwarded(El) ->
+    El.
+
+
+
 decode(El, NS, Opts) ->
     try
-       Pkt = xmpp:decode(El, NS, Opts),
+       Pkt = substitute_forwarded(xmpp:decode(El, NS, Opts)),
        ct:pal("RECV:~n~s~n~s",
               [format_element(El), xmpp:pp(Pkt)]),
        Pkt
index 00239f8cf0413624554118e189159eec95b41232..d9a9c5ab0cf15df9e3bdbb022a32ee644ec45c14 100644 (file)
@@ -5,6 +5,9 @@
 -include("mod_proxy65.hrl").
 -include("xmpp_codec.hrl").
 
+-record(forwarded_decoded, {delay :: #delay{},
+                           sub_els = [] :: [fxml:xmlel()]}).
+
 -define(STREAM_TRAILER, <<"</stream:stream>">>).
 
 -define(PUBSUB(Node), <<(?NS_PUBSUB)/binary, "#", Node>>).