mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
Add pubsub#notify_sub node option (EJAB-1230)(thanks to Karim Gemayel)
This commit is contained in:
parent
e1dd9ed875
commit
2f075b7b77
@ -1979,19 +1979,24 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
NodeId = TNode#pubsub_node.id,
|
||||
Type = TNode#pubsub_node.type,
|
||||
send_items(Host, Node, NodeId, Type, Subscriber, last),
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "subscribed"),
|
||||
case Result of
|
||||
default -> {result, Reply({subscribed, SubId})};
|
||||
_ -> {result, Result}
|
||||
end;
|
||||
{result, {_TNode, {default, subscribed, SubId}}} ->
|
||||
{result, {TNode, {default, subscribed, SubId}}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "subscribed"),
|
||||
{result, Reply({subscribed, SubId})};
|
||||
{result, {_TNode, {Result, subscribed, _SubId}}} ->
|
||||
{result, {TNode, {Result, subscribed, _SubId}}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "subscribed"),
|
||||
{result, Result};
|
||||
{result, {TNode, {default, pending, _SubId}}} ->
|
||||
send_authorization_request(TNode, Subscriber),
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "pending"),
|
||||
{result, Reply(pending)};
|
||||
{result, {TNode, {Result, pending}}} ->
|
||||
send_authorization_request(TNode, Subscriber),
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "pending"),
|
||||
{result, Result};
|
||||
{result, {_, Result}} ->
|
||||
%% this case should never occure anyway
|
||||
@ -2028,9 +2033,11 @@ unsubscribe_node(Host, Node, From, Subscriber, SubId) ->
|
||||
node_call(Type, unsubscribe_node, [NodeId, From, Subscriber, SubId])
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, default}} ->
|
||||
{result, {TNode, default}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "none"),
|
||||
{result, []};
|
||||
{result, {_, Result}} ->
|
||||
{result, {TNode, Result}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "none"),
|
||||
{result, Result};
|
||||
Error ->
|
||||
Error
|
||||
@ -3409,6 +3416,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) ->
|
||||
?BOOL_CONFIG_FIELD("Notify subscribers when the node configuration changes", notify_config),
|
||||
?BOOL_CONFIG_FIELD("Notify subscribers when the node is deleted", notify_delete),
|
||||
?BOOL_CONFIG_FIELD("Notify subscribers when items are removed from the node", notify_retract),
|
||||
?BOOL_CONFIG_FIELD("Notify owners about new subscribers and unsubscribes", notify_sub),
|
||||
?BOOL_CONFIG_FIELD("Persist items to storage", persist_items),
|
||||
?STRING_CONFIG_FIELD("A friendly name for the node", title),
|
||||
?INTEGER_CONFIG_FIELD("Max # of items to persist", max_items),
|
||||
@ -3542,6 +3550,8 @@ set_xoption(Host, [{"pubsub#notify_delete", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(notify_delete, Val);
|
||||
set_xoption(Host, [{"pubsub#notify_retract", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(notify_retract, Val);
|
||||
set_xoption(Host, [{"pubsub#notify_sub", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(notify_sub, Val);
|
||||
set_xoption(Host, [{"pubsub#persist_items", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(persist_items, Val);
|
||||
set_xoption(Host, [{"pubsub#max_items", [Val]} | Opts], NewOpts) ->
|
||||
@ -3970,3 +3980,16 @@ purge_offline({User, Server, _} = LJID) ->
|
||||
{Error, _} ->
|
||||
?DEBUG("on_user_offline ~p", [Error])
|
||||
end.
|
||||
|
||||
notify_owners(false, _, _, _, _, _) -> true;
|
||||
notify_owners(true, JID, Host, Node, Owners, State) ->
|
||||
Message = #xmlel{name = 'message', ns = ?NS_JABBER_CLIENT,
|
||||
children = [#xmlel{name = 'pubsub', ns = ?NS_PUBSUB,
|
||||
children = [#xmlel{name = 'subscription', ns = ?NS_PUBSUB,
|
||||
attrs = [?XMLATTR('node', Node),
|
||||
?XMLATTR('jid', exmpp_jid:prep_to_binary(exmpp_jid:make(JID))),
|
||||
?XMLATTR('subscription', State)]}]}]},
|
||||
lists:foreach(
|
||||
fun(Owner) ->
|
||||
ejabberd_router:route(exmpp_jid:make(Host), exmpp_jid:make(Owner), Message)
|
||||
end, Owners).
|
||||
|
@ -591,7 +591,10 @@ unsubscribe_user(Entity, Owner) ->
|
||||
%% user remove hook handling function
|
||||
%%
|
||||
|
||||
remove_user(User, Server) ->
|
||||
%% @spec(User::binary(), Server::binary()) -> any()
|
||||
remove_user(UserB, ServerB) ->
|
||||
User = binary_to_list(UserB),
|
||||
Server = binary_to_list(ServerB),
|
||||
LUser = exmpp_stringprep:nodeprep(User),
|
||||
LServer = exmpp_stringprep:nameprep(Server),
|
||||
Entity = exmpp_jid:make(LUser, LServer),
|
||||
@ -1795,19 +1798,24 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
NodeId = TNode#pubsub_node.id,
|
||||
Type = TNode#pubsub_node.type,
|
||||
send_items(Host, Node, NodeId, Type, Subscriber, last),
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "subscribed"),
|
||||
case Result of
|
||||
default -> {result, Reply({subscribed, SubId})};
|
||||
_ -> {result, Result}
|
||||
end;
|
||||
{result, {_TNode, {default, subscribed, SubId}}} ->
|
||||
{result, {TNode, {default, subscribed, SubId}}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "subscribed"),
|
||||
{result, Reply({subscribed, SubId})};
|
||||
{result, {_TNode, {Result, subscribed, _SubId}}} ->
|
||||
{result, {TNode, {Result, subscribed, _SubId}}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "subscribed"),
|
||||
{result, Result};
|
||||
{result, {TNode, {default, pending, _SubId}}} ->
|
||||
send_authorization_request(TNode, Subscriber),
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "pending"),
|
||||
{result, Reply(pending)};
|
||||
{result, {TNode, {Result, pending}}} ->
|
||||
send_authorization_request(TNode, Subscriber),
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "pending"),
|
||||
{result, Result};
|
||||
{result, {_, Result}} ->
|
||||
%% this case should never occure anyway
|
||||
@ -1844,9 +1852,11 @@ unsubscribe_node(Host, Node, From, Subscriber, SubId) ->
|
||||
node_call(Type, unsubscribe_node, [NodeId, From, Subscriber, SubId])
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, default}} ->
|
||||
{result, {TNode, default}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "none"),
|
||||
{result, []};
|
||||
{result, {_, Result}} ->
|
||||
{result, {TNode, Result}} ->
|
||||
notify_owners(get_option(TNode#pubsub_node.options, notify_sub), Subscriber, Host, Node, TNode#pubsub_node.owners, "none"),
|
||||
{result, Result};
|
||||
Error ->
|
||||
Error
|
||||
@ -3244,6 +3254,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) ->
|
||||
?BOOL_CONFIG_FIELD("Notify subscribers when the node configuration changes", notify_config),
|
||||
?BOOL_CONFIG_FIELD("Notify subscribers when the node is deleted", notify_delete),
|
||||
?BOOL_CONFIG_FIELD("Notify subscribers when items are removed from the node", notify_retract),
|
||||
?BOOL_CONFIG_FIELD("Notify owners about new subscribers and unsubscribes", notify_sub),
|
||||
?BOOL_CONFIG_FIELD("Persist items to storage", persist_items),
|
||||
?STRING_CONFIG_FIELD("A friendly name for the node", title),
|
||||
?INTEGER_CONFIG_FIELD("Max # of items to persist", max_items),
|
||||
@ -3377,6 +3388,8 @@ set_xoption(Host, [{"pubsub#notify_delete", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(notify_delete, Val);
|
||||
set_xoption(Host, [{"pubsub#notify_retract", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(notify_retract, Val);
|
||||
set_xoption(Host, [{"pubsub#notify_sub", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(notify_sub, Val);
|
||||
set_xoption(Host, [{"pubsub#persist_items", [Val]} | Opts], NewOpts) ->
|
||||
?SET_BOOL_XOPT(persist_items, Val);
|
||||
set_xoption(Host, [{"pubsub#max_items", [Val]} | Opts], NewOpts) ->
|
||||
@ -3837,3 +3850,16 @@ purge_offline({User, Server, _} = LJID) ->
|
||||
{Error, _} ->
|
||||
?DEBUG("on_user_offline ~p", [Error])
|
||||
end.
|
||||
|
||||
notify_owners(false, _, _, _, _, _) -> true;
|
||||
notify_owners(true, JID, Host, Node, Owners, State) ->
|
||||
Message = #xmlel{name = 'message', ns = ?NS_JABBER_CLIENT,
|
||||
children = [#xmlel{name = 'pubsub', ns = ?NS_PUBSUB,
|
||||
children = [#xmlel{name = 'subscription', ns = ?NS_PUBSUB,
|
||||
attrs = [?XMLATTR('node', Node),
|
||||
?XMLATTR('jid', exmpp_jid:prep_to_binary(exmpp_jid:make(JID))),
|
||||
?XMLATTR('subscription', State)]}]}]},
|
||||
lists:foreach(
|
||||
fun(Owner) ->
|
||||
ejabberd_router:route(exmpp_jid:make(Host), exmpp_jid:make(Owner), Message)
|
||||
end, Owners).
|
||||
|
@ -80,6 +80,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -86,6 +86,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -85,6 +85,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -83,6 +83,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -76,6 +76,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -77,6 +77,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -139,6 +139,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -141,6 +141,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -89,6 +89,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, false},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -84,6 +84,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, false},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, false},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -91,6 +91,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, false},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, false},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -86,6 +86,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -87,6 +87,7 @@ options() ->
|
||||
{notify_config, false},
|
||||
{notify_delete, false},
|
||||
{notify_retract, true},
|
||||
{notify_sub, false},
|
||||
{purge_offline, false},
|
||||
{persist_items, true},
|
||||
{max_items, ?MAXITEMS},
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2010-05-03 14:32:48.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2010-05-03 14:33:50.000000000 +0200
|
||||
--- mod_pubsub.erl 2010-05-12 12:00:56.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2010-05-12 12:01:12.000000000 +0200
|
||||
@@ -42,7 +42,7 @@
|
||||
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
|
||||
%%% XEP-0060 section 12.18.
|
||||
@ -285,7 +285,7 @@
|
||||
true ->
|
||||
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
||||
false ->
|
||||
@@ -937,10 +747,11 @@
|
||||
@@ -940,10 +750,11 @@
|
||||
end,
|
||||
ejabberd_router:route(To, From, Res);
|
||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||
@ -299,7 +299,7 @@
|
||||
{result, IQRes} ->
|
||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
||||
name = 'query', attrs = QAttrs,
|
||||
@@ -1060,7 +871,7 @@
|
||||
@@ -1063,7 +874,7 @@
|
||||
[] ->
|
||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||
_ ->
|
||||
@ -308,7 +308,7 @@
|
||||
{result, []} -> ["collection"];
|
||||
{result, _} -> ["leaf", "collection"];
|
||||
_ -> []
|
||||
@@ -1076,8 +887,9 @@
|
||||
@@ -1079,8 +890,9 @@
|
||||
[];
|
||||
true ->
|
||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||
@ -320,7 +320,7 @@
|
||||
end, features(Type))]
|
||||
end,
|
||||
%% TODO: add meta-data info (spec section 5.4)
|
||||
@@ -1106,8 +918,9 @@
|
||||
@@ -1109,8 +921,9 @@
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]},
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||
@ -332,7 +332,7 @@
|
||||
end, features(Host, Node))};
|
||||
?NS_ADHOC_b ->
|
||||
command_disco_info(Host, Node, From);
|
||||
@@ -1117,7 +930,7 @@
|
||||
@@ -1120,7 +933,7 @@
|
||||
node_disco_info(Host, Node, From)
|
||||
end.
|
||||
|
||||
@ -341,7 +341,7 @@
|
||||
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
||||
Nodes when is_list(Nodes) ->
|
||||
{result, lists:map(
|
||||
@@ -1134,7 +947,7 @@
|
||||
@@ -1137,7 +950,7 @@
|
||||
Other ->
|
||||
Other
|
||||
end;
|
||||
@ -350,7 +350,7 @@
|
||||
%% TODO: support localization of this string
|
||||
CommandItems = [
|
||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
||||
@@ -1143,10 +956,10 @@
|
||||
@@ -1146,10 +959,10 @@
|
||||
?XMLATTR('name', "Get Pending")
|
||||
]}],
|
||||
{result, CommandItems};
|
||||
@ -363,7 +363,7 @@
|
||||
case string:tokens(Item, "!") of
|
||||
[_SNode, _ItemID] ->
|
||||
{result, []};
|
||||
@@ -1154,10 +967,10 @@
|
||||
@@ -1157,10 +970,10 @@
|
||||
Node = string_to_node(SNode),
|
||||
Action =
|
||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
@ -377,7 +377,7 @@
|
||||
end,
|
||||
Nodes = lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}, options = Options}) ->
|
||||
@@ -1173,9 +986,10 @@
|
||||
@@ -1176,9 +989,10 @@
|
||||
Items = lists:map(
|
||||
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||
@ -390,7 +390,7 @@
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, Result}} -> {result, Result};
|
||||
@@ -1231,8 +1045,7 @@
|
||||
@@ -1234,8 +1048,7 @@
|
||||
iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
|
||||
case exmpp_xml:remove_cdata_from_list(SubEl#xmlel.children) of
|
||||
[#xmlel{name = Name, attrs = Attrs, children = Els} | Rest] ->
|
||||
@ -400,7 +400,7 @@
|
||||
case {IQType, Name} of
|
||||
{set, 'create'} ->
|
||||
Config = case Rest of
|
||||
@@ -1307,7 +1120,8 @@
|
||||
@@ -1310,7 +1123,8 @@
|
||||
(_, Acc) ->
|
||||
Acc
|
||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||
@ -410,7 +410,7 @@
|
||||
{get, 'subscriptions'} ->
|
||||
get_subscriptions(Host, Node, From, Plugins);
|
||||
{get, 'affiliations'} ->
|
||||
@@ -1464,7 +1278,8 @@
|
||||
@@ -1467,7 +1281,8 @@
|
||||
_ -> []
|
||||
end
|
||||
end,
|
||||
@ -420,7 +420,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1508,7 +1323,7 @@
|
||||
@@ -1511,7 +1326,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -429,7 +429,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
{U, S, R} = Subscriber,
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||
@@ -1538,7 +1353,7 @@
|
||||
@@ -1541,7 +1356,7 @@
|
||||
lists:foreach(fun(Owner) ->
|
||||
{U, S, R} = Owner,
|
||||
ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza)
|
||||
@ -438,7 +438,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
Els = Packet#xmlel.children,
|
||||
@@ -1580,7 +1395,7 @@
|
||||
@@ -1583,7 +1398,7 @@
|
||||
end,
|
||||
Stanza = event_stanza(
|
||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
||||
@ -447,7 +447,7 @@
|
||||
}]),
|
||||
ejabberd_router:route(service_jid(Host), JID, Stanza).
|
||||
|
||||
@@ -1597,8 +1412,8 @@
|
||||
@@ -1600,8 +1415,8 @@
|
||||
"true" -> true;
|
||||
_ -> false
|
||||
end,
|
||||
@ -458,7 +458,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1793,7 +1608,7 @@
|
||||
@@ -1796,7 +1611,7 @@
|
||||
end,
|
||||
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
||||
@ -467,7 +467,7 @@
|
||||
{result, {Result, broadcast}} ->
|
||||
%%Lang = "en", %% TODO: fix
|
||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@@ -1902,7 +1717,7 @@
|
||||
@@ -1905,7 +1720,7 @@
|
||||
%%<li>The node does not exist.</li>
|
||||
%%</ul>
|
||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
@ -476,7 +476,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -1912,7 +1727,7 @@
|
||||
@@ -1915,7 +1730,7 @@
|
||||
_:_ ->
|
||||
{undefined, undefined, undefined}
|
||||
end,
|
||||
@ -485,7 +485,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1931,9 +1746,13 @@
|
||||
@@ -1934,9 +1749,13 @@
|
||||
{"", "", ""} ->
|
||||
{false, false};
|
||||
_ ->
|
||||
@ -502,7 +502,7 @@
|
||||
end
|
||||
end,
|
||||
if
|
||||
@@ -2270,7 +2089,7 @@
|
||||
@@ -2280,7 +2099,7 @@
|
||||
%% <p>The permission are not checked in this function.</p>
|
||||
%% @todo We probably need to check that the user doing the query has the right
|
||||
%% to read the items.
|
||||
@ -511,7 +511,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2309,11 +2128,11 @@
|
||||
@@ -2319,11 +2138,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -525,7 +525,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2326,7 +2145,7 @@
|
||||
@@ -2336,7 +2155,7 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
||||
@ -534,7 +534,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2358,17 +2177,29 @@
|
||||
@@ -2368,17 +2187,29 @@
|
||||
%% @doc <p>Resend the items of a node to the user.</p>
|
||||
%% @todo use cache-last-item feature
|
||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||
@ -571,7 +571,7 @@
|
||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2448,9 +2279,8 @@
|
||||
@@ -2458,9 +2289,8 @@
|
||||
end
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
@ -583,7 +583,7 @@
|
||||
{result, {_, Affiliations}} ->
|
||||
Entities = lists:flatmap(
|
||||
fun({_, none}) -> [];
|
||||
@@ -2484,7 +2314,7 @@
|
||||
@@ -2494,7 +2324,7 @@
|
||||
_:_ -> error
|
||||
end,
|
||||
Affiliation = string_to_affiliation(
|
||||
@ -592,7 +592,7 @@
|
||||
if
|
||||
(JID == error) or
|
||||
(Affiliation == false) ->
|
||||
@@ -2499,29 +2329,13 @@
|
||||
@@ -2509,29 +2339,13 @@
|
||||
error ->
|
||||
{error, 'bad-request'};
|
||||
_ ->
|
||||
@ -626,7 +626,7 @@
|
||||
end, Entities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2555,7 +2369,7 @@
|
||||
@@ -2565,7 +2379,7 @@
|
||||
J -> jlib:short_jid(J)
|
||||
catch
|
||||
_ ->
|
||||
@ -635,7 +635,7 @@
|
||||
end,
|
||||
{result, Subs} = node_call(Type, get_subscriptions,
|
||||
[NodeID, Subscriber]),
|
||||
@@ -2576,14 +2390,14 @@
|
||||
@@ -2586,14 +2400,14 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -653,7 +653,7 @@
|
||||
children = [XdataEl]},
|
||||
PubsubEl = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [OptionsEl]},
|
||||
{result, PubsubEl}
|
||||
@@ -2607,14 +2421,14 @@
|
||||
@@ -2617,14 +2431,14 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -670,7 +670,7 @@
|
||||
end,
|
||||
{result, Subs} = node_call(Type, get_subscriptions,
|
||||
[NodeID, Subscriber]),
|
||||
@@ -2637,7 +2451,7 @@
|
||||
@@ -2647,7 +2461,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error('bad-request', "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -679,7 +679,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2810,8 +2624,8 @@
|
||||
@@ -2820,8 +2634,8 @@
|
||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||
ejabberd_router:route(service_jid(Host), JID, Stanza)
|
||||
end,
|
||||
@ -690,7 +690,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3107,7 +2921,7 @@
|
||||
@@ -3117,7 +2931,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -699,7 +699,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3121,9 +2935,9 @@
|
||||
@@ -3131,9 +2945,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -711,7 +711,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3338,6 +3152,30 @@
|
||||
@@ -3348,6 +3162,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -742,7 +742,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3736,7 +3574,13 @@
|
||||
@@ -3749,7 +3587,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -757,7 +757,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3756,13 +3600,13 @@
|
||||
@@ -3769,13 +3613,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -773,7 +773,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3775,8 +3619,15 @@
|
||||
@@ -3788,8 +3632,15 @@
|
||||
end
|
||||
end, Trans).
|
||||
|
||||
@ -791,7 +791,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3784,6 +3635,15 @@
|
||||
@@ -3797,6 +3648,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@ -807,7 +807,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@@ -3792,6 +3652,16 @@
|
||||
@@ -3805,6 +3665,16 @@
|
||||
{error, 'internal-server-error'}
|
||||
end.
|
||||
|
||||
@ -824,7 +824,7 @@
|
||||
%%%% helpers
|
||||
|
||||
%% Add pubsub-specific error element
|
||||
@@ -3880,7 +3750,7 @@
|
||||
@@ -3893,7 +3763,7 @@
|
||||
%% If the sender Server equals Host, the message comes from the Pubsub server
|
||||
Host -> allow;
|
||||
%% Else, the message comes from PEP
|
||||
|
Loading…
Reference in New Issue
Block a user