Always specify room JID for MUC <delay/> elements

As per version 1.25 of XEP-0045, use the room JID as the 'from' address
for <delay/> elements also when the room is non-anonymous, and specify
the original JID of the sender as an XEP-0033-style tag instead.

Closes #465.
This commit is contained in:
Holger Weiss 2015-03-10 00:02:32 +01:00
parent 0a88255ef6
commit d991b92a49
1 changed files with 14 additions and 7 deletions

View File

@ -2442,13 +2442,20 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
_ -> true
end,
TimeStamp = now(),
SenderJid = case
(StateData#state.config)#config.anonymous
of
true -> StateData#state.jid;
false -> FromJID
end,
TSPacket = jlib:add_delay_info(Packet, SenderJid, TimeStamp),
AddrPacket = case (StateData#state.config)#config.anonymous of
true -> Packet;
false ->
Address = #xmlel{name = <<"address">>,
attrs = [{<<"type">>, <<"ofrom">>},
{<<"jid">>,
jlib:jid_to_string(FromJID)}],
children = []},
Addresses = #xmlel{name = <<"addresses">>,
attrs = [{<<"xmlns">>, ?NS_ADDRESS}],
children = [Address]},
xml:append_subtags(Packet, [Addresses])
end,
TSPacket = jlib:add_delay_info(AddrPacket, StateData#state.jid, TimeStamp),
SPacket =
jlib:replace_from_to(jlib:jid_replace_resource(StateData#state.jid,
FromNick),