Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete XEP-0091 timestamp #383

Merged
merged 10 commits into from
Mar 16, 2015
8 changes: 2 additions & 6 deletions apps/ejabberd/src/ejabberd_c2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1768,9 +1768,7 @@ process_presence_probe(From, To, StateData) ->
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)]),
[jlib:timestamp_to_xml(Timestamp, utc, To, <<>>)]),
case privacy_check_packet(StateData, To, From, Packet, out) of
deny ->
ok;
Expand Down Expand Up @@ -2955,10 +2953,8 @@ add_timestamp({_,_,Micro} = TimeStamp, Server, Packet) ->
Time = {D,{H,M,S, Micro}},
case xml:get_subtag(Packet, <<"delay">>) of
false ->
%% TODO: Delete the next element once XEP-0091 is Obsolete
TimeStampLegacyXML = timestamp_legacy_xml(Server, Time),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that somebody confused the binding/function name and named the modern format as legacy. It's a good opportunity to fix it :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@studzien I hope the new name is ok. Thanks for the feedback

TimeStampXML = jlib:timestamp_to_xml(Time),
xml:append_subtags(Packet, [TimeStampLegacyXML, TimeStampXML]);
xml:append_subtags(Packet, [TimeStampLegacyXML]);
_ ->
Packet
end.
Expand Down
19 changes: 0 additions & 19 deletions apps/ejabberd/src/jlib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
parse_xdata_submit/1,
timestamp_to_iso/1, % TODO: Remove once XEP-0091 is Obsolete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that there is another obsolete function. I'd remove it also and see if our tests run by travis passes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalwski I removed this one too.

timestamp_to_xml/4,
timestamp_to_xml/1, % TODO: Remove once XEP-0091 is Obsolete
timestamp_to_mam_xml/4,
now_to_utc_binary/1,
datetime_binary_to_timestamp/1,
Expand Down Expand Up @@ -778,24 +777,6 @@ timestamp_to_mam_xml(DateTime, Timezone, QueryID, MessageUID) ->
{<<"id">>, MessageUID}] ++
[{<<"queryid">>, QueryID} || QueryID =/= undefined, QueryID =/= <<>>]}.


%% @doc TODO: Remove this function once XEP-0091 is Obsolete
-spec timestamp_to_xml(calendar:datetime()) -> xmlel().
timestamp_to_xml({{Year, Month, Day}, {Hour, Minute, Second, Micro}}) ->
#xmlel{name = <<"x">>,
attrs = [{<<"xmlns">>, ?NS_DELAY91},
{<<"stamp">>, lists:flatten(
io_lib:format("~4..0w~2..0w~2..0wT~2..0w:~2..0w:~2..0w.~6..0w",
[Year, Month, Day, Hour, Minute, Second, Micro]))}]};

timestamp_to_xml({{Year, Month, Day}, {Hour, Minute, Second}}) ->
#xmlel{name = <<"x">>,
attrs = [{<<"xmlns">>, ?NS_DELAY91},
{<<"stamp">>, lists:flatten(
io_lib:format("~4..0w~2..0w~2..0wT~2..0w:~2..0w:~2..0w",
[Year, Month, Day, Hour, Minute, Second]))}]}.


-spec now_to_utc_string(erlang:timestamp()) -> string().
now_to_utc_string({MegaSecs, Secs, MicroSecs}) ->
{{Year, Month, Day}, {Hour, Minute, Second}} =
Expand Down
4 changes: 1 addition & 3 deletions apps/ejabberd/src/mod_muc_room.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2462,9 +2462,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
false -> FromJID
end,
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)]),
[jlib:timestamp_to_xml(TimeStamp, utc, SenderJid, <<>>)]),
SPacket = jlib:replace_from_to(
jlib:jid_replace_resource(StateData#state.jid, FromNick),
StateData#state.jid,
Expand Down
4 changes: 1 addition & 3 deletions apps/ejabberd/src/mod_offline.erl
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,8 @@ add_timestamp(undefined, _Server, Packet) ->
add_timestamp({_,_,Micro} = TimeStamp, Server, Packet) ->
{D,{H,M,S}} = calendar:now_to_universal_time(TimeStamp),
Time = {D,{H,M,S, Micro}},
%% TODO: Delete the next element once XEP-0091 is Obsolete
TimeStampLegacyXML = timestamp_legacy_xml(Server, Time),
TimeStampXML = jlib:timestamp_to_xml(Time),
xml:append_subtags(Packet, [TimeStampLegacyXML, TimeStampXML]).
xml:append_subtags(Packet, [TimeStampLegacyXML]).

timestamp_legacy_xml(Server, Time) ->
FromJID = jlib:make_jid(<<>>, Server, <<>>),
Expand Down