mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
mod_push: Handle MUC/Sub events correctly
Unwrap MUC/Sub messages so that our check for a message body yields the correct result. Many thanks to Robert Schuh for pointing out the issue and suggesting a fix. Closes #3565.
This commit is contained in:
parent
4468c87115
commit
10905b0447
@ -405,7 +405,7 @@ c2s_stanza(State, #stream_error{}, _SendResult) ->
|
|||||||
c2s_stanza(#{push_enabled := true, mgmt_state := pending} = State,
|
c2s_stanza(#{push_enabled := true, mgmt_state := pending} = State,
|
||||||
Pkt, _SendResult) ->
|
Pkt, _SendResult) ->
|
||||||
?DEBUG("Notifying client of stanza", []),
|
?DEBUG("Notifying client of stanza", []),
|
||||||
notify(State, unwrap_carbon(Pkt), get_direction(Pkt)),
|
notify(State, unwrap_message(Pkt), get_direction(Pkt)),
|
||||||
State;
|
State;
|
||||||
c2s_stanza(State, _Pkt, _SendResult) ->
|
c2s_stanza(State, _Pkt, _SendResult) ->
|
||||||
State.
|
State.
|
||||||
@ -454,7 +454,7 @@ c2s_session_pending(#{push_enabled := true, mgmt_queue := Queue} = State) ->
|
|||||||
{Pkt, Dir} = case mod_stream_mgmt:queue_find(
|
{Pkt, Dir} = case mod_stream_mgmt:queue_find(
|
||||||
fun is_incoming_chat_msg/1, Queue) of
|
fun is_incoming_chat_msg/1, Queue) of
|
||||||
none -> {none, undefined};
|
none -> {none, undefined};
|
||||||
Pkt0 -> {unwrap_carbon(Pkt0), get_direction(Pkt0)}
|
Pkt0 -> {unwrap_message(Pkt0), get_direction(Pkt0)}
|
||||||
end,
|
end,
|
||||||
notify(State, Pkt, Dir),
|
notify(State, Pkt, Dir),
|
||||||
State;
|
State;
|
||||||
@ -555,7 +555,7 @@ notify(LServer, PushLJID, Node, XData, Pkt, Dir, HandleResponse) ->
|
|||||||
-spec is_incoming_chat_msg(stanza()) -> boolean().
|
-spec is_incoming_chat_msg(stanza()) -> boolean().
|
||||||
is_incoming_chat_msg(#message{} = Msg) ->
|
is_incoming_chat_msg(#message{} = Msg) ->
|
||||||
case get_direction(Msg) of
|
case get_direction(Msg) of
|
||||||
recv -> get_body_text(unwrap_carbon(Msg)) /= none;
|
recv -> get_body_text(unwrap_message(Msg)) /= none;
|
||||||
send -> false
|
send -> false
|
||||||
end;
|
end;
|
||||||
is_incoming_chat_msg(_Stanza) ->
|
is_incoming_chat_msg(_Stanza) ->
|
||||||
@ -714,10 +714,17 @@ make_summary(Host, #message{from = From} = Pkt, recv) ->
|
|||||||
make_summary(_Host, _Pkt, _Dir) ->
|
make_summary(_Host, _Pkt, _Dir) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
-spec unwrap_carbon(stanza()) -> stanza().
|
-spec unwrap_message(stanza()) -> stanza().
|
||||||
unwrap_carbon(#message{meta = #{carbon_copy := true}} = Msg) ->
|
unwrap_message(#message{meta = #{carbon_copy := true}} = Msg) ->
|
||||||
misc:unwrap_carbon(Msg);
|
misc:unwrap_carbon(Msg);
|
||||||
unwrap_carbon(Stanza) ->
|
unwrap_message(#message{type = normal} = Msg) ->
|
||||||
|
case misc:unwrap_mucsub_message(Msg) of
|
||||||
|
#message{} = InnerMsg ->
|
||||||
|
InnerMsg;
|
||||||
|
false ->
|
||||||
|
Msg
|
||||||
|
end;
|
||||||
|
unwrap_message(Stanza) ->
|
||||||
Stanza.
|
Stanza.
|
||||||
|
|
||||||
-spec get_direction(stanza()) -> direction().
|
-spec get_direction(stanza()) -> direction().
|
||||||
|
Loading…
Reference in New Issue
Block a user