prosody2ejabberd: Fix offline message record type

mod_offline now expects a #message{} rather than an #xmlel{} record.
This commit is contained in:
Holger Weiss 2017-03-21 18:35:07 +01:00
parent a1068df602
commit e469b6ffb4
1 changed files with 15 additions and 10 deletions

View File

@ -341,19 +341,24 @@ el_to_offline_msg(LUser, LServer, #xmlel{attrs = Attrs} = El) ->
({<<"stamp_legacy">>, _}) -> false;
(_) -> true
end, Attrs),
Packet = El#xmlel{attrs = Attrs1},
From = jid:decode(fxml:get_attr_s(<<"from">>, Attrs)),
To = jid:decode(fxml:get_attr_s(<<"to">>, Attrs)),
[#offline_msg{
us = {LUser, LServer},
timestamp = TS,
expire = never,
from = From,
to = To,
packet = Packet}]
El1 = El#xmlel{attrs = Attrs1},
case xmpp:decode(El1, ?NS_CLIENT, [ignore_els]) of
#message{from = #jid{} = From, to = #jid{} = To} = Packet ->
[#offline_msg{
us = {LUser, LServer},
timestamp = TS,
expire = never,
from = From,
to = To,
packet = Packet}];
_ ->
[]
end
catch _:{bad_timestamp, _} ->
[];
_:{bad_jid, _} ->
[];
_:{xmpp_codec, _} ->
[]
end.