25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

cosmetic changes

SVN Revision: 1924
This commit is contained in:
Christophe Romain 2009-02-27 03:19:53 +00:00
parent dd5a7bcd54
commit f4a952032a
2 changed files with 18 additions and 19 deletions

View File

@ -226,7 +226,6 @@ create_node(Host, Node, Owner) ->
set_state(#pubsub_state{stateid = {OwnerKey, {Host, Node}}, affiliation = owner}), set_state(#pubsub_state{stateid = {OwnerKey, {Host, Node}}, affiliation = owner}),
{result, {default, broadcast}}. {result, {default, broadcast}}.
%% @spec (Host, Removed) -> ok %% @spec (Host, Removed) -> ok
%% Host = mod_pubsub:host() %% Host = mod_pubsub:host()
%% Removed = [mod_pubsub:pubsubNode()] %% Removed = [mod_pubsub:pubsubNode()]
@ -559,8 +558,7 @@ get_entity_affiliations(Host, Owner) ->
{result, lists:map(Tr, States)}. {result, lists:map(Tr, States)}.
get_node_affiliations(Host, Node) -> get_node_affiliations(Host, Node) ->
States = mnesia:match_object( {result, States} = get_states(Host, Node),
#pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}),
Tr = fun(#pubsub_state{stateid = {J, {_, _}}, affiliation = A}) -> Tr = fun(#pubsub_state{stateid = {J, {_, _}}, affiliation = A}) ->
{J, A} {J, A}
end, end,
@ -594,13 +592,15 @@ set_affiliation(Host, Node, Owner, Affiliation) ->
%% that will be added to the affiliation stored in the main %% that will be added to the affiliation stored in the main
%% <tt>pubsub_state</tt> table.</p> %% <tt>pubsub_state</tt> table.</p>
get_entity_subscriptions(Host, Owner) -> get_entity_subscriptions(Host, Owner) ->
States = case jlib:short_prepd_bare_jid(Owner) of SubKey = jlib:short_prepd_jid(Owner),
{U, D, ""} -> mnesia:match_object( GenKey = jlib:short_prepd_bare_jid(SubKey),
#pubsub_state{stateid = {{U, D, '_'}, {Host, '_'}}, _ = '_'}); States = case SubKey of
{U, D, R} -> mnesia:match_object( GenKey -> mnesia:match_object(
#pubsub_state{stateid = {{U, D, ""}, {Host, '_'}}, _ = '_'}) #pubsub_state{stateid = {{U, D, '_'}, {Host, '_'}}, _ = '_'});
++ mnesia:match_object( _ -> mnesia:match_object(
#pubsub_state{stateid = {{U, D, R}, {Host, '_'}}, _ = '_'}) #pubsub_state{stateid = {GenKey, {Host, '_'}}, _ = '_'})
++ mnesia:match_object(
#pubsub_state{stateid = {SubKey, {Host, '_'}}, _ = '_'})
end, end,
Tr = fun(#pubsub_state{stateid = {J, {_, N}}, subscription = S}) -> Tr = fun(#pubsub_state{stateid = {J, {_, N}}, subscription = S}) ->
{N, S, J} {N, S, J}
@ -608,8 +608,7 @@ get_entity_subscriptions(Host, Owner) ->
{result, lists:map(Tr, States)}. {result, lists:map(Tr, States)}.
get_node_subscriptions(Host, Node) -> get_node_subscriptions(Host, Node) ->
States = mnesia:match_object( {result, States} = get_states(Host, Node),
#pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}),
Tr = fun(#pubsub_state{stateid = {J, {_, _}}, subscription = S}) -> Tr = fun(#pubsub_state{stateid = {J, {_, _}}, subscription = S}) ->
{J, S} {J, S}
end, end,
@ -778,7 +777,7 @@ get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup
%% @spec (Item) -> ok | {error, Reason::stanzaError()} %% @spec (Item) -> ok | {error, Reason::stanzaError()}
%% Item = mod_pubsub:pubsubItems() %% 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) -> set_item(Item) when is_record(Item, pubsub_item) ->
mnesia:write(Item); mnesia:write(Item);
set_item(_) -> set_item(_) ->

View File

@ -114,25 +114,25 @@ features() ->
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) -> create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
LOwner = jlib:short_prepd_jid(Owner), LOwner = jlib:short_prepd_jid(Owner),
{User, Server, _Resource} = LOwner, {User, Server, Resource} = LOwner,
Allowed = case LOwner of Allowed = case LOwner of
{undefined, Host, undefined} -> {undefined, Host, undefined} ->
true; % pubsub service always allowed true; % pubsub service always allowed
_ -> _ ->
{LU, LS, LR} = LOwner, JID = exmpp_jid:make_jid(User, Server, Resource),
case acl:match_rule(ServerHost, Access, exmpp_jid:make_jid(LU, LS, LR)) of case acl:match_rule(ServerHost, Access, JID) of
allow -> allow ->
case Host of case Host of
{User, Server, _} -> true; {User, Server, _} -> true;
_ -> false _ -> false
end; end;
E -> E ->
?DEBUG("Create not allowed : ~p~n", [E]), ?DEBUG("Create not allowed : ~p~n", [E]),
false false
end end
end, end,
{result, Allowed}. {result, Allowed}.
create_node(Host, Node, Owner) -> create_node(Host, Node, Owner) ->
case node_default:create_node(Host, Node, Owner) of case node_default:create_node(Host, Node, Owner) of
{result, _} -> {result, []}; {result, _} -> {result, []};