diff options
author | Christophe Romain <christophe.romain@process-one.net> | 2009-06-29 21:46:13 +0000 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2009-06-29 21:46:13 +0000 |
commit | 35dc60c534f8710c7bd4a540d3a89b85023c7c19 (patch) | |
tree | f445bdcdbcfa251785dac1483fa3f32d7e79d837 /src/mod_pubsub/node_dag.erl | |
parent | Don't use lists:keyfind/3 bcause it was introduced only in recent R13A. (diff) |
minor bugfixes on dag nodes
SVN Revision: 2343
Diffstat (limited to 'src/mod_pubsub/node_dag.erl')
-rw-r--r-- | src/mod_pubsub/node_dag.erl | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mod_pubsub/node_dag.erl b/src/mod_pubsub/node_dag.erl index 954a26a9..a276f08f 100644 --- a/src/mod_pubsub/node_dag.erl +++ b/src/mod_pubsub/node_dag.erl @@ -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). |