[invalid] -> invalid;
[] -> none;
[XFields] when is_list(XFields) ->
- ?DEBUG("XFields: ~p", [XFields]),
+ ?DEBUG("XFields: ~p", [XFields]),
case lists:keysearch("FORM_TYPE", 1, XFields) of
{value, {_, [?NS_PUBSUB_SUB_AUTH]}} ->
XFields;
%% Add pubsub-specific error element
extended_error(Error, Ext) ->
- extended_error(Error, Ext, [{"xmlns", ?NS_PUBSUB_ERRORS}]).
+ extended_error(Error, Ext,
+ [{"xmlns", ?NS_PUBSUB_ERRORS}]).
extended_error(Error, unsupported, Feature) ->
extended_error(Error, "unsupported",
[{"xmlns", ?NS_PUBSUB_ERRORS},
set_state(#pubsub_state{stateid = {OwnerKey, {Host, Node}}, affiliation = owner}),
{result, {default, broadcast}}.
-
%% @spec (Host, Removed) -> ok
%% Host = mod_pubsub:host()
%% Removed = [mod_pubsub:pubsubNode()]
{result, lists:map(Tr, States)}.
get_node_affiliations(Host, Node) ->
- States = mnesia:match_object(
- #pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}),
+ {result, States} = get_states(Host, Node),
Tr = fun(#pubsub_state{stateid = {J, {_, _}}, affiliation = A}) ->
{J, A}
end,
%% that will be added to the affiliation stored in the main
%% <tt>pubsub_state</tt> table.</p>
get_entity_subscriptions(Host, Owner) ->
- States = case jlib:jid_tolower(Owner) of
- {U, D, ""} -> mnesia:match_object(
+ SubKey = jlib:jid_tolower(Owner),
+ GenKey = jlib:jid_remove_resource(SubKey),
+ States = case SubKey of
+ GenKey -> mnesia:match_object(
#pubsub_state{stateid = {{U, D, '_'}, {Host, '_'}}, _ = '_'});
- {U, D, R} -> mnesia:match_object(
- #pubsub_state{stateid = {{U, D, ""}, {Host, '_'}}, _ = '_'})
+ _ -> mnesia:match_object(
+ #pubsub_state{stateid = {GenKey, {Host, '_'}}, _ = '_'})
++ mnesia:match_object(
- #pubsub_state{stateid = {{U, D, R}, {Host, '_'}}, _ = '_'})
+ #pubsub_state{stateid = {SubKey, {Host, '_'}}, _ = '_'})
end,
Tr = fun(#pubsub_state{stateid = {J, {_, N}}, subscription = S}) ->
{N, S, J}
{result, lists:map(Tr, States)}.
get_node_subscriptions(Host, Node) ->
- States = mnesia:match_object(
- #pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}),
+ {result, States} = get_states(Host, Node),
Tr = fun(#pubsub_state{stateid = {J, {_, _}}, subscription = S}) ->
{J, S}
end,
%% @spec (Item) -> ok | {error, Reason::stanzaError()}
%% Item = mod_pubsub:pubsubItems()
-%% @doc <p>Write a state into database.</p>
+%% @doc <p>Write an item into database.</p>
set_item(Item) when is_record(Item, pubsub_item) ->
mnesia:write(Item);
set_item(_) ->
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
LOwner = jlib:jid_tolower(Owner),
- {User, Server, _Resource} = LOwner,
+ {User, Server, _Resource} = LOwner,
Allowed = case LOwner of
{"", Host, ""} ->
true; % pubsub service always allowed
_ -> false
end;
E ->
- ?DEBUG("Create not allowed : ~p~n", [E]),
- false
+ ?DEBUG("Create not allowed : ~p~n", [E]),
+ false
end
end,
{result, Allowed}.
-
+
create_node(Host, Node, Owner) ->
case node_default:create_node(Host, Node, Owner) of
{result, _} -> {result, []};