diff options
author | Christophe Romain <christophe.romain@process-one.net> | 2009-05-19 21:59:15 +0000 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2009-05-19 21:59:15 +0000 |
commit | dffe80889500a5e0f749cc57289091edacbc208f (patch) | |
tree | 21ccb64e3d9c78eb76a603af220fe7f23a43695f /src/mod_pubsub/node_pep.erl | |
parent | Added API function to get current S2S connections with information (diff) |
PubSub: improve get_entity_* API
SVN Revision: 2090
Diffstat (limited to '')
-rw-r--r-- | src/mod_pubsub/node_pep.erl | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/mod_pubsub/node_pep.erl b/src/mod_pubsub/node_pep.erl index d1d1731e..833612ae 100644 --- a/src/mod_pubsub/node_pep.erl +++ b/src/mod_pubsub/node_pep.erl @@ -180,8 +180,29 @@ get_affiliation(NodeId, Owner) -> set_affiliation(NodeId, Owner, Affiliation) -> node_default:set_affiliation(NodeId, Owner, Affiliation). -get_entity_subscriptions(_Host, _Owner) -> - {result, []}. +get_entity_subscriptions(_Host, Owner) -> + {U, D, _} = SubKey = jlib:jid_tolower(Owner), + GenKey = jlib:jid_remove_resource(SubKey), + States = case SubKey of + GenKey -> mnesia:match_object( + #pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'}); + _ -> mnesia:match_object( + #pubsub_state{stateid = {GenKey, '_'}, _ = '_'}) + ++ mnesia:match_object( + #pubsub_state{stateid = {SubKey, '_'}, _ = '_'}) + end, + Reply = lists:foldl(fun(#pubsub_state{stateid = {J, N}, subscription = S}, Acc) -> + case mnesia:index_read(pubsub_node, N, #pubsub_node.id) of + [#pubsub_node{nodeid = {H, _}} = Node] -> + case H of + {_, D, _} -> [{Node, S, J}|Acc]; + _ -> Acc + end; + _ -> + Acc + end + end, [], States), + {result, Reply}. get_node_subscriptions(NodeId) -> %% note: get_node_subscriptions is used for broadcasting @@ -191,11 +212,11 @@ get_node_subscriptions(NodeId) -> %% DO NOT REMOVE node_default:get_node_subscriptions(NodeId). -get_subscription(_NodeId, _Owner) -> - {result, none}. +get_subscription(NodeId, Owner) -> + node_default:get_subscription(NodeId, Owner). -set_subscription(_NodeId, _Owner, _Subscription) -> - ok. +set_subscription(NodeId, Owner, Subscription) -> + node_default:set_subscription(NodeId, Owner, Subscription). get_states(NodeId) -> node_default:get_states(NodeId). |