From 3d5fe6a337d248a882dd00bb454417e89f30d2f9 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Tue, 27 Oct 2009 14:07:35 +0000 Subject: [PATCH] fix disco bugs, thanks to Brian Cully (EJAB-1088) SVN Revision: 2710 --- src/mod_pubsub/mod_pubsub.erl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index d7d1fffe3..8ab29ea05 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -1101,12 +1101,17 @@ iq_disco_info(Host, SNode, From, Lang) -> end. iq_disco_items(Host, [], From) -> - {result, lists:map( - fun(#pubsub_node{nodeid = {_, SubNode}, type = Type}) -> - {result, Path} = node_call(Type, node_to_path, [SubNode]), - [Name|_] = lists:reverse(Path), - {xmlelement, "item", [{"jid", Host}, {"name", Name}|nodeAttr(SubNode)], []} - end, tree_action(Host, get_subnodes, [Host, <<>>, From]))}; + case tree_action(Host, get_subnodes, [Host, <<>>, From]) of + Nodes when is_list(Nodes) -> + {result, lists:map( + fun(#pubsub_node{nodeid = {_, SubNode}, type = Type}) -> + {result, Path} = node_call(Type, node_to_path, [SubNode]), + [Name|_] = lists:reverse(Path), + {xmlelement, "item", [{"jid", Host}, {"name", Name}|nodeAttr(SubNode)], []} + end, Nodes)}; + Other -> + Other + end; iq_disco_items(Host, Item, From) -> case string:tokens(Item, "!") of [_SNode, _ItemID] -> @@ -1122,7 +1127,9 @@ iq_disco_items(Host, Item, From) -> end, Nodes = lists:map( fun(#pubsub_node{nodeid = {_, SubNode}}) -> - {xmlelement, "item", [{"jid", Host}|nodeAttr(SubNode)], []} + {result, Path} = node_call(Type, node_to_path, [SubNode]), + [Name|_] = lists:reverse(Path), + {xmlelement, "item", [{"jid", Host}, {"name", Name}|nodeAttr(SubNode)], []} end, tree_call(Host, get_subnodes, [Host, Node, From])), Items = lists:map( fun(#pubsub_item{itemid = {RN, _}}) ->