%% 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),
features() ->
["create-nodes", %*
"auto-create", %*
+ "auto-subscribe", %*
"delete-nodes", %*
+ "filtered-notifications", %*
"item-ids",
+ "modify-affiliations",
"outcast-affiliation",
"persistent-items",
"publish", %*
"retrieve-affiliations",
"retrieve-items", %*
"retrieve-subscriptions",
- "subscribe", %*
- "auto-subscribe", %*
- "filtered-notifications" %*
+ "subscribe" %*
].
create_node_permission(_Host, _ServerHost, _Node, _ParentNode, _Owner, _Access) ->
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) ->