From d74c5271015cec4c4950c41f8d6a64562354d4dc Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Sat, 22 Dec 2007 01:13:06 +0000 Subject: [PATCH] EJAB-469 bugfix SVN Revision: 1097 --- ChangeLog | 2 +- src/mod_pubsub/mod_pubsub.erl | 1 + src/mod_pubsub/node_default.erl | 1 + src/mod_pubsub/node_pep.erl | 29 ++++++++++++++++++++++------- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0e127f71..a4611b173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ * src/ejabberd_c2s.erl: Likewise * src/mod_pubsub/mod_pubsub.erl: send last pep item bugfix and - broadcast optimization (EJAB-468) (EJAB-467) (EJAB-460) + broadcast optimization (EJAB-468) (EJAB-467) (EJAB-460) (EJAB-469) * src/mod_pubsub/pubsub.hrl: Likewise * src/mod_pubsub/node_default.erl: Likewise diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index 96f1f2880..e25b30af1 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -1687,6 +1687,7 @@ send_items(Host, Node, LJID, Number) -> %% Response = [pubsubIQResponse()] %% @doc

Return the list of affiliations as an XMPP response.

get_affiliations(Host, JID, Plugins) when is_list(Plugins) -> + ?INFO_MSG("**1 ~p",[{Host,JID,Plugins}]), Result = lists:foldl( fun(Type, {Status, Acc}) -> Features = features(Type), diff --git a/src/mod_pubsub/node_default.erl b/src/mod_pubsub/node_default.erl index b02eb6c0f..f6e513422 100644 --- a/src/mod_pubsub/node_default.erl +++ b/src/mod_pubsub/node_default.erl @@ -143,6 +143,7 @@ features() -> "instant-nodes", "item-ids", "manage-subscriptions", + "modify-affiliations", "outcast-affiliation", "persistent-items", "publish", diff --git a/src/mod_pubsub/node_pep.erl b/src/mod_pubsub/node_pep.erl index 7cd023d61..87ed3364d 100644 --- a/src/mod_pubsub/node_pep.erl +++ b/src/mod_pubsub/node_pep.erl @@ -75,8 +75,11 @@ options() -> features() -> ["create-nodes", %* "auto-create", %* + "auto-subscribe", %* "delete-nodes", %* + "filtered-notifications", %* "item-ids", + "modify-affiliations", "outcast-affiliation", "persistent-items", "publish", %* @@ -85,9 +88,7 @@ features() -> "retrieve-affiliations", "retrieve-items", %* "retrieve-subscriptions", - "subscribe", %* - "auto-subscribe", %* - "filtered-notifications" %* + "subscribe" %* ]. create_node_permission(_Host, _ServerHost, _Node, _ParentNode, _Owner, _Access) -> @@ -133,16 +134,30 @@ purge_node(Host, Node, Owner) -> get_entity_affiliations(_Host, Owner) -> OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), node_default:get_entity_affiliations(OwnerKey, Owner). - %{result, []}. -get_node_affiliations(_Host, _Node) -> - {result, []}. +get_node_affiliations(_Host, Node) -> + States = mnesia:match_object( + #pubsub_state{stateid = {'_', {'_', Node}}, + _ = '_'}), + Tr = fun(#pubsub_state{stateid = {J, {_, _}}, affiliation = A}) -> + {J, A} + end, + {result, lists:map(Tr, States)}. get_affiliation(_Host, Node, Owner) -> OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), node_default:get_affiliation(OwnerKey, Node, Owner). -set_affiliation(_Host, _Node, _Owner, _Affiliation) -> +set_affiliation(_Host, Node, Owner, Affiliation) -> + OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), + Record = case get_state(OwnerKey, Node, OwnerKey) of + {error, ?ERR_ITEM_NOT_FOUND} -> + #pubsub_state{stateid = {OwnerKey, {OwnerKey, Node}}, + affiliation = Affiliation}; + {result, State} -> + State#pubsub_state{affiliation = Affiliation} + end, + set_state(Record), ok. get_entity_subscriptions(_Host, _Owner) ->