From c93bf732dbfa6ed78140eadc1df4aa78bd76ebb7 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Thu, 30 Mar 2017 14:26:30 +0200 Subject: [PATCH] Refactor pubsub's get_last_items --- include/pubsub.hrl | 2 + src/gen_pubsub_node.erl | 3 + src/mod_pubsub.erl | 135 ++++++++++++++-------------------------- src/node_buddy.erl | 4 ++ src/node_club.erl | 4 ++ src/node_dag.erl | 4 ++ src/node_dispatch.erl | 4 ++ src/node_flat.erl | 30 ++++++--- src/node_flat_sql.erl | 3 +- src/node_hometree.erl | 4 ++ src/node_mb.erl | 4 ++ src/node_mix.erl | 4 ++ src/node_mix_sql.erl | 4 ++ src/node_online.erl | 4 ++ src/node_pep.erl | 4 ++ src/node_private.erl | 4 ++ src/node_public.erl | 4 ++ 17 files changed, 123 insertions(+), 98 deletions(-) diff --git a/include/pubsub.hrl b/include/pubsub.hrl index b2bc05c99..86cdb515d 100644 --- a/include/pubsub.hrl +++ b/include/pubsub.hrl @@ -145,6 +145,7 @@ -record(pubsub_state, { stateid ,% :: {jlib:ljid(), mod_pubsub:nodeIdx()}, + nodeidx ,% :: mod_pubsub:nodeIdx(), items = [] ,% :: [mod_pubsub:itemId(),...], affiliation = 'none',% :: mod_pubsub:affiliation(), subscriptions = [] % :: [{mod_pubsub:subscription(), mod_pubsub:subId()}] @@ -153,6 +154,7 @@ -record(pubsub_item, { itemid ,% :: {mod_pubsub:itemId(), mod_pubsub:nodeIdx()}, + nodeidx ,% :: mod_pubsub:nodeIdx(), creation = {unknown, unknown},% :: {erlang:timestamp(), jlib:ljid()}, modification = {unknown, unknown},% :: {erlang:timestamp(), jlib:ljid()}, payload = [] % :: mod_pubsub:payload() diff --git a/src/gen_pubsub_node.erl b/src/gen_pubsub_node.erl index 477fafc46..4f516bd58 100644 --- a/src/gen_pubsub_node.erl +++ b/src/gen_pubsub_node.erl @@ -183,6 +183,9 @@ -callback get_items(nodeIdx(), jid(), undefined | rsm_set()) -> {result, {[pubsubItem()], undefined | rsm_set()}}. +-callback get_last_items(nodeIdx(), jid(), undefined | rsm_set()) -> + {result, {[pubsubItem()], undefined | rsm_set()}}. + -callback get_item(NodeIdx :: nodeIdx(), ItemId :: itemId(), JID :: jid(), diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index 6218af227..e9d9769a5 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -152,6 +152,7 @@ -type(pubsubState() :: #pubsub_state{ stateid :: {Entity::ljid(), Nidx::mod_pubsub:nodeIdx()}, + nodeidx :: Nidx::mod_pubsub:nodeIdx(), items :: [ItemId::mod_pubsub:itemId()], affiliation :: Affs::mod_pubsub:affiliation(), subscriptions :: [{Sub::mod_pubsub:subscription(), SubId::mod_pubsub:subId()}] @@ -161,6 +162,7 @@ -type(pubsubItem() :: #pubsub_item{ itemid :: {ItemId::mod_pubsub:itemId(), Nidx::mod_pubsub:nodeIdx()}, + nodeidx :: Nidx::mod_pubsub:nodeIdx(), creation :: {erlang:timestamp(), ljid()}, modification :: {erlang:timestamp(), ljid()}, payload :: mod_pubsub:payload() @@ -2165,48 +2167,21 @@ get_allowed_items_call(Host, Nidx, From, Type, Options, Owners, RSM) -> {PS, RG} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups), node_call(Host, Type, get_items, [Nidx, From, AccessModel, PS, RG, undefined, RSM]). -get_last_item(Host, Type, Nidx, LJID) -> - case get_cached_item(Host, Nidx) of - undefined -> get_last_item(Host, Type, Nidx, LJID, gen_mod:db_type(serverhost(Host), ?MODULE)); - LastItem -> LastItem - end. -get_last_item(Host, Type, Nidx, LJID, mnesia) -> - case node_action(Host, Type, get_items, [Nidx, LJID, undefined]) of - {result, {[LastItem|_], _}} -> LastItem; - _ -> undefined - end; -get_last_item(Host, Type, Nidx, LJID, sql) -> - case node_action(Host, Type, get_last_items, [Nidx, LJID, 1]) of - {result, [LastItem]} -> LastItem; - _ -> undefined - end; -get_last_item(_Host, _Type, _Nidx, _LJID, _) -> - undefined. - -get_last_items(Host, Type, Nidx, LJID, Number) -> - get_last_items(Host, Type, Nidx, LJID, Number, gen_mod:db_type(serverhost(Host), ?MODULE)). -get_last_items(Host, Type, Nidx, LJID, Number, mnesia) -> - case node_action(Host, Type, get_items, [Nidx, LJID, undefined]) of - {result, {Items, _}} -> lists:sublist(Items, Number); - _ -> [] - end; -get_last_items(Host, Type, Nidx, LJID, Number, sql) -> - case node_action(Host, Type, get_last_items, [Nidx, LJID, Number]) of +get_last_items(Host, Type, Nidx, LJID, Count) -> + case node_action(Host, Type, get_last_items, [Nidx, LJID, Count]) of {result, Items} -> Items; _ -> [] - end; -get_last_items(_Host, _Type, _Nidx, _LJID, _Number, _) -> - []. + end. %% @doc

