diff options
author | Mickaël Rémond <mickael.remond@process-one.net> | 2006-06-07 14:07:18 +0000 |
---|---|---|
committer | Mickaël Rémond <mickael.remond@process-one.net> | 2006-06-07 14:07:18 +0000 |
commit | b80002a8bb2de8591ddf39f0b63dfe726d1c4c15 (patch) | |
tree | 1558294526fb9b6b798d4da893cfab21b36c51f4 /src | |
parent | * src/mod_pubsub/mod_pubsub.erl: Support for pubsub node (diff) |
* src/mod_pubsub/mod_pubsub.erl: Discovery query on an item does
no more return an "item not found error". Discovery stop
correctly at the item level (Thanks to Christophe Romain) (EJAB-105).
SVN Revision: 578
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_pubsub/mod_pubsub.erl | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index 6c46ffdb3..afea05cb0 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -328,32 +328,50 @@ iq_disco_info(SNode) -> [] end. - iq_disco_items(Host, From, SNode) -> - Node = string:tokens(SNode, "/"), + {Node,ItemID} = case SNode of + [] -> + {[],none}; + _ -> + Tokens = string:tokens(SNode, "!"), + NodeList = string:tokens(lists:nth(1, Tokens), "/"), + ItemName = case length(Tokens) of + 2 -> lists:nth(2, Tokens); + _ -> none + end, + {NodeList, ItemName} + end, + NodeFull = string:tokens(SNode,"/"), F = fun() -> case mnesia:read({pubsub_node, {Host, Node}}) of [#pubsub_node{info = Info}] -> - SubNodes = mnesia:index_read(pubsub_node, + case ItemID of + none -> + SubNodes = mnesia:index_read(pubsub_node, {Host, Node}, #pubsub_node.host_parent), - SubItems = - lists:map(fun(#pubsub_node{host_node = {_, N}}) -> + SubItems = lists:map(fun(#pubsub_node{host_node = {_, N}}) -> SN = node_to_string(N), {xmlelement, "item", [{"jid", Host}, {"node", SN}, {"name", lists:last(N)}], []} end, SubNodes), - SN = node_to_string(Node), - Items = - lists:map(fun(#item{id = Name}) -> + SN = node_to_string(Node), + Items = lists:map(fun(#item{id = Name}) -> + RealName = case Name of + [] -> "item"; + _ -> Name + end, {xmlelement, "item", [{"jid", Host}, {"node", SN ++ "!" ++ Name}, - {"name", Name}], []} + {"name", RealName}], []} end, Info#nodeinfo.items), - SubItems ++ Items; + SubItems ++ Items; + _ -> + [] + end; [] -> case Node of [] -> @@ -384,8 +402,6 @@ iq_disco_items(Host, From, SNode) -> {error, ?ERR_INTERNAL_SERVER_ERROR} end. - - iq_get_vcard(Lang) -> [{xmlelement, "FN", [], [{xmlcdata, "ejabberd/mod_pubsub"}]}, |