diff options
Diffstat (limited to 'src/mod_pubsub/node_default.erl')
-rw-r--r-- | src/mod_pubsub/node_default.erl | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/mod_pubsub/node_default.erl b/src/mod_pubsub/node_default.erl index f6369f0df..42d53c2d2 100644 --- a/src/mod_pubsub/node_default.erl +++ b/src/mod_pubsub/node_default.erl @@ -224,7 +224,6 @@ create_node(Host, Node, Owner) -> set_state(#pubsub_state{stateid = {OwnerKey, {Host, Node}}, affiliation = owner}), {result, {default, broadcast}}. - %% @spec (Host, Removed) -> ok %% Host = mod_pubsub:host() %% Removed = [mod_pubsub:pubsubNode()] @@ -560,8 +559,7 @@ get_entity_affiliations(Host, Owner) -> {result, lists:map(Tr, States)}. get_node_affiliations(Host, Node) -> - States = mnesia:match_object( - #pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}), + {result, States} = get_states(Host, Node), Tr = fun(#pubsub_state{stateid = {J, {_, _}}, affiliation = A}) -> {J, A} end, @@ -597,13 +595,15 @@ set_affiliation(Host, Node, Owner, Affiliation) -> %% that will be added to the affiliation stored in the main %% <tt>pubsub_state</tt> table.</p> get_entity_subscriptions(Host, Owner) -> - States = case jlib:jid_tolower(Owner) of - {U, D, ""} -> mnesia:match_object( + SubKey = jlib:jid_tolower(Owner), + GenKey = jlib:jid_remove_resource(SubKey), + States = case SubKey of + GenKey -> mnesia:match_object( #pubsub_state{stateid = {{U, D, '_'}, {Host, '_'}}, _ = '_'}); - {U, D, R} -> mnesia:match_object( - #pubsub_state{stateid = {{U, D, ""}, {Host, '_'}}, _ = '_'}) + _ -> mnesia:match_object( + #pubsub_state{stateid = {GenKey, {Host, '_'}}, _ = '_'}) ++ mnesia:match_object( - #pubsub_state{stateid = {{U, D, R}, {Host, '_'}}, _ = '_'}) + #pubsub_state{stateid = {SubKey, {Host, '_'}}, _ = '_'}) end, Tr = fun(#pubsub_state{stateid = {J, {_, N}}, subscription = S}) -> {N, S, J} @@ -611,8 +611,7 @@ get_entity_subscriptions(Host, Owner) -> {result, lists:map(Tr, States)}. get_node_subscriptions(Host, Node) -> - States = mnesia:match_object( - #pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}), + {result, States} = get_states(Host, Node), Tr = fun(#pubsub_state{stateid = {J, {_, _}}, subscription = S}) -> {J, S} end, @@ -783,7 +782,7 @@ get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup %% @spec (Item) -> ok | {error, Reason::stanzaError()} %% Item = mod_pubsub:pubsubItems() -%% @doc <p>Write a state into database.</p> +%% @doc <p>Write an item into database.</p> set_item(Item) when is_record(Item, pubsub_item) -> mnesia:write(Item); set_item(_) -> |