Remove now() in pubsub code

This commit is contained in:
Paweł Chmielowski 2015-12-07 16:16:11 +01:00
parent 29db302808
commit 5ac10d6555
6 changed files with 9 additions and 9 deletions

View File

@ -3141,7 +3141,7 @@ sub_option_can_deliver(nodes, _, {subscription_type, items}) -> false;
sub_option_can_deliver(_, _, {subscription_depth, all}) -> true; sub_option_can_deliver(_, _, {subscription_depth, all}) -> true;
sub_option_can_deliver(_, Depth, {subscription_depth, D}) -> Depth =< D; sub_option_can_deliver(_, Depth, {subscription_depth, D}) -> Depth =< D;
sub_option_can_deliver(_, _, {deliver, false}) -> false; sub_option_can_deliver(_, _, {deliver, false}) -> false;
sub_option_can_deliver(_, _, {expire, When}) -> now() < When; sub_option_can_deliver(_, _, {expire, When}) -> p1_time_compat:timestamp() < When;
sub_option_can_deliver(_, _, _) -> true. sub_option_can_deliver(_, _, _) -> true.
-spec(presence_can_deliver/2 :: -spec(presence_can_deliver/2 ::
@ -3910,7 +3910,7 @@ set_cached_item({_, ServerHost, _}, Nidx, ItemId, Publisher, Payload) ->
set_cached_item(Host, Nidx, ItemId, Publisher, Payload) -> set_cached_item(Host, Nidx, ItemId, Publisher, Payload) ->
case is_last_item_cache_enabled(Host) of case is_last_item_cache_enabled(Host) of
true -> mnesia:dirty_write({pubsub_last_item, Nidx, ItemId, true -> mnesia:dirty_write({pubsub_last_item, Nidx, ItemId,
{now(), jid:tolower(jid:remove_resource(Publisher))}, {p1_time_compat:timestamp(), jid:tolower(jid:remove_resource(Publisher))},
Payload}); Payload});
_ -> ok _ -> ok
end. end.
@ -4218,7 +4218,7 @@ string_to_ljid(JID) ->
-spec(uniqid/0 :: () -> mod_pubsub:itemId()). -spec(uniqid/0 :: () -> mod_pubsub:itemId()).
uniqid() -> uniqid() ->
{T1, T2, T3} = now(), {T1, T2, T3} = p1_time_compat:timestamp(),
iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])). iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
nodeAttr(Node) -> [{<<"node">>, Node}]. nodeAttr(Node) -> [{<<"node">>, Node}].

View File

@ -362,7 +362,7 @@ publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
{error, ?ERR_FORBIDDEN}; {error, ?ERR_FORBIDDEN};
true -> true ->
if MaxItems > 0 -> if MaxItems > 0 ->
Now = now(), Now = p1_time_compat:timestamp(),
PubId = {Now, SubKey}, PubId = {Now, SubKey},
Item = case get_item(Nidx, ItemId) of Item = case get_item(Nidx, ItemId) of
{result, OldItem} -> {result, OldItem} ->

View File

@ -223,9 +223,9 @@ publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
{error, ?ERR_FORBIDDEN}; {error, ?ERR_FORBIDDEN};
true -> true ->
if MaxItems > 0 -> if MaxItems > 0 ->
PubId = {now(), SubKey}, PubId = {p1_time_compat:timestamp(), SubKey},
set_item(#pubsub_item{itemid = {ItemId, Nidx}, set_item(#pubsub_item{itemid = {ItemId, Nidx},
creation = {now(), GenKey}, creation = {p1_time_compat:timestamp(), GenKey},
modification = PubId, modification = PubId,
payload = Payload}), payload = Payload}),
Items = [ItemId | itemids(Nidx, GenKey) -- [ItemId]], Items = [ItemId | itemids(Nidx, GenKey) -- [ItemId]],

View File

@ -157,7 +157,7 @@ update_node_database(Host, ServerHost) ->
{unknown, {unknown,
Publisher}, Publisher},
M = M =
{now(), {p1_time_compat:timestamp(),
Publisher}, Publisher},
mnesia:write(#pubsub_item{itemid mnesia:write(#pubsub_item{itemid
= =

View File

@ -202,7 +202,7 @@ write_subscription(_JID, _NodeId, SubID, Options) ->
-spec(make_subid/0 :: () -> SubId::mod_pubsub:subId()). -spec(make_subid/0 :: () -> SubId::mod_pubsub:subId()).
make_subid() -> make_subid() ->
{T1, T2, T3} = now(), {T1, T2, T3} = p1_time_compat:timestamp(),
iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])). iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
%% %%

View File

@ -165,7 +165,7 @@ create_table() -> ok.
-spec(make_subid/0 :: () -> mod_pubsub:subId()). -spec(make_subid/0 :: () -> mod_pubsub:subId()).
make_subid() -> make_subid() ->
{T1, T2, T3} = now(), {T1, T2, T3} = p1_time_compat:timestamp(),
iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])). iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
%% %%