diff options
Diffstat (limited to 'src/mod_pubsub/mod_pubsub_odbc.erl')
-rw-r--r-- | src/mod_pubsub/mod_pubsub_odbc.erl | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/mod_pubsub/mod_pubsub_odbc.erl b/src/mod_pubsub/mod_pubsub_odbc.erl index 2ed6d2268..058eb71a5 100644 --- a/src/mod_pubsub/mod_pubsub_odbc.erl +++ b/src/mod_pubsub/mod_pubsub_odbc.erl @@ -1544,11 +1544,19 @@ create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) -> end, case node_call(Type, create_node_permission, [Host, ServerHost, Node, Parent, Owner, Access]) of {result, true} -> + ParentTree = tree_call(Host, get_parentnodes_tree, [Host, Node, Owner]), + SubsByDepth = [{Depth, [{N, get_node_subs(N)} || N <- Nodes]} || {Depth, Nodes} <- ParentTree], case tree_call(Host, create_node, [Host, Node, Type, Owner, NodeOptions, Parents]) of {ok, NodeId} -> - node_call(Type, create_node, [NodeId, Owner]); + case node_call(Type, create_node, [NodeId, Owner]) of + {result, Result} -> {result, {NodeId, SubsByDepth, Result}}; + Error -> Error + end; {error, {virtual, NodeId}} -> - node_call(Type, create_node, [NodeId, Owner]); + case node_call(Type, create_node, [NodeId, Owner]) of + {result, Result} -> {result, {NodeId, SubsByDepth, Result}}; + Error -> Error + end; Error -> Error end; @@ -1560,20 +1568,15 @@ create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) -> [{xmlelement, "create", nodeAttr(Node), []}]}], case transaction(Host, CreateNode, transaction) of - {result, {Result, broadcast}} -> - %%Lang = "en", %% TODO: fix - %%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), - %%broadcast_publish_item(Host, Node, uniqid(), Owner, - %% [{xmlelement, "x", [{"xmlns", ?NS_XDATA}, {"type", "result"}], - %% [?XFIELD("hidden", "", "FORM_TYPE", ?NS_PUBSUB_NMI), - %% ?XFIELD("jid-single", "Node Creator", "creator", jlib:jid_to_string(OwnerKey))]}]), + {result, {NodeId, SubsByDepth, {Result, broadcast}}} -> + broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth), case Result of default -> {result, Reply}; _ -> {result, Result} end; - {result, default} -> + {result, {_NodeId, _SubsByDepth, default}} -> {result, Reply}; - {result, Result} -> + {result, {_NodeId, _SubsByDepth, Result}} -> {result, Result}; Error -> %% in case we change transaction to sync_dirty... @@ -2844,7 +2847,7 @@ broadcast_removed_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth) -> case get_option(NodeOptions, notify_delete) of true -> case SubsByDepth of - [] -> + [] -> {result, false}; _ -> Stanza = event_stanza( @@ -2858,6 +2861,13 @@ broadcast_removed_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth) -> {result, false} end. +broadcast_created_node(_, _, _, _, _, []) -> + {result, false}; +broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth) -> + Stanza = event_stanza([{xmlelement, "create", nodeAttr(Node), []}]), + broadcast_stanza(Host, Node, NodeId, Type, NodeOptions, SubsByDepth, nodes, Stanza, true), + {result, true}. + broadcast_config_notification(Host, Node, NodeId, Type, NodeOptions, Lang) -> case get_option(NodeOptions, notify_config) of true -> @@ -2875,7 +2885,7 @@ broadcast_config_notification(Host, Node, NodeId, Type, NodeOptions, Lang) -> broadcast_stanza(Host, Node, NodeId, Type, NodeOptions, SubsByDepth, nodes, Stanza, false), {result, true}; - _ -> + _ -> {result, false} end; _ -> |