mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-04 16:40:36 +01:00
Include original timestamp on delayed presences (thanks to Mickael Remond)(EJAB-234)
SVN Revision: 2348
This commit is contained in:
parent
49688feaf2
commit
29ea2738cc
@ -1441,7 +1441,13 @@ process_presence_probe(From, To, StateData) ->
|
||||
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,
|
||||
@ -1495,6 +1501,7 @@ presence_update(From, Packet, StateData) ->
|
||||
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};
|
||||
@ -1511,6 +1518,7 @@ presence_update(From, Packet, StateData) ->
|
||||
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},
|
||||
@ -1539,6 +1547,7 @@ presence_update(From, Packet, StateData) ->
|
||||
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,
|
||||
@ -1557,7 +1566,8 @@ presence_update(From, Packet, StateData) ->
|
||||
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,
|
||||
@ -1571,7 +1581,8 @@ presence_update(From, Packet, StateData) ->
|
||||
ok
|
||||
end,
|
||||
StateData#state{pres_last = Packet,
|
||||
pres_invis = false
|
||||
pres_invis = false,
|
||||
pres_timestamp = Timestamp
|
||||
}
|
||||
end,
|
||||
NewState
|
||||
|
@ -1827,7 +1827,7 @@ send_new_presence(NJID, Reason, StateData) ->
|
||||
false ->
|
||||
[]
|
||||
end,
|
||||
Packet = append_subtags(
|
||||
Packet = xml:append_subtags(
|
||||
Presence,
|
||||
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
|
||||
[{xmlelement, "item", ItemAttrs, ItemEls} | Status]}]),
|
||||
@ -1868,7 +1868,7 @@ send_existing_presences(ToJID, StateData) ->
|
||||
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, []}]}]),
|
||||
@ -1881,10 +1881,6 @@ send_existing_presences(ToJID, StateData) ->
|
||||
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.
|
||||
|
||||
@ -1944,7 +1940,7 @@ send_nick_changing(JID, OldNick, StateData) ->
|
||||
[{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, []}]}]),
|
||||
@ -2004,7 +2000,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
|
||||
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)]),
|
||||
|
@ -34,6 +34,7 @@
|
||||
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]).
|
||||
|
||||
@ -219,6 +220,9 @@ get_subtag_cdata(Tag, Name) ->
|
||||
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]) ->
|
||||
|
Loading…
Reference in New Issue
Block a user