mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
make last_item_cache feature cluster aware (EJAB-1234)
This commit is contained in:
parent
a5f8aeb6da
commit
07e870271e
@ -183,9 +183,8 @@ init([ServerHost, Opts]) ->
|
||||
pubsub_index:init(Host, ServerHost, Opts),
|
||||
ets:new(gen_mod:get_module_proc(Host, config), [set, named_table]),
|
||||
ets:new(gen_mod:get_module_proc(ServerHost, config), [set, named_table]),
|
||||
ets:new(gen_mod:get_module_proc(Host, last_items), [set, named_table]),
|
||||
ets:new(gen_mod:get_module_proc(ServerHost, last_items), [set, named_table]),
|
||||
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
|
||||
mnesia:create_table(pubsub_last_item, [{ram_copies, [node()]}, {attributes, record_info(fields, pubsub_last_item)}]),
|
||||
mod_disco:register_feature(ServerHost, ?NS_PUBSUB),
|
||||
ets:insert(gen_mod:get_module_proc(Host, config), {nodetree, NodeTree}),
|
||||
ets:insert(gen_mod:get_module_proc(Host, config), {plugins, Plugins}),
|
||||
@ -2054,7 +2053,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
||||
PluginPayload -> PluginPayload
|
||||
end,
|
||||
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:jid_tolower(Publisher), BroadcastPayload),
|
||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
case Result of
|
||||
default -> {result, Reply};
|
||||
_ -> {result, Result}
|
||||
@ -2064,14 +2063,14 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
||||
Type = TNode#pubsub_node.type,
|
||||
Options = TNode#pubsub_node.options,
|
||||
broadcast_retract_items(Host, Node, NodeId, Type, Options, Removed),
|
||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
{result, Reply};
|
||||
{result, {TNode, {Result, Removed}}} ->
|
||||
NodeId = TNode#pubsub_node.id,
|
||||
Type = TNode#pubsub_node.type,
|
||||
Options = TNode#pubsub_node.options,
|
||||
broadcast_retract_items(Host, Node, NodeId, Type, Options, Removed),
|
||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
{result, Result};
|
||||
{result, {_, default}} ->
|
||||
{result, Reply};
|
||||
@ -2310,10 +2309,10 @@ send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||
undefined ->
|
||||
send_items(Host, Node, NodeId, Type, LJID, 1);
|
||||
LastItem ->
|
||||
{ModifNow, ModifLjid} = LastItem#pubsub_item.modification,
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
Stanza = event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls([LastItem])}], ModifNow, ModifLjid),
|
||||
itemsEls([LastItem])}], ModifNow, ModifUSR),
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza)
|
||||
end;
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
@ -2330,10 +2329,10 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
end,
|
||||
Stanza = case ToSend of
|
||||
[LastItem] ->
|
||||
{ModifNow, ModifLjid} = LastItem#pubsub_item.modification,
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls(ToSend)}], ModifNow, ModifLjid);
|
||||
itemsEls(ToSend)}], ModifNow, ModifUSR);
|
||||
_ ->
|
||||
event_stanza(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
@ -2947,9 +2946,9 @@ payload_xmlelements([_|Tail], Count) -> payload_xmlelements(Tail, Count).
|
||||
event_stanza(Els) ->
|
||||
event_stanza_withmoreels(Els, []).
|
||||
|
||||
event_stanza_with_delay(Els, ModifNow, ModifLjid) ->
|
||||
event_stanza_with_delay(Els, ModifNow, ModifUSR) ->
|
||||
DateTime = calendar:now_to_datetime(ModifNow),
|
||||
MoreEls = [jlib:timestamp_to_xml(DateTime, utc, ModifLjid, "")],
|
||||
MoreEls = [jlib:timestamp_to_xml(DateTime, utc, ModifUSR, "")],
|
||||
event_stanza_withmoreels(Els, MoreEls).
|
||||
|
||||
event_stanza_withmoreels(Els, MoreEls) ->
|
||||
@ -3557,18 +3556,18 @@ is_last_item_cache_enabled(Host) ->
|
||||
_ -> false
|
||||
end.
|
||||
|
||||
set_cached_item({_, ServerHost, _}, NodeId, ItemId, Payload) ->
|
||||
set_cached_item(ServerHost, NodeId, ItemId, Payload);
|
||||
set_cached_item(Host, NodeId, ItemId, Payload) ->
|
||||
set_cached_item({_, ServerHost, _}, NodeId, ItemId, Publisher, Payload) ->
|
||||
set_cached_item(ServerHost, NodeId, ItemId, Publisher, Payload);
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true -> ets:insert(gen_mod:get_module_proc(Host, last_items), {NodeId, {ItemId, Payload}});
|
||||
true -> mnesia:dirty_write({pubsub_last_item, NodeId, ItemId, {now(), jlib:short_prepd_bare_jid(Publisher)}, Payload});
|
||||
_ -> ok
|
||||
end.
|
||||
unset_cached_item({_, ServerHost, _}, NodeId) ->
|
||||
unset_cached_item(ServerHost, NodeId);
|
||||
unset_cached_item(Host, NodeId) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true -> ets:delete(gen_mod:get_module_proc(Host, last_items), NodeId);
|
||||
true -> mnesia:dirty_delete({pubsub_last_item, NodeId});
|
||||
_ -> ok
|
||||
end.
|
||||
get_cached_item({_, ServerHost, _}, NodeId) ->
|
||||
@ -3576,9 +3575,10 @@ get_cached_item({_, ServerHost, _}, NodeId) ->
|
||||
get_cached_item(Host, NodeId) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true ->
|
||||
case catch ets:lookup(gen_mod:get_module_proc(Host, last_items), NodeId) of
|
||||
[{NodeId, {ItemId, Payload}}] ->
|
||||
#pubsub_item{itemid = {ItemId, NodeId}, payload = Payload};
|
||||
case mnesia:dirty_read({pubsub_last_item, NodeId}) of
|
||||
[{pubsub_last_item, NodeId, ItemId, Creation, Payload}] ->
|
||||
#pubsub_item{itemid = {ItemId, NodeId}, payload = Payload,
|
||||
creation = Creation, modification = Creation};
|
||||
_ ->
|
||||
undefined
|
||||
end;
|
||||
|
@ -183,9 +183,8 @@ init([ServerHost, Opts]) ->
|
||||
pubsub_index:init(Host, ServerHost, Opts),
|
||||
ets:new(gen_mod:get_module_proc(Host, config), [set, named_table]),
|
||||
ets:new(gen_mod:get_module_proc(ServerHost, config), [set, named_table]),
|
||||
ets:new(gen_mod:get_module_proc(Host, last_items), [set, named_table]),
|
||||
ets:new(gen_mod:get_module_proc(ServerHost, last_items), [set, named_table]),
|
||||
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
|
||||
mnesia:create_table(pubsub_last_item, [{ram_copies, [node()]}, {attributes, record_info(fields, pubsub_last_item)}]),
|
||||
mod_disco:register_feature(ServerHost, ?NS_PUBSUB),
|
||||
ets:insert(gen_mod:get_module_proc(Host, config), {nodetree, NodeTree}),
|
||||
ets:insert(gen_mod:get_module_proc(Host, config), {plugins, Plugins}),
|
||||
@ -1868,7 +1867,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
||||
PluginPayload -> PluginPayload
|
||||
end,
|
||||
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:jid_tolower(Publisher), BroadcastPayload),
|
||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
case Result of
|
||||
default -> {result, Reply};
|
||||
_ -> {result, Result}
|
||||
@ -1878,14 +1877,14 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
||||
Type = TNode#pubsub_node.type,
|
||||
Options = TNode#pubsub_node.options,
|
||||
broadcast_retract_items(Host, Node, NodeId, Type, Options, Removed),
|
||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
{result, Reply};
|
||||
{result, {TNode, {Result, Removed}}} ->
|
||||
NodeId = TNode#pubsub_node.id,
|
||||
Type = TNode#pubsub_node.type,
|
||||
Options = TNode#pubsub_node.options,
|
||||
broadcast_retract_items(Host, Node, NodeId, Type, Options, Removed),
|
||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
{result, Result};
|
||||
{result, {_, default}} ->
|
||||
{result, Reply};
|
||||
@ -2126,20 +2125,20 @@ send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||
% special ODBC optimization, works only with node_hometree_odbc, node_flat_odbc and node_pep_odbc
|
||||
case node_action(Host, Type, get_last_items, [NodeId, LJID, 1]) of
|
||||
{result, [LastItem]} ->
|
||||
{ModifNow, ModifLjid} = LastItem#pubsub_item.modification,
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls([LastItem])}], ModifNow, ModifLjid);
|
||||
itemsEls([LastItem])}], ModifNow, ModifUSR);
|
||||
_ ->
|
||||
event_stanza(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls([])}])
|
||||
end;
|
||||
LastItem ->
|
||||
{ModifNow, ModifLjid} = LastItem#pubsub_item.modification,
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls([LastItem])}], ModifNow, ModifLjid)
|
||||
itemsEls([LastItem])}], ModifNow, ModifUSR)
|
||||
end,
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
@ -2156,10 +2155,10 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
end,
|
||||
Stanza = case ToSend of
|
||||
[LastItem] ->
|
||||
{ModifNow, ModifLjid} = LastItem#pubsub_item.modification,
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls(ToSend)}], ModifNow, ModifLjid);
|
||||
itemsEls(ToSend)}], ModifNow, ModifUSR);
|
||||
_ ->
|
||||
event_stanza(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
@ -2757,9 +2756,9 @@ payload_xmlelements([_|Tail], Count) -> payload_xmlelements(Tail, Count).
|
||||
event_stanza(Els) ->
|
||||
event_stanza_withmoreels(Els, []).
|
||||
|
||||
event_stanza_with_delay(Els, ModifNow, ModifLjid) ->
|
||||
event_stanza_with_delay(Els, ModifNow, ModifUSR) ->
|
||||
DateTime = calendar:now_to_datetime(ModifNow),
|
||||
MoreEls = [jlib:timestamp_to_xml(DateTime, utc, ModifLjid, "")],
|
||||
MoreEls = [jlib:timestamp_to_xml(DateTime, utc, ModifUSR, "")],
|
||||
event_stanza_withmoreels(Els, MoreEls).
|
||||
|
||||
event_stanza_withmoreels(Els, MoreEls) ->
|
||||
@ -3391,18 +3390,18 @@ is_last_item_cache_enabled(Host) ->
|
||||
_ -> false
|
||||
end.
|
||||
|
||||
set_cached_item({_, ServerHost, _}, NodeId, ItemId, Payload) ->
|
||||
set_cached_item(ServerHost, NodeId, ItemId, Payload);
|
||||
set_cached_item(Host, NodeId, ItemId, Payload) ->
|
||||
set_cached_item({_, ServerHost, _}, NodeId, ItemId, Publisher, Payload) ->
|
||||
set_cached_item(ServerHost, NodeId, ItemId, Publisher, Payload);
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true -> ets:insert(gen_mod:get_module_proc(Host, last_items), {NodeId, {ItemId, Payload}});
|
||||
true -> mnesia:dirty_write({pubsub_last_item, NodeId, ItemId, {now(), jlib:short_prepd_bare_jid(Publisher)}, Payload});
|
||||
_ -> ok
|
||||
end.
|
||||
unset_cached_item({_, ServerHost, _}, NodeId) ->
|
||||
unset_cached_item(ServerHost, NodeId);
|
||||
unset_cached_item(Host, NodeId) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true -> ets:delete(gen_mod:get_module_proc(Host, last_items), NodeId);
|
||||
true -> mnesia:dirty_delete({pubsub_last_item, NodeId});
|
||||
_ -> ok
|
||||
end.
|
||||
get_cached_item({_, ServerHost, _}, NodeId) ->
|
||||
@ -3410,9 +3409,10 @@ get_cached_item({_, ServerHost, _}, NodeId) ->
|
||||
get_cached_item(Host, NodeId) ->
|
||||
case is_last_item_cache_enabled(Host) of
|
||||
true ->
|
||||
case catch ets:lookup(gen_mod:get_module_proc(Host, last_items), NodeId) of
|
||||
[{NodeId, {ItemId, Payload}}] ->
|
||||
#pubsub_item{itemid = {ItemId, NodeId}, payload = Payload};
|
||||
case mnesia:dirty_read({pubsub_last_item, NodeId}) of
|
||||
[{pubsub_last_item, NodeId, ItemId, Creation, Payload}] ->
|
||||
#pubsub_item{itemid = {ItemId, NodeId}, payload = Payload,
|
||||
creation = Creation, modification = Creation};
|
||||
_ ->
|
||||
undefined
|
||||
end;
|
||||
|
@ -135,3 +135,12 @@
|
||||
%% <p>This is the format of the <tt>subscriptions</tt> table. The type of the
|
||||
%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
|
||||
-record(pubsub_subscription, {subid, options}).
|
||||
|
||||
%% @type pubsubLastItem() = #pubsub_last_item{
|
||||
%% nodeid = nodeidx(),
|
||||
%% itemid = string(),
|
||||
%% payload = XMLContent::string()}.
|
||||
%% <p>This is the format of the <tt>last items</tt> table. it stores last item payload
|
||||
%% for every node</p>
|
||||
-record(pubsub_last_item, {nodeid, itemid, creation, payload}).
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2010-05-19 11:03:27.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2010-05-19 11:04:11.000000000 +0200
|
||||
--- mod_pubsub.erl 2010-05-28 11:46:24.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2010-05-28 11:55:17.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.
|
||||
@ -40,7 +40,7 @@
|
||||
-define(LOOPNAME, ejabberd_mod_pubsub_loop).
|
||||
-define(PLUGIN_PREFIX, "node_").
|
||||
-define(TREE_PREFIX, "nodetree_").
|
||||
@@ -221,8 +221,6 @@
|
||||
@@ -220,8 +220,6 @@
|
||||
ok
|
||||
end,
|
||||
ejabberd_router:register_route(Host),
|
||||
@ -49,7 +49,7 @@
|
||||
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
||||
State = #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
@@ -281,207 +279,14 @@
|
||||
@@ -280,207 +278,14 @@
|
||||
|
||||
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
||||
%% TODO, this call should be done plugin side
|
||||
@ -260,7 +260,7 @@
|
||||
send_loop(State) ->
|
||||
receive
|
||||
{presence, JID, Pid} ->
|
||||
@@ -492,17 +297,15 @@
|
||||
@@ -491,17 +296,15 @@
|
||||
%% for each node From is subscribed to
|
||||
%% and if the node is so configured, send the last published item to From
|
||||
lists:foreach(fun(PType) ->
|
||||
@ -284,7 +284,7 @@
|
||||
true ->
|
||||
% resource not concerned about that subscription
|
||||
ok
|
||||
@@ -748,10 +551,10 @@
|
||||
@@ -747,10 +550,10 @@
|
||||
lists:foreach(fun(PType) ->
|
||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
|
||||
lists:foreach(fun
|
||||
@ -297,7 +297,7 @@
|
||||
true ->
|
||||
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
||||
false ->
|
||||
@@ -921,7 +724,8 @@
|
||||
@@ -920,7 +723,8 @@
|
||||
sub_el = SubEl} = IQ ->
|
||||
{xmlelement, _, QAttrs, _} = SubEl,
|
||||
Node = xml:get_attr_s("node", QAttrs),
|
||||
@ -307,7 +307,7 @@
|
||||
{result, IQRes} ->
|
||||
jlib:iq_to_xml(
|
||||
IQ#iq{type = result,
|
||||
@@ -1034,7 +838,7 @@
|
||||
@@ -1033,7 +837,7 @@
|
||||
[] ->
|
||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||
_ ->
|
||||
@ -316,7 +316,7 @@
|
||||
{result, []} -> ["collection"];
|
||||
{result, _} -> ["leaf", "collection"];
|
||||
_ -> []
|
||||
@@ -1050,8 +854,9 @@
|
||||
@@ -1049,8 +853,9 @@
|
||||
[];
|
||||
true ->
|
||||
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
|
||||
@ -328,7 +328,7 @@
|
||||
end, features(Type))]
|
||||
end,
|
||||
%% TODO: add meta-data info (spec section 5.4)
|
||||
@@ -1080,8 +885,9 @@
|
||||
@@ -1079,8 +884,9 @@
|
||||
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
|
||||
@ -340,7 +340,7 @@
|
||||
end, features(Host, Node))};
|
||||
<<?NS_COMMANDS>> ->
|
||||
command_disco_info(Host, Node, From);
|
||||
@@ -1091,7 +897,7 @@
|
||||
@@ -1090,7 +896,7 @@
|
||||
node_disco_info(Host, Node, From)
|
||||
end.
|
||||
|
||||
@ -349,7 +349,7 @@
|
||||
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
||||
Nodes when is_list(Nodes) ->
|
||||
{result, lists:map(
|
||||
@@ -1108,14 +914,14 @@
|
||||
@@ -1107,14 +913,14 @@
|
||||
Other ->
|
||||
Other
|
||||
end;
|
||||
@ -367,7 +367,7 @@
|
||||
case string:tokens(Item, "!") of
|
||||
[_SNode, _ItemID] ->
|
||||
{result, []};
|
||||
@@ -1123,10 +929,10 @@
|
||||
@@ -1122,10 +928,10 @@
|
||||
Node = string_to_node(SNode),
|
||||
Action =
|
||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
@ -381,7 +381,7 @@
|
||||
end,
|
||||
Nodes = lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}, options = Options}) ->
|
||||
@@ -1144,7 +950,7 @@
|
||||
@@ -1143,7 +949,7 @@
|
||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||
{xmlelement, "item", [{"jid", Host}, {"name", Name}], []}
|
||||
end, NodeItems),
|
||||
@ -390,7 +390,7 @@
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, Result}} -> {result, Result};
|
||||
@@ -1273,7 +1079,8 @@
|
||||
@@ -1272,7 +1078,8 @@
|
||||
(_, Acc) ->
|
||||
Acc
|
||||
end, [], xml:remove_cdata(Els)),
|
||||
@ -400,7 +400,7 @@
|
||||
{get, "subscriptions"} ->
|
||||
get_subscriptions(Host, Node, From, Plugins);
|
||||
{get, "affiliations"} ->
|
||||
@@ -1296,7 +1103,9 @@
|
||||
@@ -1295,7 +1102,9 @@
|
||||
|
||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||
{xmlelement, _, _, SubEls} = SubEl,
|
||||
@ -411,7 +411,7 @@
|
||||
case Action of
|
||||
[{xmlelement, Name, Attrs, Els}] ->
|
||||
Node = string_to_node(xml:get_attr_s("node", Attrs)),
|
||||
@@ -1426,7 +1235,8 @@
|
||||
@@ -1425,7 +1234,8 @@
|
||||
_ -> []
|
||||
end
|
||||
end,
|
||||
@ -421,7 +421,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1465,7 +1275,7 @@
|
||||
@@ -1464,7 +1274,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -430,7 +430,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
Stanza = {xmlelement, "message",
|
||||
[],
|
||||
@@ -1494,7 +1304,7 @@
|
||||
@@ -1493,7 +1303,7 @@
|
||||
[{xmlelement, "value", [], [{xmlcdata, "false"}]}]}]}]},
|
||||
lists:foreach(fun(Owner) ->
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(Owner), Stanza)
|
||||
@ -439,7 +439,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
{xmlelement, _Name, _Attrs, Els} = Packet,
|
||||
@@ -1558,8 +1368,8 @@
|
||||
@@ -1557,8 +1367,8 @@
|
||||
"true" -> true;
|
||||
_ -> false
|
||||
end,
|
||||
@ -450,7 +450,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1750,7 +1560,7 @@
|
||||
@@ -1749,7 +1559,7 @@
|
||||
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "create", nodeAttr(Node),
|
||||
[]}]}],
|
||||
@ -459,7 +459,7 @@
|
||||
{result, {Result, broadcast}} ->
|
||||
%%Lang = "en", %% TODO: fix
|
||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@@ -1858,7 +1668,7 @@
|
||||
@@ -1857,7 +1667,7 @@
|
||||
%%<li>The node does not exist.</li>
|
||||
%%</ul>
|
||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
@ -468,7 +468,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -1866,7 +1676,7 @@
|
||||
@@ -1865,7 +1675,7 @@
|
||||
error -> {"", "", ""};
|
||||
J -> jlib:jid_tolower(J)
|
||||
end,
|
||||
@ -477,7 +477,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1885,9 +1695,13 @@
|
||||
@@ -1884,9 +1694,13 @@
|
||||
{"", "", ""} ->
|
||||
{false, false};
|
||||
_ ->
|
||||
@ -494,7 +494,7 @@
|
||||
end
|
||||
end,
|
||||
if
|
||||
@@ -2218,7 +2032,7 @@
|
||||
@@ -2217,7 +2031,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.
|
||||
@ -503,7 +503,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2257,11 +2071,11 @@
|
||||
@@ -2256,11 +2070,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -517,7 +517,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2274,7 +2088,8 @@
|
||||
@@ -2273,7 +2087,8 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
@ -527,7 +527,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2306,16 +2121,27 @@
|
||||
@@ -2305,16 +2120,27 @@
|
||||
%% @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) ->
|
||||
@ -538,30 +538,30 @@
|
||||
+ % special ODBC optimization, works only with node_hometree_odbc, node_flat_odbc and node_pep_odbc
|
||||
+ case node_action(Host, Type, get_last_items, [NodeId, LJID, 1]) of
|
||||
+ {result, [LastItem]} ->
|
||||
+ {ModifNow, ModifLjid} = LastItem#pubsub_item.modification,
|
||||
+ {ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
+ event_stanza_with_delay(
|
||||
+ [{xmlelement, "items", nodeAttr(Node),
|
||||
+ itemsEls([LastItem])}], ModifNow, ModifLjid);
|
||||
+ itemsEls([LastItem])}], ModifNow, ModifUSR);
|
||||
+ _ ->
|
||||
+ event_stanza(
|
||||
+ [{xmlelement, "items", nodeAttr(Node),
|
||||
+ itemsEls([])}])
|
||||
+ end;
|
||||
LastItem ->
|
||||
{ModifNow, ModifLjid} = LastItem#pubsub_item.modification,
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
- Stanza = event_stanza_with_delay(
|
||||
+ event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
- itemsEls([LastItem])}], ModifNow, ModifLjid),
|
||||
- itemsEls([LastItem])}], ModifNow, ModifUSR),
|
||||
- ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza)
|
||||
- end;
|
||||
+ itemsEls([LastItem])}], ModifNow, ModifLjid)
|
||||
+ itemsEls([LastItem])}], ModifNow, ModifUSR)
|
||||
+ end,
|
||||
+ ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2441,7 +2267,8 @@
|
||||
@@ -2440,7 +2266,8 @@
|
||||
error ->
|
||||
{error, ?ERR_BAD_REQUEST};
|
||||
_ ->
|
||||
@ -571,7 +571,7 @@
|
||||
case lists:member(Owner, Owners) of
|
||||
true ->
|
||||
OwnerJID = exmpp_jid:make(Owner),
|
||||
@@ -2451,24 +2278,7 @@
|
||||
@@ -2450,24 +2277,7 @@
|
||||
end,
|
||||
lists:foreach(
|
||||
fun({JID, Affiliation}) ->
|
||||
@ -597,7 +597,7 @@
|
||||
end, FilteredEntities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2521,11 +2331,11 @@
|
||||
@@ -2520,11 +2330,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -611,7 +611,7 @@
|
||||
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
||||
{"subid", SubID}|nodeAttr(Node)],
|
||||
[XdataEl]},
|
||||
@@ -2551,7 +2361,7 @@
|
||||
@@ -2550,7 +2360,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -620,7 +620,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2580,7 +2390,7 @@
|
||||
@@ -2579,7 +2389,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -629,7 +629,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2748,8 +2558,8 @@
|
||||
@@ -2747,8 +2557,8 @@
|
||||
{"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza)
|
||||
end,
|
||||
@ -640,7 +640,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3079,7 +2889,7 @@
|
||||
@@ -3078,7 +2888,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -649,7 +649,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3093,9 +2903,9 @@
|
||||
@@ -3092,9 +2902,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -661,7 +661,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3299,6 +3109,30 @@
|
||||
@@ -3298,6 +3108,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user