]> granicus.if.org Git - ejabberd/commitdiff
EJAB-469 bugfix
authorChristophe Romain <christophe.romain@process-one.net>
Sat, 22 Dec 2007 01:13:06 +0000 (01:13 +0000)
committerChristophe Romain <christophe.romain@process-one.net>
Sat, 22 Dec 2007 01:13:06 +0000 (01:13 +0000)
SVN Revision: 1097

ChangeLog
src/mod_pubsub/mod_pubsub.erl
src/mod_pubsub/node_default.erl
src/mod_pubsub/node_pep.erl

index e0e127f71155ecbbd55264e695bb11de00940f78..a4611b1731f4443f84eb8d51bef671242f0ce68a 100644 (file)
--- 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
 
index 96f1f288089af0ce6e13f4ce54bc291cfe7cbeb1..e25b30af1e8147f39b7bd64958bf88ff64fc4085 100644 (file)
@@ -1687,6 +1687,7 @@ send_items(Host, Node, LJID, Number) ->
 %%      Response = [pubsubIQResponse()]
 %% @doc <p>Return the list of affiliations as an XMPP response.</p>
 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),
index b02eb6c0f203661a52a37cba7be6ad0f86f7d717..f6e513422fd3e0aed510b7f0a720e18e95cf376c 100644 (file)
@@ -143,6 +143,7 @@ features() ->
      "instant-nodes",
      "item-ids",
      "manage-subscriptions",
+     "modify-affiliations",
      "outcast-affiliation",
      "persistent-items",
      "publish",
index 7cd023d612c439815f6642e9ab96745d3727412c..87ed3364d10241c585329edcd5aa37cd3786be6a 100644 (file)
@@ -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) ->