diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2021-07-28 18:22:39 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2021-07-28 18:22:39 +0200 |
commit | 103e98b8da5abd7713c3ef8e9e54b004c4935a09 (patch) | |
tree | 5d54387f5781522ea01a3c8d344616c3def33a67 | |
parent | When vsn is an exact tag, append .0 to satisfy SemVer (diff) |
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.
-rw-r--r-- | src/mod_push.erl | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mod_push.erl b/src/mod_push.erl index 14ee02910..b4dd48234 100644 --- a/src/mod_push.erl +++ b/src/mod_push.erl @@ -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) -> |