]> granicus.if.org Git - ejabberd/commitdiff
Move unwrap_mucsub_message/1 into misc
authorHolger Weiss <holger@zedat.fu-berlin.de>
Wed, 24 Oct 2018 23:22:57 +0000 (01:22 +0200)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Wed, 24 Oct 2018 23:22:57 +0000 (01:22 +0200)
src/misc.erl
src/mod_mam.erl
src/mod_muc_room.erl

index 8a44f2b6bf1b3cb8cd38d78373f21a90aa36b54c..5aa281565c9e708a90d6e81dbb6ef751286bdb5a 100644 (file)
@@ -29,7 +29,7 @@
 
 %% API
 -export([add_delay_info/3, add_delay_info/4,
-        unwrap_carbon/1, is_standalone_chat_state/1,
+        unwrap_carbon/1, unwrap_mucsub_message/1, is_standalone_chat_state/1,
         tolower/1, term_to_base64/1, base64_to_term/1, ip_to_list/1,
         hex_to_bin/1, hex_to_base64/1, url_encode/1, expand_keyword/3,
         atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
@@ -91,6 +91,24 @@ unwrap_carbon(#message{} = Msg) ->
     end;
 unwrap_carbon(Stanza) -> Stanza.
 
+-spec unwrap_mucsub_message(xmpp_element()) -> message() | false.
+unwrap_mucsub_message(#message{} = OuterMsg) ->
+    case xmpp:get_subtag(OuterMsg, #ps_event{}) of
+       #ps_event{
+           items = #ps_items{
+               node = Node,
+               items = [
+                   #ps_item{
+                       sub_els = [#message{} = InnerMsg]} | _]}}
+           when Node == ?NS_MUCSUB_NODES_MESSAGES;
+                Node == ?NS_MUCSUB_NODES_SUBJECT ->
+           InnerMsg;
+       _ ->
+           false
+    end;
+unwrap_mucsub_message(_Packet) ->
+    false.
+
 -spec is_standalone_chat_state(stanza()) -> boolean().
 is_standalone_chat_state(Stanza) ->
     case unwrap_carbon(Stanza) of
index ca2cbeb02c043583c5d3c5609799b973427a39a2..9689a93a2630d6f563119edc08bb5ce2c12cc1d6 100644 (file)
@@ -653,7 +653,7 @@ should_archive(#message{body = Body, subject = Subject,
                        true ->
                            true;
                        _ ->
-                           case mod_muc_room:unwrap_mucsub_message(Pkt) of
+                           case misc:unwrap_mucsub_message(Pkt) of
                                #message{type = groupchat} = Msg ->
                                    should_archive(Msg#message{type = chat}, LServer);
                                #message{} = Msg ->
index aeb03176303fb969582089a9b735b15b33483940..492f9a4b38d24721607e16b5a76802b2427159e0 100644 (file)
@@ -39,8 +39,7 @@
         is_occupant_or_admin/2,
         route/2,
         expand_opts/1,
-        config_fields/0,
-        unwrap_mucsub_message/1]).
+        config_fields/0]).
 
 %% gen_fsm callbacks
 -export([init/1,
@@ -4461,24 +4460,6 @@ wrap(From, To, Packet, Node) ->
                                            id = p1_rand:get_string(),
                                            sub_els = [El]}]}}]}.
 
--spec unwrap_mucsub_message(xmpp_element()) -> message() | false.
-unwrap_mucsub_message(#message{} = Packet) ->
-    case xmpp:get_subtag(Packet, #ps_event{}) of
-       #ps_event{
-           items = #ps_items{
-               node = Node,
-               items = [
-                   #ps_item{
-                       sub_els = [#message{} = Message]} | _]}}
-           when Node == ?NS_MUCSUB_NODES_MESSAGES;
-                Node == ?NS_MUCSUB_NODES_SUBJECT ->
-           Message;
-       _ ->
-           false
-    end;
-unwrap_mucsub_message(_Packet) ->
-    false.
-
 %% -spec send_multiple(jid(), binary(), [#user{}], stanza()) -> ok.
 %% send_multiple(From, Server, Users, Packet) ->
 %%     JIDs = [ User#user.jid || {_, User} <- ?DICT:to_list(Users)],