Resend the items of a node to the user.

%% @todo use cache-last-item feature send_items(Host, Node, Nidx, Type, Options, LJID, last) -> - case get_last_item(Host, Type, Nidx, LJID) of - undefined -> - ok; - LastItem -> + case get_last_items(Host, Type, Nidx, LJID, 1) of + [LastItem] -> Stanza = items_event_stanza(Node, Options, [LastItem]), - dispatch_items(Host, LJID, Node, Stanza) + dispatch_items(Host, LJID, Node, Stanza); + _ -> + ok end; send_items(Host, Node, Nidx, Type, Options, LJID, Number) when Number > 0 -> Stanza = items_event_stanza(Node, Options, get_last_items(Host, Type, Nidx, Number, LJID)), @@ -2566,28 +2541,21 @@ get_subscriptions(Host, Node, JID) -> Error end. -get_subscriptions_for_send_last(Host, PType, mnesia, JID, LJID, BJID) -> +get_subscriptions_for_send_last(Host, PType, sql, JID, LJID, BJID) -> + {result, Subs} = node_action(Host, PType, + get_entity_subscriptions_for_send_last, + [Host, JID]), + [{Node, Sub, SubId, SubJID} + || {Node, Sub, SubId, SubJID} <- Subs, + Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID)]; +get_subscriptions_for_send_last(Host, PType, _, JID, LJID, BJID) -> {result, Subs} = node_action(Host, PType, get_entity_subscriptions, [Host, JID]), [{Node, Sub, SubId, SubJID} || {Node, Sub, SubId, SubJID} <- Subs, Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID), - match_option(Node, send_last_published_item, on_sub_and_presence)]; -get_subscriptions_for_send_last(Host, PType, sql, JID, LJID, BJID) -> - case catch node_action(Host, PType, - get_entity_subscriptions_for_send_last, - [Host, JID]) - of - {result, Subs} -> - [{Node, Sub, SubId, SubJID} - || {Node, Sub, SubId, SubJID} <- Subs, - Sub =:= subscribed, (SubJID == LJID) or (SubJID == BJID)]; - _ -> - [] - end; -get_subscriptions_for_send_last(_Host, _PType, _, _JID, _LJID, _BJID) -> - []. + match_option(Node, send_last_published_item, on_sub_and_presence)]. -spec set_subscriptions(host(), binary(), jid(), [ps_subscription()]) -> {result, undefined} | {error, stanza_error()}. @@ -3202,28 +3170,18 @@ filter_node_options(Options, BaseOptions) -> -spec node_owners_action(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()]. node_owners_action(Host, Type, Nidx, []) -> - case gen_mod:db_type(serverhost(Host), ?MODULE) of - sql -> - case node_action(Host, Type, get_node_affiliations, [Nidx]) of - {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner]; - _ -> [] - end; - _ -> - [] + case node_action(Host, Type, get_node_affiliations, [Nidx]) of + {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner]; + _ -> [] end; node_owners_action(_Host, _Type, _Nidx, Owners) -> Owners. -spec node_owners_call(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()]. node_owners_call(Host, Type, Nidx, []) -> - case gen_mod:db_type(serverhost(Host), ?MODULE) of - sql -> - case node_call(Host, Type, get_node_affiliations, [Nidx]) of - {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner]; - _ -> [] - end; - _ -> - [] + case node_call(Host, Type, get_node_affiliations, [Nidx]) of + {result, Affs} -> [LJID || {LJID, Aff} <- Affs, Aff =:= owner]; + _ -> [] end; node_owners_call(_Host, _Type, _Nidx, Owners) -> Owners. @@ -3468,23 +3426,15 @@ tree(Host) -> Tree -> Tree end. --spec tree(host(), binary() | atom()) -> atom(). +-spec tree(host(), binary()) -> atom(). tree(_Host, <<"virtual">>) -> nodetree_virtual; % special case, virtual does not use any backend tree(Host, Name) -> - case gen_mod:db_type(serverhost(Host), ?MODULE) of - mnesia -> aux:binary_to_atom(<<"nodetree_", Name/binary>>); - sql -> aux:binary_to_atom(<<"nodetree_", Name/binary, "_sql">>); - _ -> Name - end. + submodule(Host, <<"nodetree_", Name/binary>>). --spec plugin(host(), binary() | atom()) -> atom(). +-spec plugin(host(), binary()) -> atom(). plugin(Host, Name) -> - case gen_mod:db_type(serverhost(Host), ?MODULE) of - mnesia -> aux:binary_to_atom(<<"node_", Name/binary>>); - sql -> aux:binary_to_atom(<<"node_", Name/binary, "_sql">>); - _ -> Name - end. + submodule(Host, <<"node_", Name/binary>>). -spec plugins(host()) -> [binary()]. plugins(Host) -> @@ -3494,14 +3444,16 @@ plugins(Host) -> Plugins -> Plugins end. --spec subscription_plugin(host()) -> pubsub_subscription | - pubsub_subscription_sql | - none. +-spec subscription_plugin(host()) -> atom(). subscription_plugin(Host) -> + submodule(Host, <<"pubsub_subscription">>). + +-spec submodule(host(), binary()) -> atom(). +submodule(Host, Name) -> case gen_mod:db_type(serverhost(Host), ?MODULE) of - mnesia -> pubsub_subscription; - sql -> pubsub_subscription_sql; - _ -> none + mnesia -> aux:binary_to_atom(Name); + Type -> aux:binary_to_atom(<>) end. -spec config(binary(), any()) -> any(). @@ -3614,9 +3566,14 @@ tree_action(Host, Function, Args) -> {error, xmpp:err_internal_server_error(ErrTxt, ?MYLANG)} end; Other -> - ?ERROR_MSG("unsupported backend: ~p~n", [Other]), - ErrTxt = <<"Database failure">>, - {error, xmpp:err_internal_server_error(ErrTxt, ?MYLANG)} + case catch Fun() of + {'EXIT', _} -> + ?ERROR_MSG("unsupported backend: ~p~n", [Other]), + ErrTxt = <<"Database failure">>, + {error, xmpp:err_internal_server_error(ErrTxt, ?MYLANG)}; + Result -> + Result + end end. %% @doc

