25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

minor bugfixes on dag nodes

SVN Revision: 2343
This commit is contained in:
Christophe Romain 2009-06-29 21:46:13 +00:00
parent 523239d5a7
commit 35dc60c534
4 changed files with 23 additions and 10 deletions

View File

@ -2651,7 +2651,7 @@ sub_to_deliver(_LJID, NotifyType, Depth, SubOptions) ->
sub_option_can_deliver(items, _, {subscription_type, nodes}) -> false;
sub_option_can_deliver(nodes, _, {subscription_type, items}) -> false;
sub_option_can_deliver(_, _, {subscription_depth, all}) -> true;
sub_option_can_deliver(_, Depth, {subscription_depth, D}) -> Depth < D;
sub_option_can_deliver(_, Depth, {subscription_depth, D}) -> Depth =< D;
sub_option_can_deliver(_, _, {deliver, false}) -> false;
sub_option_can_deliver(_, _, {expire, When}) -> now() < When;
sub_option_can_deliver(_, _, _) -> true.

View File

@ -86,8 +86,25 @@ unsubscribe_node(NodeID, Sender, Subscriber, SubID) ->
node_hometree:unsubscribe_node(NodeID, Sender, Subscriber, SubID).
publish_item(NodeID, Publisher, Model, MaxItems, ItemID, Payload) ->
node_hometree:publish_item(NodeID, Publisher, Model, MaxItems,
ItemID, Payload).
%% TODO: should look up the NodeTree plugin here. There's no
%% access to the Host of the request at this level, so for now we
%% just use nodetree_dag.
case nodetree_dag:get_node(NodeID) of
#pubsub_node{options = Options} ->
case find_opt(node_type, Options) of
collection ->
{error, ?ERR_EXTENDED(?ERR_NOT_ALLOWED, "publish")};
_ ->
node_hometree:publish_item(NodeID, Publisher, Model,
MaxItems, ItemID, Payload)
end;
Err ->
Err
end.
find_opt(_, []) -> false;
find_opt(Option, [{Option, Value} | _]) -> Value;
find_opt(Option, [_ | T]) -> find_opt(Option, T).
remove_extra_items(NodeID, MaxItems, ItemIDs) ->
node_hometree:remove_extra_items(NodeID, MaxItems, ItemIDs).

View File

@ -108,6 +108,7 @@ delete_node(Key, NodeID) ->
end, get_subnodes(Key, NodeID)),
%% Remove and return the requested node.
pubsub_index:free(node, Node#pubsub_node.id),
mnesia:delete_object(pubsub_node, Node, write),
[Node]
end.

View File

@ -150,13 +150,8 @@ get_subnodes_tree(_Host, _Node) ->
%% @doc <p>No node record is stored on database. Any valid node
%% is considered as already created.</p>
%% <p>default allowed nodes: /home/host/user/any/node/name</p>
create_node(Host, Node, _Type, Owner, _Options) ->
UserName = Owner#jid.luser,
UserHost = Owner#jid.lserver,
case Node of
["home", UserHost, UserName | _] -> {error, {virtual, {Host, Node}}};
_ -> {error, ?ERR_NOT_ALLOWED}
end.
create_node(Host, Node, _Type, _Owner, _Options) ->
{error, {virtual, {Host, Node}}}.
%% @spec (Host, Node) -> [mod_pubsub:node()]
%% Host = mod_pubsub:host()