andalso ?SETS:is_element(LFrom, StateData#state.pres_a),
if
Cond1 ->
- Packet = StateData#state.pres_last,
+ Timestamp = StateData#state.pres_timestamp,
+ Packet = xml:append_subtags(
+ StateData#state.pres_last,
+ %% To is the one sending the presence (the target of the probe)
+ [jlib:timestamp_to_xml(Timestamp, utc, To, ""),
+ %% TODO: Delete the next line once XEP-0091 is Obsolete
+ jlib:timestamp_to_xml(Timestamp)]),
case ejabberd_hooks:run_fold(
privacy_check_packet, StateData#state.server,
allow,
presence_broadcast(StateData, From, StateData#state.pres_a, Packet),
presence_broadcast(StateData, From, StateData#state.pres_i, Packet),
StateData#state{pres_last = undefined,
+ pres_timestamp = undefined,
pres_a = ?SETS:new(),
pres_i = ?SETS:new(),
pres_invis = false};
StateData#state.pres_i,
Packet),
S1 = StateData#state{pres_last = undefined,
+ pres_timestamp = undefined,
pres_a = ?SETS:new(),
pres_i = ?SETS:new(),
pres_invis = true},
get_priority_from_presence(OldPresence)
end,
NewPriority = get_priority_from_presence(Packet),
+ Timestamp = calendar:now_to_universal_time(now()),
update_priority(NewPriority, Packet, StateData),
FromUnavail = (StateData#state.pres_last == undefined) or
StateData#state.pres_invis,
end,
presence_broadcast_first(
From, StateData#state{pres_last = Packet,
- pres_invis = false
+ pres_invis = false,
+ pres_timestamp = Timestamp
}, Packet);
true ->
presence_broadcast_to_trusted(StateData,
ok
end,
StateData#state{pres_last = Packet,
- pres_invis = false
+ pres_invis = false,
+ pres_timestamp = Timestamp
}
end,
NewState
false ->
[]
end,
- Packet = append_subtags(
+ Packet = xml:append_subtags(
Presence,
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
[{xmlelement, "item", ItemAttrs, ItemEls} | Status]}]),
affiliation_to_list(FromAffiliation)},
{"role", role_to_list(FromRole)}]
end,
- Packet = append_subtags(
+ Packet = xml:append_subtags(
Presence,
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
[{xmlelement, "item", ItemAttrs, []}]}]),
end, ?DICT:to_list(StateData#state.users)).
-append_subtags({xmlelement, Name, Attrs, SubTags1}, SubTags2) ->
- {xmlelement, Name, Attrs, SubTags1 ++ SubTags2}.
-
-
now_to_usec({MSec, Sec, USec}) ->
(MSec*1000000 + Sec)*1000000 + USec.
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
[{xmlelement, "item", ItemAttrs1, []},
{xmlelement, "status", [{"code", "303"}], []}]}]},
- Packet2 = append_subtags(
+ Packet2 = xml:append_subtags(
Presence,
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
[{xmlelement, "item", ItemAttrs2, []}]}]),
true -> StateData#state.jid;
false -> FromJID
end,
- TSPacket = append_subtags(Packet,
+ TSPacket = xml:append_subtags(Packet,
[jlib:timestamp_to_xml(TimeStamp, utc, SenderJid, ""),
%% TODO: Delete the next line once XEP-0091 is Obsolete
jlib:timestamp_to_xml(TimeStamp)]),
get_attr/2, get_attr_s/2,
get_tag_attr/2, get_tag_attr_s/2,
get_subtag/2, get_subtag_cdata/2,
+ append_subtags/2,
get_path_s/2,
replace_tag_attr/3]).
get_tag_cdata(Subtag)
end.
+append_subtags({xmlelement, Name, Attrs, SubTags1}, SubTags2) ->
+ {xmlelement, Name, Attrs, SubTags1 ++ SubTags2}.
+
get_path_s(El, []) ->
El;
get_path_s(El, [{elem, Name} | Path]) ->