]> granicus.if.org Git - ejabberd/commitdiff
cosmetic changes
authorChristophe Romain <christophe.romain@process-one.net>
Fri, 27 Feb 2009 03:09:00 +0000 (03:09 +0000)
committerChristophe Romain <christophe.romain@process-one.net>
Fri, 27 Feb 2009 03:09:00 +0000 (03:09 +0000)
SVN Revision: 1923

src/mod_pubsub/mod_pubsub.erl
src/mod_pubsub/node_default.erl
src/mod_pubsub/node_pep.erl

index f2bf6122d0e921e5f119a4b724fd45636d952175..4998789fc8d36fa75ca0fe89260291630fd4719f 100644 (file)
@@ -1064,7 +1064,7 @@ find_authorization_response(Packet) ->
        [invalid] -> invalid;
        [] -> none;
        [XFields] when is_list(XFields) ->
-            ?DEBUG("XFields: ~p", [XFields]),
+           ?DEBUG("XFields: ~p", [XFields]),
            case lists:keysearch("FORM_TYPE", 1, XFields) of
                {value, {_, [?NS_PUBSUB_SUB_AUTH]}} ->
                    XFields;
@@ -2810,7 +2810,8 @@ transaction(Fun, Trans) ->
 
 %% Add pubsub-specific error element
 extended_error(Error, Ext) ->
-    extended_error(Error, Ext, [{"xmlns", ?NS_PUBSUB_ERRORS}]).
+    extended_error(Error, Ext,
+                  [{"xmlns", ?NS_PUBSUB_ERRORS}]).
 extended_error(Error, unsupported, Feature) ->
     extended_error(Error, "unsupported",
                   [{"xmlns", ?NS_PUBSUB_ERRORS},
index f6369f0df7a379a7ea82d459c6b8aec94c20d75c..42d53c2d2fa1df53fb86e1ee2137cba8bf9a9937 100644 (file)
@@ -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(_) ->
index 2c322530ffe1299ce5e3b2fc43ebfc24b1e1b582..8fd6fa7775f167d5577d21535cf5da815c3a49d5 100644 (file)
@@ -113,7 +113,7 @@ features() ->
 
 create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
     LOwner = jlib:jid_tolower(Owner),
-    {User, Server, _Resource} = LOwner, 
+    {User, Server, _Resource} = LOwner,
     Allowed = case LOwner of
        {"", Host, ""} ->
            true; % pubsub service always allowed
@@ -125,12 +125,12 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
                        _ -> false
                    end;
                E ->
-                       ?DEBUG("Create not allowed : ~p~n", [E]),
-                   false   
+                   ?DEBUG("Create not allowed : ~p~n", [E]),
+                   false
            end
     end,
     {result, Allowed}.
-    
+
 create_node(Host, Node, Owner) ->
     case node_default:create_node(Host, Node, Owner) of
        {result, _} -> {result, []};