From: Christophe Romain
Date: Fri, 27 Feb 2009 03:09:00 +0000 (+0000)
Subject: cosmetic changes
X-Git-Tag: v2.1.0~18^2~425
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67e24366ee34ac33812cb451efed7ba290a3dde4;p=ejabberd
cosmetic changes
SVN Revision: 1923
---
diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl
index f2bf6122d..4998789fc 100644
--- a/src/mod_pubsub/mod_pubsub.erl
+++ b/src/mod_pubsub/mod_pubsub.erl
@@ -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},
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
%% pubsub_state table.
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 Write a state into database.
+%% @doc Write an item into database.
set_item(Item) when is_record(Item, pubsub_item) ->
mnesia:write(Item);
set_item(_) ->
diff --git a/src/mod_pubsub/node_pep.erl b/src/mod_pubsub/node_pep.erl
index 2c322530f..8fd6fa777 100644
--- a/src/mod_pubsub/node_pep.erl
+++ b/src/mod_pubsub/node_pep.erl
@@ -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, []};