25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

mod_push: Fix handling of MUC/Sub messages

Don't fail to include the sender/body of MUC/Sub messages if the
recipient is offline.

Closes #3651.
This commit is contained in:
Holger Weiss 2021-07-28 18:22:39 +02:00
parent 8e553decb0
commit 103e98b8da

View File

@ -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_message(Pkt), get_direction(Pkt)), notify(State, 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_message(Pkt0), get_direction(Pkt0)} Pkt0 -> {Pkt0, get_direction(Pkt0)}
end, end,
notify(State, Pkt, Dir), notify(State, Pkt, Dir),
State; State;
@ -536,7 +536,8 @@ notify(LUser, LServer, Clients, Pkt, Dir) ->
-spec notify(binary(), ljid(), binary(), xdata(), -spec notify(binary(), ljid(), binary(), xdata(),
xmpp_element() | xmlel() | none, direction(), xmpp_element() | xmlel() | none, direction(),
fun((iq() | timeout) -> any())) -> ok. fun((iq() | timeout) -> any())) -> ok.
notify(LServer, PushLJID, Node, XData, Pkt, Dir, HandleResponse) -> notify(LServer, PushLJID, Node, XData, Pkt0, Dir, HandleResponse) ->
Pkt = unwrap_message(Pkt0),
From = jid:make(LServer), From = jid:make(LServer),
Summary = make_summary(LServer, Pkt, Dir), Summary = make_summary(LServer, Pkt, Dir),
Item = #ps_item{sub_els = [#push_notification{xdata = Summary}]}, Item = #ps_item{sub_els = [#push_notification{xdata = Summary}]},
@ -714,7 +715,7 @@ make_summary(Host, #message{from = From} = Pkt, recv) ->
make_summary(_Host, _Pkt, _Dir) -> make_summary(_Host, _Pkt, _Dir) ->
undefined. undefined.
-spec unwrap_message(stanza()) -> stanza(). -spec unwrap_message(Stanza) -> Stanza when Stanza :: stanza() | none.
unwrap_message(#message{meta = #{carbon_copy := true}} = Msg) -> unwrap_message(#message{meta = #{carbon_copy := true}} = Msg) ->
misc:unwrap_carbon(Msg); misc:unwrap_carbon(Msg);
unwrap_message(#message{type = normal} = Msg) -> unwrap_message(#message{type = normal} = Msg) ->