node plugin call.

@@ -3684,7 +3641,7 @@ transaction_retry(Host, ServerHost, Fun, Trans, DBType, Count) -> end, catch ejabberd_sql:SqlFun(ServerHost, Fun); _ -> - {unsupported, DBType} + catch Fun() end, case Res of {result, Result} -> diff --git a/src/node_buddy.erl b/src/node_buddy.erl index a01332b67..6f126518c 100644 --- a/src/node_buddy.erl +++ b/src/node_buddy.erl @@ -39,6 +39,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -157,6 +158,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId). diff --git a/src/node_club.erl b/src/node_club.erl index 54ee5d763..2f674760d 100644 --- a/src/node_club.erl +++ b/src/node_club.erl @@ -39,6 +39,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId). diff --git a/src/node_dag.erl b/src/node_dag.erl index c81b2bc80..9829c27cb 100644 --- a/src/node_dag.erl +++ b/src/node_dag.erl @@ -40,6 +40,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -144,6 +145,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_hometree:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_hometree:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_hometree:get_item(Nidx, ItemId). diff --git a/src/node_dispatch.erl b/src/node_dispatch.erl index bde20e772..92a655b8b 100644 --- a/src/node_dispatch.erl +++ b/src/node_dispatch.erl @@ -46,6 +46,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -170,6 +171,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_hometree:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_hometree:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_hometree:get_item(Nidx, ItemId). diff --git a/src/node_flat.erl b/src/node_flat.erl index 907858428..3989e0d94 100644 --- a/src/node_flat.erl +++ b/src/node_flat.erl @@ -46,17 +46,18 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1, can_fetch_item/2, is_subscribed/1]). + path_to_node/1, can_fetch_item/2, is_subscribed/1, transform/1]). init(_Host, _ServerHost, _Opts) -> %pubsub_subscription:init(Host, ServerHost, Opts), ejabberd_mnesia:create(?MODULE, pubsub_state, - [{disc_copies, [node()]}, + [{disc_copies, [node()]}, {index, [nodeidx]}, {type, ordered_set}, {attributes, record_info(fields, pubsub_state)}]), ejabberd_mnesia:create(?MODULE, pubsub_item, - [{disc_only_copies, [node()]}, + [{disc_only_copies, [node()]}, {index, [nodeidx]}, {attributes, record_info(fields, pubsub_item)}]), ejabberd_mnesia:create(?MODULE, pubsub_orphan, [{disc_copies, [node()]}, @@ -131,7 +132,7 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) -> create_node(Nidx, Owner) -> OwnerKey = jid:tolower(jid:remove_resource(Owner)), set_state(#pubsub_state{stateid = {OwnerKey, Nidx}, - affiliation = owner}), + nodeidx = Nidx, affiliation = owner}), {result, {default, broadcast}}. delete_node(Nodes) -> @@ -382,6 +383,7 @@ publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload, payload = Payload}; _ -> #pubsub_item{itemid = {ItemId, Nidx}, + nodeidx = Nidx, creation = {Now, GenKey}, modification = PubId, payload = Payload} @@ -681,8 +683,7 @@ get_nodes_helper(NodeTree, #pubsub_state{stateid = {_, N}, subscriptions = Subs} %% ```get_states(Nidx) -> %% node_default:get_states(Nidx).'''

get_states(Nidx) -> - States = case catch mnesia:match_object( - #pubsub_state{stateid = {'_', Nidx}, _ = '_'}) of + States = case catch mnesia:index_read(pubsub_state, Nidx, #pubsub_state.nodeidx) of List when is_list(List) -> List; _ -> [] end, @@ -693,7 +694,7 @@ get_state(Nidx, Key) -> StateId = {Key, Nidx}, case catch mnesia:read({pubsub_state, StateId}) of [State] when is_record(State, pubsub_state) -> State; - _ -> #pubsub_state{stateid = StateId} + _ -> #pubsub_state{stateid = StateId, nodeidx = Nidx} end. %% @doc

Write a state into database.

@@ -725,7 +726,7 @@ del_state(#pubsub_state{stateid = {Key, Nidx}, items = Items}) -> %%

PubSub plugins can store the items where they wants (for example in a %% relational database), or they can even decide not to persist any items.

get_items(Nidx, _From, _RSM) -> - Items = mnesia:match_object(#pubsub_item{itemid = {'_', Nidx}, _ = '_'}), + Items = mnesia:index_read(pubsub_item, Nidx, #pubsub_item.nodeidx), {result, {lists:reverse(lists:keysort(#pubsub_item.modification, Items)), undefined}}. get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) -> @@ -764,6 +765,12 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM get_items(Nidx, JID, RSM) end. +get_last_items(Nidx, From, Count) when Count > 0 -> + {result, {Items, _}} = get_items(Nidx, From, undefined), + {result, lists:sublist(Items, Count)}; +get_last_items(_Nidx, _From, _Count) -> + {result, []}. + %% @doc

Returns an item (one item list), given its reference.

get_item(Nidx, ItemId) -> @@ -868,3 +875,10 @@ first_in_list(Pred, [H | T]) -> true -> {value, H}; _ -> first_in_list(Pred, T) end. + +transform({pubsub_state, {Id, Nidx}, Is, A, Ss}) -> + {pubsub_state, {Id, Nidx}, Nidx, Is, A, Ss}; +transform({pubsub_item, {Id, Nidx}, C, M, P}) -> + {pubsub_item, {Id, Nidx}, Nidx, C, M, P}; +transform(Rec) -> + Rec. diff --git a/src/node_flat_sql.erl b/src/node_flat_sql.erl index e133a8e73..8127d2619 100644 --- a/src/node_flat_sql.erl +++ b/src/node_flat_sql.erl @@ -615,10 +615,11 @@ get_state_without_itemids(Nidx, JID) -> "where nodeid=%(Nidx)d and jid=%(J)s")) of {selected, [{SJID, Aff, Subs}]} -> #pubsub_state{stateid = {decode_jid(SJID), Nidx}, + nodeidx = Nidx, affiliation = decode_affiliation(Aff), subscriptions = decode_subscriptions(Subs)}; _ -> - #pubsub_state{stateid = {JID, Nidx}} + #pubsub_state{stateid = {JID, Nidx}, nodeidx = Nidx} end. set_state(State) -> diff --git a/src/node_hometree.erl b/src/node_hometree.erl index 1255c3d5f..ddefa30cf 100644 --- a/src/node_hometree.erl +++ b/src/node_hometree.erl @@ -39,6 +39,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -154,6 +155,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId). diff --git a/src/node_mb.erl b/src/node_mb.erl index 04370f61f..132060319 100644 --- a/src/node_mb.erl +++ b/src/node_mb.erl @@ -53,6 +53,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -171,6 +172,9 @@ get_items(Nidx, From, RSM) -> get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> node_pep:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_pep:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_pep:get_item(Nidx, ItemId). diff --git a/src/node_mix.erl b/src/node_mix.erl index 485782a9c..2d394aaa6 100644 --- a/src/node_mix.erl +++ b/src/node_mix.erl @@ -37,6 +37,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -161,6 +162,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId). diff --git a/src/node_mix_sql.erl b/src/node_mix_sql.erl index de7319fa7..5ba2cd21d 100644 --- a/src/node_mix_sql.erl +++ b/src/node_mix_sql.erl @@ -37,6 +37,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1, get_entity_subscriptions_for_send_last/2]). @@ -161,6 +162,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat_sql:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat_sql:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat_sql:get_item(Nidx, ItemId). diff --git a/src/node_online.erl b/src/node_online.erl index 56357a652..39b08d992 100644 --- a/src/node_online.erl +++ b/src/node_online.erl @@ -40,6 +40,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId). diff --git a/src/node_pep.erl b/src/node_pep.erl index c79df4e15..6dd7a68c4 100644 --- a/src/node_pep.erl +++ b/src/node_pep.erl @@ -43,6 +43,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1, depends/3]). @@ -228,6 +229,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId). diff --git a/src/node_private.erl b/src/node_private.erl index 6cf50bfc2..9738d3b86 100644 --- a/src/node_private.erl +++ b/src/node_private.erl @@ -39,6 +39,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId). diff --git a/src/node_public.erl b/src/node_public.erl index 84e71590e..bfa45230d 100644 --- a/src/node_public.erl +++ b/src/node_public.erl @@ -39,6 +39,7 @@ get_subscriptions/2, set_subscriptions/4, get_pending_nodes/2, get_states/1, get_state/2, set_state/1, get_items/7, get_items/3, get_item/7, + get_last_items/3, get_item/2, set_item/1, get_item_name/3, node_to_path/1, path_to_node/1]). @@ -156,6 +157,9 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) node_flat:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). +get_last_items(Nidx, From, Count) -> + node_flat:get_last_items(Nidx, From, Count). + get_item(Nidx, ItemId) -> node_flat:get_item(Nidx, ItemId).