25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +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}),
{result, {default, broadcast}}.
%% @spec (Host, Removed) -> ok
%% Host = mod_pubsub:host()
%% Removed = [mod_pubsub:pubsubNode()]
@ -559,8 +558,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,
@ -594,13 +592,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:short_prepd_bare_jid(Owner) of
{U, D, ""} -> 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 = {{U, D, R}, {Host, '_'}}, _ = '_'})
SubKey = jlib:short_prepd_jid(Owner),
GenKey = jlib:short_prepd_bare_jid(SubKey),
States = case SubKey of
GenKey -> mnesia:match_object(
#pubsub_state{stateid = {{U, D, '_'}, {Host, '_'}}, _ = '_'});
_ -> mnesia:match_object(
#pubsub_state{stateid = {GenKey, {Host, '_'}}, _ = '_'})
++ mnesia:match_object(
#pubsub_state{stateid = {SubKey, {Host, '_'}}, _ = '_'})
end,
Tr = fun(#pubsub_state{stateid = {J, {_, N}}, subscription = S}) ->
{N, S, J}
@ -608,8 +608,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,
@ -778,7 +777,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(_) ->

View File

@ -114,25 +114,25 @@ features() ->
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
LOwner = jlib:short_prepd_jid(Owner),
{User, Server, _Resource} = LOwner,
{User, Server, Resource} = LOwner,
Allowed = case LOwner of
{undefined, Host, undefined} ->
true; % pubsub service always allowed
_ ->
{LU, LS, LR} = LOwner,
case acl:match_rule(ServerHost, Access, exmpp_jid:make_jid(LU, LS, LR)) of
JID = exmpp_jid:make_jid(User, Server, Resource),
case acl:match_rule(ServerHost, Access, JID) of
allow ->
case Host of
{User, Server, _} -> true;
_ -> 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, []};