aboutsummaryrefslogtreecommitdiff
path: root/src/misc.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.erl')
-rw-r--r--src/misc.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/misc.erl b/src/misc.erl
index 8a44f2b6b..5aa281565 100644
--- a/src/misc.erl
+++ b/src/misc.erl
@@ -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