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

cosmetic changes, move badly placed comments

This commit is contained in:
Christophe Romain 2013-06-14 00:04:25 +02:00
parent 4d8f770624
commit 26b815f52d
5 changed files with 143 additions and 220 deletions

View File

@ -1286,17 +1286,6 @@ remove_user(User, Server) ->
LServer = jlib:nameprep(Server), LServer = jlib:nameprep(Server),
Entity = jlib:make_jid(LUser, LServer, <<"">>), Entity = jlib:make_jid(LUser, LServer, <<"">>),
Host = host(LServer), Host = host(LServer),
%%--------------------------------------------------------------------
%% Function:
%% handle_call(Request, From, State) -> {reply, Reply, State} |
%% {reply, Reply, State, Timeout} |
%% {noreply, State} |
%% {noreply, State, Timeout} |
%% {stop, Reason, Reply, State} |
%% {stop, Reason, State}
%% Description: Handling call messages
%%--------------------------------------------------------------------
%% @private
HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>, HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>,
spawn(fun () -> spawn(fun () ->
lists:foreach(fun (PType) -> lists:foreach(fun (PType) ->
@ -1375,13 +1364,6 @@ handle_call(stop, _From, State) ->
%% Description: Handling cast messages %% Description: Handling cast messages
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @private %% @private
%%--------------------------------------------------------------------
%% Function: handle_info(Info, State) -> {noreply, State} |
%% {noreply, State, Timeout} |
%% {stop, Reason, State}
%% Description: Handling all non call/cast messages
%%--------------------------------------------------------------------
%% @private
handle_cast(_Msg, State) -> {noreply, State}. handle_cast(_Msg, State) -> {noreply, State}.
-spec(handle_info/2 :: -spec(handle_info/2 ::
@ -1391,6 +1373,13 @@ handle_cast(_Msg, State) -> {noreply, State}.
-> {noreply, state()} -> {noreply, state()}
). ).
%%--------------------------------------------------------------------
%% Function: handle_info(Info, State) -> {noreply, State} |
%% {noreply, State, Timeout} |
%% {stop, Reason, State}
%% Description: Handling all non call/cast messages
%%--------------------------------------------------------------------
%% @private
handle_info({route, From, To, Packet}, handle_info({route, From, To, Packet},
#state{server_host = ServerHost, access = Access, #state{server_host = ServerHost, access = Access,
plugins = Plugins} = plugins = Plugins} =
@ -1402,6 +1391,9 @@ handle_info({route, From, To, Packet},
_ -> ok _ -> ok
end, end,
{noreply, State}; {noreply, State};
handle_info(_Info, State) ->
{noreply, State}.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Function: terminate(Reason, State) -> void() %% Function: terminate(Reason, State) -> void()
%% Description: This function is called by a gen_server when it is about to %% Description: This function is called by a gen_server when it is about to
@ -1410,8 +1402,6 @@ handle_info({route, From, To, Packet},
%% The return value is ignored. %% The return value is ignored.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @private %% @private
handle_info(_Info, State) -> {noreply, State}.
terminate(_Reason, terminate(_Reason,
#state{host = Host, server_host = ServerHost, #state{host = Host, server_host = ServerHost,
nodetree = TreePlugin, plugins = Plugins}) -> nodetree = TreePlugin, plugins = Plugins}) ->
@ -1452,14 +1442,14 @@ terminate(_Reason,
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB), mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB),
gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop, gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop,
terminate_plugins(Host, ServerHost, Plugins,
TreePlugin).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState} %% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
%% Description: Convert process state when code is changed %% Description: Convert process state when code is changed
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @private %% @private
terminate_plugins(Host, ServerHost, Plugins,
TreePlugin).
code_change(_OldVsn, State, _Extra) -> {ok, State}. code_change(_OldVsn, State, _Extra) -> {ok, State}.
-spec(do_route/7 :: -spec(do_route/7 ::
@ -3380,13 +3370,6 @@ send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
children = itemsEls(ToSend)}]) children = itemsEls(ToSend)}])
end, end,
case is_tuple(Host) of case is_tuple(Host) of
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
%% Host = host()
%% JID = jid()
%% Plugins = [Plugin::string()]
%% Reason = stanzaError()
%% Response = [pubsubIQResponse()]
%% @doc <p>Return the list of affiliations as an XMPP response.</p>
false -> false ->
ejabberd_router:route(service_jid(Host), ejabberd_router:route(service_jid(Host),
jlib:make_jid(LJID), Stanza); jlib:make_jid(LJID), Stanza);
@ -3401,6 +3384,13 @@ send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
end end
end. end.
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
%% Host = host()
%% JID = jid()
%% Plugins = [Plugin::string()]
%% Reason = stanzaError()
%% Response = [pubsubIQResponse()]
%% @doc <p>Return the list of affiliations as an XMPP response.</p>
-spec(get_affiliations/4 :: -spec(get_affiliations/4 ::
( (
Host :: mod_pubsub:host(), Host :: mod_pubsub:host(),
@ -4069,10 +4059,6 @@ get_roster_info(OwnerUser, OwnerServer,
end, end,
Groups), Groups),
{PresenceSubscription, RosterGroup}; {PresenceSubscription, RosterGroup};
%% @spec (AffiliationStr) -> Affiliation
%% AffiliationStr = string()
%% Affiliation = atom()
%% @doc <p>Convert an affiliation type from string to atom.</p>
get_roster_info(OwnerUser, OwnerServer, JID, get_roster_info(OwnerUser, OwnerServer, JID,
AllowedGroups) -> AllowedGroups) ->
get_roster_info(OwnerUser, OwnerServer, get_roster_info(OwnerUser, OwnerServer,
@ -4085,10 +4071,6 @@ string_to_affiliation(<<"outcast">>) -> outcast;
string_to_affiliation(<<"none">>) -> none; string_to_affiliation(<<"none">>) -> none;
string_to_affiliation(_) -> false. string_to_affiliation(_) -> false.
%% @spec (SubscriptionStr) -> Subscription
%% SubscriptionStr = string()
%% Subscription = atom()
%% @doc <p>Convert a subscription type from string to atom.</p>
string_to_subscription(<<"subscribed">>) -> subscribed; string_to_subscription(<<"subscribed">>) -> subscribed;
string_to_subscription(<<"pending">>) -> pending; string_to_subscription(<<"pending">>) -> pending;
string_to_subscription(<<"unconfigured">>) -> string_to_subscription(<<"unconfigured">>) ->
@ -4096,21 +4078,6 @@ string_to_subscription(<<"unconfigured">>) ->
string_to_subscription(<<"none">>) -> none; string_to_subscription(<<"none">>) -> none;
string_to_subscription(_) -> false. string_to_subscription(_) -> false.
%% @spec (Affiliation) -> AffiliationStr
%% Affiliation = atom()
%% AffiliationStr = string()
%% @doc <p>Convert an affiliation type from atom to string.</p>
%% @spec (Subscription) -> SubscriptionStr
%% Subscription = atom()
%% SubscriptionStr = string()
%% @doc <p>Convert a subscription type from atom to string.</p>
%% @spec (Node) -> NodeStr
%% Node = pubsubNode()
%% NodeStr = string()
%% @doc <p>Convert a node type from pubsubNode to string.</p>
%% @spec (Host) -> jid()
%% Host = host()
%% @doc <p>Generate pubsub service JID.</p>
affiliation_to_string(owner) -> <<"owner">>; affiliation_to_string(owner) -> <<"owner">>;
affiliation_to_string(publisher) -> <<"publisher">>; affiliation_to_string(publisher) -> <<"publisher">>;
affiliation_to_string(member) -> <<"member">>; affiliation_to_string(member) -> <<"member">>;
@ -4128,6 +4095,11 @@ subscription_to_string(_) -> <<"none">>.
-> jid() -> jid()
). ).
service_jid(Host) -> service_jid(Host) ->
case Host of
{U, S, _} -> {jid, U, S, <<"">>, U, S, <<"">>};
_ -> {jid, <<"">>, Host, <<"">>, <<"">>, Host, <<"">>}
end.
%% @spec (LJID, NotifyType, Depth, NodeOptions, SubOptions) -> boolean() %% @spec (LJID, NotifyType, Depth, NodeOptions, SubOptions) -> boolean()
%% LJID = jid() %% LJID = jid()
%% NotifyType = items | nodes %% NotifyType = items | nodes
@ -4136,11 +4108,6 @@ service_jid(Host) ->
%% SubOptions = [{atom(), term()}] %% SubOptions = [{atom(), term()}]
%% @doc <p>Check if a notification must be delivered or not based on %% @doc <p>Check if a notification must be delivered or not based on
%% node and subscription options.</p> %% node and subscription options.</p>
case Host of
{U, S, _} -> {jid, U, S, <<"">>, U, S, <<"">>};
_ -> {jid, <<"">>, Host, <<"">>, <<"">>, Host, <<"">>}
end.
is_to_deliver(LJID, NotifyType, Depth, NodeOptions, is_to_deliver(LJID, NotifyType, Depth, NodeOptions,
SubOptions) -> SubOptions) ->
sub_to_deliver(LJID, NotifyType, Depth, SubOptions) sub_to_deliver(LJID, NotifyType, Depth, SubOptions)
@ -4243,13 +4210,13 @@ get_resource_state({U, S, R}, ShowValues, JIDs) ->
end end
end. end.
%% @spec (Payload) -> int()
%% Payload = term()
-spec(payload_xmlelements/1 :: -spec(payload_xmlelements/1 ::
( (
Payload :: mod_pubsub:payload()) Payload :: mod_pubsub:payload())
-> Count :: non_neg_integer() -> Count :: non_neg_integer()
). ).
%% @spec (Payload) -> int()
%% Payload = term()
%% @doc <p>Count occurence of XML elements in payload.</p> %% @doc <p>Count occurence of XML elements in payload.</p>
payload_xmlelements(Payload) -> payload_xmlelements(Payload, 0). payload_xmlelements(Payload) -> payload_xmlelements(Payload, 0).
payload_xmlelements([], Count) -> Count; payload_xmlelements([], Count) -> Count;

View File

@ -931,17 +931,6 @@ remove_user(User, Server) ->
LServer = jlib:nameprep(Server), LServer = jlib:nameprep(Server),
Entity = jlib:make_jid(LUser, LServer, <<"">>), Entity = jlib:make_jid(LUser, LServer, <<"">>),
Host = host(LServer), Host = host(LServer),
%%--------------------------------------------------------------------
%% Function:
%% handle_call(Request, From, State) -> {reply, Reply, State} |
%% {reply, Reply, State, Timeout} |
%% {noreply, State} |
%% {noreply, State, Timeout} |
%% {stop, Reason, Reply, State} |
%% {stop, Reason, State}
%% Description: Handling call messages
%%--------------------------------------------------------------------
%% @private
HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>, HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>,
spawn(fun () -> spawn(fun () ->
lists:foreach(fun (PType) -> lists:foreach(fun (PType) ->
@ -1020,13 +1009,6 @@ handle_call(stop, _From, State) ->
%% Description: Handling cast messages %% Description: Handling cast messages
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @private %% @private
%%--------------------------------------------------------------------
%% Function: handle_info(Info, State) -> {noreply, State} |
%% {noreply, State, Timeout} |
%% {stop, Reason, State}
%% Description: Handling all non call/cast messages
%%--------------------------------------------------------------------
%% @private
handle_cast(_Msg, State) -> {noreply, State}. handle_cast(_Msg, State) -> {noreply, State}.
-spec(handle_info/2 :: -spec(handle_info/2 ::
@ -1036,6 +1018,13 @@ handle_cast(_Msg, State) -> {noreply, State}.
-> {noreply, state()} -> {noreply, state()}
). ).
%%--------------------------------------------------------------------
%% Function: handle_info(Info, State) -> {noreply, State} |
%% {noreply, State, Timeout} |
%% {stop, Reason, State}
%% Description: Handling all non call/cast messages
%%--------------------------------------------------------------------
%% @private
handle_info({route, From, To, Packet}, handle_info({route, From, To, Packet},
#state{server_host = ServerHost, access = Access, #state{server_host = ServerHost, access = Access,
plugins = Plugins} = plugins = Plugins} =
@ -1047,6 +1036,9 @@ handle_info({route, From, To, Packet},
_ -> ok _ -> ok
end, end,
{noreply, State}; {noreply, State};
handle_info(_Info, State) ->
{noreply, State}.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Function: terminate(Reason, State) -> void() %% Function: terminate(Reason, State) -> void()
%% Description: This function is called by a gen_server when it is about to %% Description: This function is called by a gen_server when it is about to
@ -1055,8 +1047,6 @@ handle_info({route, From, To, Packet},
%% The return value is ignored. %% The return value is ignored.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @private %% @private
handle_info(_Info, State) -> {noreply, State}.
terminate(_Reason, terminate(_Reason,
#state{host = Host, server_host = ServerHost, #state{host = Host, server_host = ServerHost,
nodetree = TreePlugin, plugins = Plugins}) -> nodetree = TreePlugin, plugins = Plugins}) ->
@ -1097,14 +1087,14 @@ terminate(_Reason,
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB), mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB),
gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop, gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop,
terminate_plugins(Host, ServerHost, Plugins,
TreePlugin).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState} %% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
%% Description: Convert process state when code is changed %% Description: Convert process state when code is changed
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @private %% @private
terminate_plugins(Host, ServerHost, Plugins,
TreePlugin).
code_change(_OldVsn, State, _Extra) -> {ok, State}. code_change(_OldVsn, State, _Extra) -> {ok, State}.
-spec(do_route/7 :: -spec(do_route/7 ::
@ -3684,10 +3674,6 @@ get_roster_info(OwnerUser, OwnerServer,
end, end,
Groups), Groups),
{PresenceSubscription, RosterGroup}; {PresenceSubscription, RosterGroup};
%% @spec (AffiliationStr) -> Affiliation
%% AffiliationStr = string()
%% Affiliation = atom()
%% @doc <p>Convert an affiliation type from string to atom.</p>
get_roster_info(OwnerUser, OwnerServer, JID, get_roster_info(OwnerUser, OwnerServer, JID,
AllowedGroups) -> AllowedGroups) ->
get_roster_info(OwnerUser, OwnerServer, get_roster_info(OwnerUser, OwnerServer,
@ -3700,10 +3686,6 @@ string_to_affiliation(<<"outcast">>) -> outcast;
string_to_affiliation(<<"none">>) -> none; string_to_affiliation(<<"none">>) -> none;
string_to_affiliation(_) -> false. string_to_affiliation(_) -> false.
%% @spec (SubscriptionStr) -> Subscription
%% SubscriptionStr = string()
%% Subscription = atom()
%% @doc <p>Convert a subscription type from string to atom.</p>
string_to_subscription(<<"subscribed">>) -> subscribed; string_to_subscription(<<"subscribed">>) -> subscribed;
string_to_subscription(<<"pending">>) -> pending; string_to_subscription(<<"pending">>) -> pending;
string_to_subscription(<<"unconfigured">>) -> string_to_subscription(<<"unconfigured">>) ->
@ -3711,21 +3693,6 @@ string_to_subscription(<<"unconfigured">>) ->
string_to_subscription(<<"none">>) -> none; string_to_subscription(<<"none">>) -> none;
string_to_subscription(_) -> false. string_to_subscription(_) -> false.
%% @spec (Affiliation) -> AffiliationStr
%% Affiliation = atom()
%% AffiliationStr = string()
%% @doc <p>Convert an affiliation type from atom to string.</p>
%% @spec (Subscription) -> SubscriptionStr
%% Subscription = atom()
%% SubscriptionStr = string()
%% @doc <p>Convert a subscription type from atom to string.</p>
%% @spec (Node) -> NodeStr
%% Node = pubsubNode()
%% NodeStr = string()
%% @doc <p>Convert a node type from pubsubNode to string.</p>
%% @spec (Host) -> jid()
%% Host = host()
%% @doc <p>Generate pubsub service JID.</p>
affiliation_to_string(owner) -> <<"owner">>; affiliation_to_string(owner) -> <<"owner">>;
affiliation_to_string(publisher) -> <<"publisher">>; affiliation_to_string(publisher) -> <<"publisher">>;
affiliation_to_string(member) -> <<"member">>; affiliation_to_string(member) -> <<"member">>;
@ -3743,6 +3710,11 @@ subscription_to_string(_) -> <<"none">>.
-> jid() -> jid()
). ).
service_jid(Host) -> service_jid(Host) ->
case Host of
{U, S, _} -> {jid, U, S, <<"">>, U, S, <<"">>};
_ -> {jid, <<"">>, Host, <<"">>, <<"">>, Host, <<"">>}
end.
%% @spec (LJID, NotifyType, Depth, NodeOptions, SubOptions) -> boolean() %% @spec (LJID, NotifyType, Depth, NodeOptions, SubOptions) -> boolean()
%% LJID = jid() %% LJID = jid()
%% NotifyType = items | nodes %% NotifyType = items | nodes
@ -3751,11 +3723,6 @@ service_jid(Host) ->
%% SubOptions = [{atom(), term()}] %% SubOptions = [{atom(), term()}]
%% @doc <p>Check if a notification must be delivered or not based on %% @doc <p>Check if a notification must be delivered or not based on
%% node and subscription options.</p> %% node and subscription options.</p>
case Host of
{U, S, _} -> {jid, U, S, <<"">>, U, S, <<"">>};
_ -> {jid, <<"">>, Host, <<"">>, <<"">>, Host, <<"">>}
end.
is_to_deliver(LJID, NotifyType, Depth, NodeOptions, is_to_deliver(LJID, NotifyType, Depth, NodeOptions,
SubOptions) -> SubOptions) ->
sub_to_deliver(LJID, NotifyType, Depth, SubOptions) sub_to_deliver(LJID, NotifyType, Depth, SubOptions)
@ -3858,13 +3825,13 @@ get_resource_state({U, S, R}, ShowValues, JIDs) ->
end end
end. end.
%% @spec (Payload) -> int()
%% Payload = term()
-spec(payload_xmlelements/1 :: -spec(payload_xmlelements/1 ::
( (
Payload :: mod_pubsub:payload()) Payload :: mod_pubsub:payload())
-> Count :: non_neg_integer() -> Count :: non_neg_integer()
). ).
%% @spec (Payload) -> int()
%% Payload = term()
%% @doc <p>Count occurence of XML elements in payload.</p> %% @doc <p>Count occurence of XML elements in payload.</p>
payload_xmlelements(Payload) -> payload_xmlelements(Payload, 0). payload_xmlelements(Payload) -> payload_xmlelements(Payload, 0).
payload_xmlelements([], Count) -> Count; payload_xmlelements([], Count) -> Count;

View File

@ -137,6 +137,18 @@ options() ->
%% @doc Returns the node features %% @doc Returns the node features
-spec(features/0 :: () -> Features::[binary(),...]). -spec(features/0 :: () -> Features::[binary(),...]).
features() -> features() ->
[<<"create-nodes">>, <<"auto-create">>,
<<"access-authorize">>, <<"delete-nodes">>,
<<"delete-items">>, <<"get-pending">>,
<<"instant-nodes">>, <<"manage-subscriptions">>,
<<"modify-affiliations">>, <<"multi-subscribe">>,
<<"outcast-affiliation">>, <<"persistent-items">>,
<<"publish">>, <<"purge-nodes">>, <<"retract-items">>,
<<"retrieve-affiliations">>, <<"retrieve-items">>,
<<"retrieve-subscriptions">>, <<"subscribe">>,
<<"subscription-notifications">>,
<<"subscription-options">>].
%% @spec (Host, ServerHost, NodeId, ParentNodeId, Owner, Access) -> {result, Allowed} %% @spec (Host, ServerHost, NodeId, ParentNodeId, Owner, Access) -> {result, Allowed}
%% Host = mod_pubsub:hostPubsub() %% Host = mod_pubsub:hostPubsub()
%% ServerHost = string() %% ServerHost = string()
@ -157,18 +169,6 @@ features() ->
%% module by implementing this function like this: %% module by implementing this function like this:
%% ```check_create_user_permission(Host, ServerHost, NodeId, ParentNodeId, Owner, Access) -> %% ```check_create_user_permission(Host, ServerHost, NodeId, ParentNodeId, Owner, Access) ->
%% node_default:check_create_user_permission(Host, ServerHost, NodeId, ParentNodeId, Owner, Access).'''</p> %% node_default:check_create_user_permission(Host, ServerHost, NodeId, ParentNodeId, Owner, Access).'''</p>
[<<"create-nodes">>, <<"auto-create">>,
<<"access-authorize">>, <<"delete-nodes">>,
<<"delete-items">>, <<"get-pending">>,
<<"instant-nodes">>, <<"manage-subscriptions">>,
<<"modify-affiliations">>, <<"multi-subscribe">>,
<<"outcast-affiliation">>, <<"persistent-items">>,
<<"publish">>, <<"purge-nodes">>, <<"retract-items">>,
<<"retrieve-affiliations">>, <<"retrieve-items">>,
<<"retrieve-subscriptions">>, <<"subscribe">>,
<<"subscription-notifications">>,
<<"subscription-options">>].
-spec(create_node_permission/6 :: -spec(create_node_permission/6 ::
( (
Host :: mod_pubsub:host(), Host :: mod_pubsub:host(),
@ -1073,14 +1073,14 @@ get_state(NodeIdx, JID) ->
-> ok -> ok
). ).
set_state(State) when is_record(State, pubsub_state) -> set_state(State) when is_record(State, pubsub_state) ->
mnesia:write(State).
%set_state(_) -> {error, ?ERR_INTERNAL_SERVER_ERROR}.
%% @spec (NodeIdx, JID) -> ok | {error, Reason} %% @spec (NodeIdx, JID) -> ok | {error, Reason}
%% NodeIdx = mod_pubsub:nodeIdx() %% NodeIdx = mod_pubsub:nodeIdx()
%% JID = mod_pubsub:jid() %% JID = mod_pubsub:jid()
%% Reason = mod_pubsub:stanzaError() %% Reason = mod_pubsub:stanzaError()
%% @doc <p>Delete a state from database.</p> %% @doc <p>Delete a state from database.</p>
mnesia:write(State).
%set_state(_) -> {error, ?ERR_INTERNAL_SERVER_ERROR}.
-spec(del_state/2 :: -spec(del_state/2 ::
( (
NodeIdx :: mod_pubsub:nodeIdx(), NodeIdx :: mod_pubsub:nodeIdx(),
@ -1251,14 +1251,14 @@ get_item(NodeIdx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup,
-> ok -> ok
). ).
set_item(Item) when is_record(Item, pubsub_item) -> set_item(Item) when is_record(Item, pubsub_item) ->
mnesia:write(Item).
%set_item(_) -> {error, ?ERR_INTERNAL_SERVER_ERROR}.
%% @spec (NodeIdx, ItemId) -> ok | {error, Reason} %% @spec (NodeIdx, ItemId) -> ok | {error, Reason}
%% NodeIdx = mod_pubsub:nodeIdx() %% NodeIdx = mod_pubsub:nodeIdx()
%% ItemId = mod_pubsub:itemId() %% ItemId = mod_pubsub:itemId()
%% Reason = mod_pubsub:stanzaError() %% Reason = mod_pubsub:stanzaError()
%% @doc <p>Delete an item from database.</p> %% @doc <p>Delete an item from database.</p>
mnesia:write(Item).
%set_item(_) -> {error, ?ERR_INTERNAL_SERVER_ERROR}.
-spec(del_item/2 :: -spec(del_item/2 ::
( (
NodeIdx :: mod_pubsub:nodeIdx(), NodeIdx :: mod_pubsub:nodeIdx(),
@ -1299,13 +1299,13 @@ node_to_path(Node) -> str:tokens((Node), <<"/">>).
path_to_node([]) -> <<>>; path_to_node([]) -> <<>>;
path_to_node(Path) -> path_to_node(Path) ->
iolist_to_binary(str:join([<<"">> | Path], <<"/">>)).
%% @spec (Affiliation, Subscription) -> true | false %% @spec (Affiliation, Subscription) -> true | false
%% Affiliation = owner | member | publisher | outcast | none %% Affiliation = owner | member | publisher | outcast | none
%% Subscription = subscribed | none %% Subscription = subscribed | none
%% @doc Determines if the combination of Affiliation and Subscribed %% @doc Determines if the combination of Affiliation and Subscribed
%% are allowed to get items from a node. %% are allowed to get items from a node.
iolist_to_binary(str:join([<<"">> | Path], <<"/">>)).
can_fetch_item(owner, _) -> true; can_fetch_item(owner, _) -> true;
can_fetch_item(member, _) -> true; can_fetch_item(member, _) -> true;
can_fetch_item(publisher, _) -> true; can_fetch_item(publisher, _) -> true;

View File

@ -132,6 +132,18 @@ options() ->
%% @doc Returns the node features %% @doc Returns the node features
-spec(features/0 :: () -> Features::[Feature::binary(),...]). -spec(features/0 :: () -> Features::[Feature::binary(),...]).
features() -> features() ->
[<<"create-nodes">>, <<"auto-create">>,
<<"access-authorize">>, <<"delete-nodes">>,
<<"delete-items">>, <<"get-pending">>,
<<"instant-nodes">>, <<"manage-subscriptions">>,
<<"modify-affiliations">>, <<"multi-subscribe">>,
<<"outcast-affiliation">>, <<"persistent-items">>,
<<"publish">>, <<"purge-nodes">>, <<"retract-items">>,
<<"retrieve-affiliations">>, <<"retrieve-items">>,
<<"retrieve-subscriptions">>, <<"subscribe">>,
<<"subscription-notifications">>,
<<"subscription-options">>, <<"rsm">>].
%% @spec (Host, ServerHost, Node, ParentNode, Owner, Access) -> bool() %% @spec (Host, ServerHost, Node, ParentNode, Owner, Access) -> bool()
%% Host = mod_pubsub:host() %% Host = mod_pubsub:host()
%% ServerHost = mod_pubsub:host() %% ServerHost = mod_pubsub:host()
@ -151,18 +163,6 @@ features() ->
%% module by implementing this function like this: %% module by implementing this function like this:
%% ```check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> %% ```check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
%% node_default:check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access).'''</p> %% node_default:check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access).'''</p>
[<<"create-nodes">>, <<"auto-create">>,
<<"access-authorize">>, <<"delete-nodes">>,
<<"delete-items">>, <<"get-pending">>,
<<"instant-nodes">>, <<"manage-subscriptions">>,
<<"modify-affiliations">>, <<"multi-subscribe">>,
<<"outcast-affiliation">>, <<"persistent-items">>,
<<"publish">>, <<"purge-nodes">>, <<"retract-items">>,
<<"retrieve-affiliations">>, <<"retrieve-items">>,
<<"retrieve-subscriptions">>, <<"subscribe">>,
<<"subscription-notifications">>,
<<"subscription-options">>, <<"rsm">>].
-spec(create_node_permission/6 :: -spec(create_node_permission/6 ::
( (
Host :: mod_pubsub:host(), Host :: mod_pubsub:host(),
@ -1503,8 +1503,6 @@ del_item(NodeId, ItemId) ->
del_items(_, []) -> ok; del_items(_, []) -> ok;
del_items(NodeId, [ItemId]) -> del_item(NodeId, ItemId); del_items(NodeId, [ItemId]) -> del_item(NodeId, ItemId);
del_items(NodeId, ItemIds) -> del_items(NodeId, ItemIds) ->
%% @doc <p>Return the name of the node if known: Default is to return
%% node id.</p>
I = str:join([[<<"'">>, (?PUBSUB):escape(X), <<"'">>] I = str:join([[<<"'">>, (?PUBSUB):escape(X), <<"'">>]
|| X <- ItemIds], || X <- ItemIds],
<<",">>), <<",">>),
@ -1519,13 +1517,13 @@ node_to_path(Node) -> str:tokens((Node), <<"/">>).
path_to_node([]) -> <<>>; path_to_node([]) -> <<>>;
path_to_node(Path) -> path_to_node(Path) ->
iolist_to_binary(str:join([<<"">> | Path], <<"/">>)).
%% @spec (Affiliation, Subscription) -> true | false %% @spec (Affiliation, Subscription) -> true | false
%% Affiliation = owner | member | publisher | outcast | none %% Affiliation = owner | member | publisher | outcast | none
%% Subscription = subscribed | none %% Subscription = subscribed | none
%% @doc Determines if the combination of Affiliation and Subscribed %% @doc Determines if the combination of Affiliation and Subscribed
%% are allowed to get items from a node. %% are allowed to get items from a node.
iolist_to_binary(str:join([<<"">> | Path], <<"/">>)).
can_fetch_item(owner, _) -> true; can_fetch_item(owner, _) -> true;
can_fetch_item(member, _) -> true; can_fetch_item(member, _) -> true;
can_fetch_item(publisher, _) -> true; can_fetch_item(publisher, _) -> true;

View File

@ -1,5 +1,5 @@
--- mod_pubsub.erl 2013-06-06 11:08:12.333599362 +0200 --- mod_pubsub.erl 2013-06-13 23:58:13.380824021 +0200
+++ mod_pubsub_odbc.erl 2013-06-06 11:31:06.640173557 +0200 +++ mod_pubsub_odbc.erl 2013-06-14 00:01:11.907478941 +0200
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see %%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
%%% XEP-0060 section 12.18. %%% XEP-0060 section 12.18.
@ -9,7 +9,7 @@
-author('christophe.romain@process-one.net'). -author('christophe.romain@process-one.net').
@@ -61,11 +61,11 @@ @@ -62,11 +62,11 @@
-include("pubsub.hrl"). -include("pubsub.hrl").
@ -24,7 +24,7 @@
%% exports for hooks %% exports for hooks
-export([presence_probe/3, caps_update/3, -export([presence_probe/3, caps_update/3,
@@ -100,7 +100,7 @@ @@ -101,7 +101,7 @@
-export([subscription_to_string/1, affiliation_to_string/1, -export([subscription_to_string/1, affiliation_to_string/1,
string_to_subscription/1, string_to_affiliation/1, string_to_subscription/1, string_to_affiliation/1,
extended_error/2, extended_error/3, extended_error/2, extended_error/3,
@ -33,7 +33,7 @@
%% API and gen_server callbacks %% API and gen_server callbacks
-export([start_link/2, start/2, stop/1, init/1, -export([start_link/2, start/2, stop/1, init/1,
@@ -110,7 +110,7 @@ @@ -111,7 +111,7 @@
%% calls for parallel sending of last items %% calls for parallel sending of last items
-export([send_loop/1]). -export([send_loop/1]).
@ -42,7 +42,7 @@
-define(LOOPNAME, ejabberd_mod_pubsub_loop). -define(LOOPNAME, ejabberd_mod_pubsub_loop).
@@ -349,8 +349,6 @@ @@ -350,8 +350,6 @@
false -> ok false -> ok
end, end,
ejabberd_router:register_route(Host), ejabberd_router:register_route(Host),
@ -51,7 +51,7 @@
put(server_host, ServerHost), put(server_host, ServerHost),
init_nodes(Host, ServerHost, NodeTree, Plugins), init_nodes(Host, ServerHost, NodeTree, Plugins),
State = #state{host = Host, server_host = ServerHost, State = #state{host = Host, server_host = ServerHost,
@@ -423,359 +421,14 @@ @@ -424,359 +422,14 @@
ok. ok.
init_nodes(Host, ServerHost, _NodeTree, Plugins) -> init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
@ -414,7 +414,7 @@
send_loop(State) -> send_loop(State) ->
receive receive
{presence, JID, Pid} -> {presence, JID, Pid} ->
@@ -784,11 +437,13 @@ @@ -785,11 +438,13 @@
LJID = jlib:jid_tolower(JID), LJID = jlib:jid_tolower(JID),
BJID = jlib:jid_remove_resource(LJID), BJID = jlib:jid_remove_resource(LJID),
lists:foreach(fun (PType) -> lists:foreach(fun (PType) ->
@ -432,7 +432,7 @@
lists:foreach(fun ({Node, subscribed, _, lists:foreach(fun ({Node, subscribed, _,
SubJID}) -> SubJID}) ->
if (SubJID == LJID) or if (SubJID == LJID) or
@@ -800,24 +455,14 @@ @@ -801,24 +456,14 @@
type = type =
Type, Type,
id = id =
@ -459,7 +459,7 @@
true -> true ->
% resource not concerned about that subscription % resource not concerned about that subscription
ok ok
@@ -1008,7 +653,8 @@ @@ -1009,7 +654,8 @@
children = []}]; children = []}];
disco_identity(Host, Node, From) -> disco_identity(Host, Node, From) ->
Action = fun (#pubsub_node{id = Idx, type = Type, Action = fun (#pubsub_node{id = Idx, type = Type,
@ -469,7 +469,7 @@
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
{result, _} -> {result, _} ->
{result, {result,
@@ -1060,7 +706,8 @@ @@ -1061,7 +707,8 @@
|| Feature <- features(<<"pep">>)]]; || Feature <- features(<<"pep">>)]];
disco_features(Host, Node, From) -> disco_features(Host, Node, From) ->
Action = fun (#pubsub_node{id = Idx, type = Type, Action = fun (#pubsub_node{id = Idx, type = Type,
@ -479,7 +479,7 @@
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
{result, _} -> {result, _} ->
{result, {result,
@@ -1105,9 +752,9 @@ @@ -1106,9 +753,9 @@
). ).
disco_items(Host, <<>>, From) -> disco_items(Host, <<>>, From) ->
Action = fun (#pubsub_node{nodeid = {_, NodeID}, Action = fun (#pubsub_node{nodeid = {_, NodeID},
@ -491,7 +491,7 @@
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
{result, _} -> {result, _} ->
[#xmlel{name = <<"item">>, [#xmlel{name = <<"item">>,
@@ -1128,13 +775,14 @@ @@ -1129,13 +776,14 @@
_ -> Acc _ -> Acc
end end
end, end,
@ -508,7 +508,7 @@
case get_allowed_items_call(Host, Idx, From, Type, case get_allowed_items_call(Host, Idx, From, Type,
Options, Owners) Options, Owners)
of of
@@ -1238,9 +886,6 @@ @@ -1239,9 +887,6 @@
lists:foreach(fun ({#pubsub_node{options lists:foreach(fun ({#pubsub_node{options
= =
Options, Options,
@ -518,7 +518,7 @@
id = id =
NodeId}, NodeId},
subscribed, _, subscribed, _,
@@ -1252,7 +897,7 @@ @@ -1253,7 +898,7 @@
presence -> presence ->
case case
lists:member(BJID, lists:member(BJID,
@ -527,7 +527,7 @@
of of
true -> true ->
node_action(Host, node_action(Host,
@@ -1512,7 +1157,8 @@ @@ -1503,7 +1148,8 @@
IQ -> IQ ->
#xmlel{attrs = QAttrs} = SubEl, #xmlel{attrs = QAttrs} = SubEl,
Node = xml:get_attr_s(<<"node">>, QAttrs), Node = xml:get_attr_s(<<"node">>, QAttrs),
@ -537,7 +537,7 @@
{result, IQRes} -> {result, IQRes} ->
jlib:iq_to_xml(IQ#iq{type = result, jlib:iq_to_xml(IQ#iq{type = result,
sub_el = sub_el =
@@ -1639,7 +1285,7 @@ @@ -1630,7 +1276,7 @@
% [] -> % [] ->
% [<<"leaf">>]; %% No sub-nodes: it's a leaf node % [<<"leaf">>]; %% No sub-nodes: it's a leaf node
% _ -> % _ ->
@ -546,7 +546,7 @@
% {result, []} -> [<<"collection">>]; % {result, []} -> [<<"collection">>];
% {result, _} -> [<<"leaf">>, <<"collection">>]; % {result, _} -> [<<"leaf">>, <<"collection">>];
% _ -> [] % _ -> []
@@ -1661,7 +1307,11 @@ @@ -1652,7 +1298,11 @@
% [#xmlel{name = <<"feature">>, % [#xmlel{name = <<"feature">>,
% attrs = [{<<"var">>, ?NS_PUBSUB}], % attrs = [{<<"var">>, ?NS_PUBSUB}],
% children = []} % children = []}
@ -559,7 +559,7 @@
% #xmlel{name = <<"feature">>, % #xmlel{name = <<"feature">>,
% attrs = % attrs =
% [{<<"var">>, % [{<<"var">>,
@@ -1686,7 +1336,7 @@ @@ -1677,7 +1327,7 @@
[] -> [<<"leaf">>]; [] -> [<<"leaf">>];
_ -> _ ->
case node_call(Type, get_items, case node_call(Type, get_items,
@ -568,7 +568,7 @@
of of
{result, []} -> {result, []} ->
[<<"collection">>]; [<<"collection">>];
@@ -1708,7 +1358,11 @@ @@ -1699,7 +1349,11 @@
F = [#xmlel{name = <<"feature">>, F = [#xmlel{name = <<"feature">>,
attrs = [{<<"var">>, ?NS_PUBSUB}], attrs = [{<<"var">>, ?NS_PUBSUB}],
children = []} children = []}
@ -581,7 +581,7 @@
#xmlel{name = <<"feature">>, #xmlel{name = <<"feature">>,
attrs = attrs =
[{<<"var">>, [{<<"var">>,
@@ -1752,7 +1406,11 @@ @@ -1743,7 +1397,11 @@
#xmlel{name = <<"feature">>, #xmlel{name = <<"feature">>,
attrs = [{<<"var">>, ?NS_VCARD}], children = []}] attrs = [{<<"var">>, ?NS_VCARD}], children = []}]
++ ++
@ -594,7 +594,7 @@
#xmlel{name = <<"feature">>, #xmlel{name = <<"feature">>,
attrs = attrs =
[{<<"var">>, <<(?NS_PUBSUB)/binary, "#", Feature/binary>>}], [{<<"var">>, <<(?NS_PUBSUB)/binary, "#", Feature/binary>>}],
@@ -1765,14 +1423,15 @@ @@ -1756,14 +1414,15 @@
_ -> node_disco_info(Host, Node, From) _ -> node_disco_info(Host, Node, From)
end. end.
@ -613,7 +613,7 @@
{result, {result,
lists:map(fun (#pubsub_node{nodeid = {_, SubNode}, lists:map(fun (#pubsub_node{nodeid = {_, SubNode},
options = Options}) -> options = Options}) ->
@@ -1809,7 +1468,7 @@ @@ -1800,7 +1459,7 @@
% Nodes)}; % Nodes)};
% Other -> Other % Other -> Other
% end; % end;
@ -622,7 +622,7 @@
CommandItems = [#xmlel{name = <<"item">>, CommandItems = [#xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, Host}, [{<<"jid">>, Host},
@@ -1817,22 +1476,19 @@ @@ -1808,22 +1467,19 @@
{<<"name">>, <<"Get Pending">>}], {<<"name">>, <<"Get Pending">>}],
children = []}], children = []}],
{result, CommandItems}; {result, CommandItems};
@ -651,7 +651,7 @@
end, end,
Nodes = lists:map(fun (#pubsub_node{nodeid = Nodes = lists:map(fun (#pubsub_node{nodeid =
{_, SubNode}, {_, SubNode},
@@ -1875,7 +1531,7 @@ @@ -1866,7 +1522,7 @@
children = []} children = []}
end, end,
NodeItems), NodeItems),
@ -660,7 +660,7 @@
end, end,
case transaction(Host, Node, Action, sync_dirty) of case transaction(Host, Node, Action, sync_dirty) of
{result, {_, Result}} -> {result, Result}; {result, {_, Result}} -> {result, Result};
@@ -2026,7 +1682,8 @@ @@ -2017,7 +1673,8 @@
(_, Acc) -> Acc (_, Acc) -> Acc
end, end,
[], xml:remove_cdata(Els)), [], xml:remove_cdata(Els)),
@ -670,7 +670,7 @@
{get, <<"subscriptions">>} -> {get, <<"subscriptions">>} ->
get_subscriptions(Host, Node, From, Plugins); get_subscriptions(Host, Node, From, Plugins);
{get, <<"affiliations">>} -> {get, <<"affiliations">>} ->
@@ -2061,7 +1718,9 @@ @@ -2052,7 +1709,9 @@
). ).
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) -> iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
#xmlel{children = SubEls} = SubEl, #xmlel{children = SubEls} = SubEl,
@ -681,7 +681,7 @@
case Action of case Action of
[#xmlel{name = Name, attrs = Attrs, children = Els}] -> [#xmlel{name = Name, attrs = Attrs, children = Els}] ->
Node = xml:get_attr_s(<<"node">>, Attrs), Node = xml:get_attr_s(<<"node">>, Attrs),
@@ -2195,7 +1854,8 @@ @@ -2186,7 +1845,8 @@
_ -> [] _ -> []
end end
end, end,
@ -691,7 +691,7 @@
{result, lists:flatmap(Tr, Plugins)} {result, lists:flatmap(Tr, Plugins)}
end, end,
sync_dirty) sync_dirty)
@@ -2240,7 +1900,8 @@ @@ -2231,7 +1891,8 @@
%%% authorization handling %%% authorization handling
@ -701,7 +701,7 @@
Subscriber) -> Subscriber) ->
Lang = <<"en">>, Lang = <<"en">>,
Stanza = #xmlel{name = <<"message">>, attrs = [], Stanza = #xmlel{name = <<"message">>, attrs = [],
@@ -2318,7 +1979,7 @@ @@ -2309,7 +1970,7 @@
ejabberd_router:route(service_jid(Host), ejabberd_router:route(service_jid(Host),
jlib:make_jid(Owner), Stanza) jlib:make_jid(Owner), Stanza)
end, end,
@ -710,7 +710,7 @@
find_authorization_response(Packet) -> find_authorization_response(Packet) ->
#xmlel{children = Els} = Packet, #xmlel{children = Els} = Packet,
@@ -2383,11 +2044,11 @@ @@ -2374,11 +2035,11 @@
<<"true">> -> true; <<"true">> -> true;
_ -> false _ -> false
end, end,
@ -724,7 +724,7 @@
{result, Subscriptions} = node_call(Type, {result, Subscriptions} = node_call(Type,
get_subscriptions, get_subscriptions,
[NodeId, [NodeId,
@@ -2642,7 +2303,7 @@ @@ -2633,7 +2294,7 @@
children = [#xmlel{name = <<"create">>, children = [#xmlel{name = <<"create">>,
attrs = nodeAttr(Node), attrs = nodeAttr(Node),
children = []}]}], children = []}]}],
@ -733,7 +733,7 @@
{result, {NodeId, SubsByDepth, {Result, broadcast}}} -> {result, {NodeId, SubsByDepth, {Result, broadcast}}} ->
broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth), broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth),
ejabberd_hooks:run(pubsub_create_node, ServerHost, [ServerHost, Host, Node, NodeId, NodeOptions]), ejabberd_hooks:run(pubsub_create_node, ServerHost, [ServerHost, Host, Node, NodeId, NodeOptions]),
@@ -2779,7 +2440,7 @@ @@ -2770,7 +2431,7 @@
%%</ul> %%</ul>
subscribe_node(Host, Node, From, JID, Configuration) -> subscribe_node(Host, Node, From, JID, Configuration) ->
SubOpts = case SubOpts = case
@ -742,7 +742,7 @@
of of
{result, GoodSubOpts} -> GoodSubOpts; {result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid _ -> invalid
@@ -2793,7 +2454,7 @@ @@ -2784,7 +2445,7 @@
end end
end, end,
Action = fun (#pubsub_node{options = Options, Action = fun (#pubsub_node{options = Options,
@ -751,7 +751,7 @@
Features = features(Type), Features = features(Type),
SubscribeFeature = lists:member(<<"subscribe">>, Features), SubscribeFeature = lists:member(<<"subscribe">>, Features),
OptionsFeature = lists:member(<<"subscription-options">>, Features), OptionsFeature = lists:member(<<"subscription-options">>, Features),
@@ -2802,6 +2463,7 @@ @@ -2793,6 +2454,7 @@
AccessModel = get_option(Options, access_model), AccessModel = get_option(Options, access_model),
SendLast = get_option(Options, send_last_published_item), SendLast = get_option(Options, send_last_published_item),
AllowedGroups = get_option(Options, roster_groups_allowed, []), AllowedGroups = get_option(Options, roster_groups_allowed, []),
@ -759,7 +759,7 @@
{PresenceSubscription, RosterGroup} = {PresenceSubscription, RosterGroup} =
get_presence_and_roster_permissions(Host, Subscriber, get_presence_and_roster_permissions(Host, Subscriber,
Owners, AccessModel, AllowedGroups), Owners, AccessModel, AllowedGroups),
@@ -2956,12 +2618,9 @@ @@ -2947,12 +2609,9 @@
Features = features(Type), Features = features(Type),
PublishFeature = lists:member(<<"publish">>, Features), PublishFeature = lists:member(<<"publish">>, Features),
PublishModel = get_option(Options, publish_model), PublishModel = get_option(Options, publish_model),
@ -773,7 +773,7 @@
PayloadCount = payload_xmlelements(Payload), PayloadCount = payload_xmlelements(Payload),
PayloadSize = byte_size(term_to_binary(Payload)) - 2, PayloadSize = byte_size(term_to_binary(Payload)) - 2,
PayloadMaxSize = get_option(Options, max_payload_size), PayloadMaxSize = get_option(Options, max_payload_size),
@@ -3017,7 +2676,7 @@ @@ -3008,7 +2667,7 @@
false -> false ->
ok ok
end, end,
@ -782,7 +782,7 @@
case Result of case Result of
default -> {result, Reply}; default -> {result, Reply};
_ -> {result, Result} _ -> {result, Result}
@@ -3210,19 +2869,20 @@ @@ -3201,19 +2860,20 @@
%% <p>The permission are not checked in this function.</p> %% <p>The permission are not checked in this function.</p>
%% @todo We probably need to check that the user doing the query has the right %% @todo We probably need to check that the user doing the query has the right
%% to read the items. %% to read the items.
@ -806,7 +806,7 @@
MaxItems = if SMaxItems == <<"">> -> MaxItems = if SMaxItems == <<"">> ->
get_max_items_node(Host); get_max_items_node(Host);
true -> true ->
@@ -3234,13 +2894,13 @@ @@ -3225,13 +2885,13 @@
case MaxItems of case MaxItems of
{error, Error} -> {error, Error}; {error, Error} -> {error, Error};
_ -> _ ->
@ -822,7 +822,7 @@
{PresenceSubscription, RosterGroup} = {PresenceSubscription, RosterGroup} =
get_presence_and_roster_permissions(Host, From, Owners, get_presence_and_roster_permissions(Host, From, Owners,
AccessModel, AllowedGroups), AccessModel, AllowedGroups),
@@ -3258,11 +2918,11 @@ @@ -3249,11 +2909,11 @@
node_call(Type, get_items, node_call(Type, get_items,
[NodeId, From, AccessModel, [NodeId, From, AccessModel,
PresenceSubscription, RosterGroup, PresenceSubscription, RosterGroup,
@ -836,7 +836,7 @@
SendItems = case ItemIDs of SendItems = case ItemIDs of
[] -> Items; [] -> Items;
_ -> _ ->
@@ -3280,8 +2940,8 @@ @@ -3271,8 +2931,8 @@
children = children =
[#xmlel{name = <<"items">>, attrs = nodeAttr(Node), [#xmlel{name = <<"items">>, attrs = nodeAttr(Node),
children = children =
@ -847,7 +847,7 @@
Error -> Error Error -> Error
end end
end. end.
@@ -3305,13 +2965,18 @@ @@ -3296,13 +2956,18 @@
end. end.
get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) -> get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
@ -867,7 +867,7 @@
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any() %% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
%% Host = pubsubHost() %% Host = pubsubHost()
@@ -3322,35 +2987,32 @@ @@ -3313,35 +2978,32 @@
%% Number = last | integer() %% Number = last | integer()
%% @doc <p>Resend the items of a node to the user.</p> %% @doc <p>Resend the items of a node to the user.</p>
%% @todo use cache-last-item feature %% @todo use cache-last-item feature
@ -922,20 +922,11 @@
send_items(Host, Node, NodeId, Type, {U, S, R} = LJID, send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
Number) -> Number) ->
ToSend = case node_action(Host, Type, get_items, ToSend = case node_action(Host, Type, get_items,
@@ -3378,7 +3040,8 @@ @@ -3369,20 +3031,7 @@
attrs = nodeAttr(Node), attrs = nodeAttr(Node),
children = itemsEls(ToSend)}]) children = itemsEls(ToSend)}])
end, end,
- case is_tuple(Host) of - case is_tuple(Host) of
+ ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza).
+
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
%% Host = host()
%% JID = jid()
@@ -3386,20 +3049,6 @@
%% Reason = stanzaError()
%% Response = [pubsubIQResponse()]
%% @doc <p>Return the list of affiliations as an XMPP response.</p>
- false -> - false ->
- ejabberd_router:route(service_jid(Host), - ejabberd_router:route(service_jid(Host),
- jlib:make_jid(LJID), Stanza); - jlib:make_jid(LJID), Stanza);
@ -949,11 +940,11 @@
- _ -> ok - _ -> ok
- end - end
- end. - end.
- + ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza).
-spec(get_affiliations/4 ::
( %% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
Host :: mod_pubsub:host(), %% Host = host()
@@ -3586,9 +3235,10 @@ @@ -3577,9 +3226,10 @@
case Entities of case Entities of
error -> {error, ?ERR_BAD_REQUEST}; error -> {error, ?ERR_BAD_REQUEST};
_ -> _ ->
@ -965,7 +956,7 @@
case lists:member(Owner, Owners) of case lists:member(Owner, Owners) of
true -> true ->
OwnerJID = jlib:make_jid(Owner), OwnerJID = jlib:make_jid(Owner),
@@ -3601,42 +3251,7 @@ @@ -3592,42 +3242,7 @@
_ -> Entities _ -> Entities
end, end,
lists:foreach(fun ({JID, Affiliation}) -> lists:foreach(fun ({JID, Affiliation}) ->
@ -1009,7 +1000,7 @@
end, end,
FilteredEntities), FilteredEntities),
{result, []}; {result, []};
@@ -3695,11 +3310,11 @@ @@ -3686,11 +3301,11 @@
end. end.
read_sub(Subscriber, Node, NodeID, SubID, Lang) -> read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
@ -1023,7 +1014,7 @@
OptionsEl = #xmlel{name = <<"options">>, OptionsEl = #xmlel{name = <<"options">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(Subscriber)}, [{<<"jid">>, jlib:jid_to_string(Subscriber)},
@@ -3733,7 +3348,7 @@ @@ -3724,7 +3339,7 @@
end. end.
set_options_helper(Configuration, JID, NodeID, SubID, Type) -> set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
@ -1032,7 +1023,7 @@
{result, GoodSubOpts} -> GoodSubOpts; {result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid _ -> invalid
end, end,
@@ -3765,7 +3380,7 @@ @@ -3756,7 +3371,7 @@
write_sub(_Subscriber, _NodeID, _SubID, invalid) -> write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
{error, extended_error(?ERR_BAD_REQUEST, <<"invalid-options">>)}; {error, extended_error(?ERR_BAD_REQUEST, <<"invalid-options">>)};
write_sub(Subscriber, NodeID, SubID, Options) -> write_sub(Subscriber, NodeID, SubID, Options) ->
@ -1041,7 +1032,7 @@
{error, notfound} -> {error, notfound} ->
{error, extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)}; {error, extended_error(?ERR_NOT_ACCEPTABLE, <<"invalid-subid">>)};
{result, _} -> {result, _} ->
@@ -3986,9 +3601,9 @@ @@ -3977,9 +3592,9 @@
ejabberd_router:route(service_jid(Host), ejabberd_router:route(service_jid(Host),
jlib:make_jid(JID), Stanza) jlib:make_jid(JID), Stanza)
end, end,
@ -1053,7 +1044,7 @@
true -> true ->
Result = lists:foldl(fun ({JID, Subscription, Result = lists:foldl(fun ({JID, Subscription,
SubId}, SubId},
@@ -4405,7 +4020,7 @@ @@ -4373,7 +3988,7 @@
{Depth, [{N, get_node_subs(N)} || N <- Nodes]} {Depth, [{N, get_node_subs(N)} || N <- Nodes]}
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))} end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
end, end,
@ -1062,7 +1053,7 @@
{result, CollSubs} -> CollSubs; {result, CollSubs} -> CollSubs;
_ -> [] _ -> []
end. end.
@@ -4419,9 +4034,9 @@ @@ -4387,9 +4002,9 @@
get_options_for_subs(NodeID, Subs) -> get_options_for_subs(NodeID, Subs) ->
lists:foldl(fun({JID, subscribed, SubID}, Acc) -> lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
@ -1074,7 +1065,7 @@
_ -> Acc _ -> Acc
end; end;
(_, Acc) -> (_, Acc) ->
@@ -5121,6 +4736,30 @@ @@ -5089,6 +4704,30 @@
_ -> features() _ -> features()
end. end.
@ -1105,7 +1096,7 @@
%% @doc <p>node tree plugin call.</p> %% @doc <p>node tree plugin call.</p>
tree_call({_User, Server, _Resource}, Function, Args) -> tree_call({_User, Server, _Resource}, Function, Args) ->
tree_call(Server, Function, Args); tree_call(Server, Function, Args);
@@ -5140,7 +4779,13 @@ @@ -5108,7 +4747,13 @@
tree_action(Host, Function, Args) -> tree_action(Host, Function, Args) ->
?DEBUG("tree_action ~p ~p ~p", [Host, Function, Args]), ?DEBUG("tree_action ~p ~p ~p", [Host, Function, Args]),
Fun = fun () -> tree_call(Host, Function, Args) end, Fun = fun () -> tree_call(Host, Function, Args) end,
@ -1120,7 +1111,7 @@
%% @doc <p>node plugin call.</p> %% @doc <p>node plugin call.</p>
node_call(Type, Function, Args) -> node_call(Type, Function, Args) ->
@@ -5165,13 +4810,12 @@ @@ -5133,13 +4778,12 @@
node_action(Host, Type, Function, Args) -> node_action(Host, Type, Function, Args) ->
?DEBUG("node_action ~p ~p ~p ~p", ?DEBUG("node_action ~p ~p ~p ~p",
[Host, Type, Function, Args]), [Host, Type, Function, Args]),
@ -1136,7 +1127,7 @@
case tree_call(Host, get_node, [Host, Node]) of case tree_call(Host, get_node, [Host, Node]) of
N when is_record(N, pubsub_node) -> N when is_record(N, pubsub_node) ->
case Action(N) of case Action(N) of
@@ -5185,16 +4829,22 @@ @@ -5153,16 +4797,22 @@
end, end,
Trans). Trans).
@ -1163,7 +1154,7 @@
{result, Result} -> {result, Result}; {result, Result} -> {result, Result};
{error, Error} -> {error, Error}; {error, Error} -> {error, Error};
{atomic, {result, Result}} -> {result, Result}; {atomic, {result, Result}} -> {result, Result};
@@ -5203,6 +4853,15 @@ @@ -5171,6 +4821,15 @@
?ERROR_MSG("transaction return internal error: ~p~n", ?ERROR_MSG("transaction return internal error: ~p~n",
[{aborted, Reason}]), [{aborted, Reason}]),
{error, ?ERR_INTERNAL_SERVER_ERROR}; {error, ?ERR_INTERNAL_SERVER_ERROR};
@ -1179,7 +1170,7 @@
{'EXIT', Reason} -> {'EXIT', Reason} ->
?ERROR_MSG("transaction return internal error: ~p~n", ?ERROR_MSG("transaction return internal error: ~p~n",
[{'EXIT', Reason}]), [{'EXIT', Reason}]),
@@ -5213,6 +4872,16 @@ @@ -5181,6 +4840,16 @@
{error, ?ERR_INTERNAL_SERVER_ERROR} {error, ?ERR_INTERNAL_SERVER_ERROR}
end. end.