25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +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,
Pkt, _SendResult) ->
?DEBUG("Notifying client of stanza", []),
notify(State, unwrap_message(Pkt), get_direction(Pkt)),
notify(State, Pkt, get_direction(Pkt)),
State;
c2s_stanza(State, _Pkt, _SendResult) ->
State.
@ -454,7 +454,7 @@ c2s_session_pending(#{push_enabled := true, mgmt_queue := Queue} = State) ->
{Pkt, Dir} = case mod_stream_mgmt:queue_find(
fun is_incoming_chat_msg/1, Queue) of
none -> {none, undefined};
Pkt0 -> {unwrap_message(Pkt0), get_direction(Pkt0)}
Pkt0 -> {Pkt0, get_direction(Pkt0)}
end,
notify(State, Pkt, Dir),
State;
@ -536,7 +536,8 @@ notify(LUser, LServer, Clients, Pkt, Dir) ->
-spec notify(binary(), ljid(), binary(), xdata(),
xmpp_element() | xmlel() | none, direction(),
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),
Summary = make_summary(LServer, Pkt, Dir),
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) ->
undefined.
-spec unwrap_message(stanza()) -> stanza().
-spec unwrap_message(Stanza) -> Stanza when Stanza :: stanza() | none.
unwrap_message(#message{meta = #{carbon_copy := true}} = Msg) ->
misc:unwrap_carbon(Msg);
unwrap_message(#message{type = normal} = Msg) ->