Don't crash when 'from' is undefined

c2s_filter_send hook may pass a stanza with undefined from/to (due to
legacy auth for example). Work around this problem.

Fixes #2036
This commit is contained in:
Evgeniy Khramtsov 2017-10-06 21:48:54 +03:00
parent 0ed210877a
commit 6efdd0f350
1 changed files with 4 additions and 1 deletions

View File

@ -265,7 +265,10 @@ filter_other({Stanza, #{jid := JID} = C2SState} = Acc) when ?is_stanza(Stanza) -
Acc;
_ ->
?DEBUG("Won't add stanza for ~s to CSI queue", [jid:encode(JID)]),
From = xmpp:get_from(Stanza),
From = case xmpp:get_from(Stanza) of
undefined -> JID;
F -> F
end,
C2SState1 = dequeue_sender(From, C2SState),
{Stanza, C2SState1}
end;