mirror of
https://github.com/processone/ejabberd.git
synced 2024-07-06 23:22:36 +02:00
update the pubsub_odbc patch
This commit is contained in:
parent
1babae067d
commit
6bfd8b8e9a
|
@ -1833,9 +1833,12 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
|||
Features = features(Type),
|
||||
PublishFeature = lists:member("publish", Features),
|
||||
PublishModel = get_option(Options, publish_model),
|
||||
MaxItems = max_items(Host, Options),
|
||||
DeliverPayloads = get_option(Options, deliver_payloads),
|
||||
PersistItems = get_option(Options, persist_items),
|
||||
MaxItems = case PersistItems of
|
||||
false -> 0;
|
||||
true -> max_items(Host, Options)
|
||||
end,
|
||||
PayloadCount = payload_xmlelements(Payload),
|
||||
PayloadSize = size(term_to_binary(Payload))-2, % size(term_to_binary([])) == 2
|
||||
PayloadMaxSize = get_option(Options, max_payload_size),
|
||||
|
@ -2135,29 +2138,31 @@ get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners, RSM) ->
|
|||
%% Number = last | integer()
|
||||
%% @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) ->
|
||||
send_items(Host, Node, NodeId, Type, {U,S,R} = LJID, last) ->
|
||||
Stanza = case get_cached_item(Host, NodeId) of
|
||||
undefined ->
|
||||
% 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, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls([LastItem])}], ModifNow, ModifUSR);
|
||||
_ ->
|
||||
event_stanza(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls([])}])
|
||||
end;
|
||||
send_items(Host, Node, NodeId, Type, LJID, 1);
|
||||
LastItem ->
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls([LastItem])}], ModifNow, ModifUSR)
|
||||
end,
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
case is_tuple(Host) of
|
||||
false ->
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
true ->
|
||||
case ejabberd_sm:get_session_pid(U,S,R) of
|
||||
C2SPid when is_pid(C2SPid) ->
|
||||
ejabberd_c2s:broadcast(C2SPid,
|
||||
{pep_message, binary_to_list(Node)++"+notify"},
|
||||
_Sender = service_jid(Host),
|
||||
Stanza);
|
||||
_ ->
|
||||
ok
|
||||
end
|
||||
end;
|
||||
send_items(Host, Node, NodeId, Type, {U,S,R} = LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
[];
|
||||
|
@ -2180,7 +2185,20 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
|||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls(ToSend)}])
|
||||
end,
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza).
|
||||
case is_tuple(Host) of
|
||||
false ->
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
true ->
|
||||
case ejabberd_sm:get_session_pid(U,S,R) of
|
||||
C2SPid when is_pid(C2SPid) ->
|
||||
ejabberd_c2s:broadcast(C2SPid,
|
||||
{pep_message, binary_to_list(Node)++"+notify"},
|
||||
_Sender = service_jid(Host),
|
||||
Stanza);
|
||||
_ ->
|
||||
ok
|
||||
end
|
||||
end.
|
||||
|
||||
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
|
||||
%% Host = host()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
--- mod_pubsub.erl 2011-07-18 12:23:39.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2011-08-17 16:17:28.000000000 +0200
|
||||
--- mod_pubsub.erl 2011-08-29 09:35:41.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2011-09-26 16:35:05.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.
|
||||
|
@ -580,7 +580,7 @@
|
|||
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups),
|
||||
if
|
||||
not SubscribeFeature ->
|
||||
@@ -2275,7 +2042,7 @@
|
||||
@@ -2278,7 +2045,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.
|
||||
|
@ -589,7 +589,7 @@
|
|||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2289,12 +2056,13 @@
|
||||
@@ -2292,12 +2059,13 @@
|
||||
{error, Error} ->
|
||||
{error, Error};
|
||||
_ ->
|
||||
|
@ -604,7 +604,7 @@
|
|||
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
|
||||
if
|
||||
not RetreiveFeature ->
|
||||
@@ -2307,11 +2075,11 @@
|
||||
@@ -2310,11 +2078,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
|
@ -618,7 +618,7 @@
|
|||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2324,7 +2092,8 @@
|
||||
@@ -2327,7 +2095,8 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
|
@ -628,7 +628,7 @@
|
|||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2346,10 +2115,15 @@
|
||||
@@ -2349,10 +2118,15 @@
|
||||
Error -> Error
|
||||
end.
|
||||
get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
|
||||
|
@ -645,41 +645,51 @@
|
|||
|
||||
|
||||
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
|
||||
@@ -2362,16 +2136,27 @@
|
||||
@@ -2365,27 +2139,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) ->
|
||||
send_items(Host, Node, NodeId, Type, {U,S,R} = LJID, last) ->
|
||||
- case get_cached_item(Host, NodeId) of
|
||||
+ Stanza = case get_cached_item(Host, NodeId) of
|
||||
undefined ->
|
||||
- send_items(Host, Node, NodeId, Type, LJID, 1);
|
||||
+ % 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, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
+ event_stanza_with_delay(
|
||||
+ [{xmlelement, "items", nodeAttr(Node),
|
||||
+ itemsEls([LastItem])}], ModifNow, ModifUSR);
|
||||
+ _ ->
|
||||
+ event_stanza(
|
||||
+ [{xmlelement, "items", nodeAttr(Node),
|
||||
+ itemsEls([])}])
|
||||
+ end;
|
||||
send_items(Host, Node, NodeId, Type, LJID, 1);
|
||||
LastItem ->
|
||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||
- Stanza = event_stanza_with_delay(
|
||||
+ event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
- itemsEls([LastItem])}], ModifNow, ModifUSR),
|
||||
- ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza)
|
||||
- end;
|
||||
- case is_tuple(Host) of
|
||||
- false ->
|
||||
- ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
- true ->
|
||||
- case ejabberd_sm:get_session_pid(U,S,R) of
|
||||
- C2SPid when is_pid(C2SPid) ->
|
||||
- ejabberd_c2s:broadcast(C2SPid,
|
||||
- {pep_message, binary_to_list(Node)++"+notify"},
|
||||
- _Sender = service_jid(Host),
|
||||
- Stanza);
|
||||
- _ ->
|
||||
- ok
|
||||
- end
|
||||
+ 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, []} ->
|
||||
@@ -2497,7 +2282,8 @@
|
||||
+ case is_tuple(Host) of
|
||||
+ false ->
|
||||
+ ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
+ true ->
|
||||
+ case ejabberd_sm:get_session_pid(U,S,R) of
|
||||
+ C2SPid when is_pid(C2SPid) ->
|
||||
+ ejabberd_c2s:broadcast(C2SPid,
|
||||
+ {pep_message, binary_to_list(Node)++"+notify"},
|
||||
+ _Sender = service_jid(Host),
|
||||
+ Stanza);
|
||||
+ _ ->
|
||||
+ ok
|
||||
end
|
||||
end;
|
||||
send_items(Host, Node, NodeId, Type, {U,S,R} = LJID, Number) ->
|
||||
@@ -2526,7 +2300,8 @@
|
||||
error ->
|
||||
{error, ?ERR_BAD_REQUEST};
|
||||
_ ->
|
||||
|
@ -689,7 +699,7 @@
|
|||
case lists:member(Owner, Owners) of
|
||||
true ->
|
||||
OwnerJID = jlib:make_jid(Owner),
|
||||
@@ -2507,24 +2293,7 @@
|
||||
@@ -2536,24 +2311,7 @@
|
||||
end,
|
||||
lists:foreach(
|
||||
fun({JID, Affiliation}) ->
|
||||
|
@ -715,7 +725,7 @@
|
|||
end, FilteredEntities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2577,9 +2346,9 @@
|
||||
@@ -2606,9 +2364,9 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
|
@ -727,7 +737,7 @@
|
|||
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
||||
{"subid", SubID}|nodeAttr(Node)],
|
||||
[XdataEl]},
|
||||
@@ -2611,7 +2380,7 @@
|
||||
@@ -2640,7 +2398,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
|
@ -736,7 +746,7 @@
|
|||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2810,8 +2579,8 @@
|
||||
@@ -2839,8 +2597,8 @@
|
||||
{"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza)
|
||||
end,
|
||||
|
@ -747,7 +757,7 @@
|
|||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3174,7 +2943,7 @@
|
||||
@@ -3203,7 +2961,7 @@
|
||||
Collection = tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]),
|
||||
{result, [{Depth, [{N, sub_with_options(N)} || N <- Nodes]} || {Depth, Nodes} <- Collection]}
|
||||
end,
|
||||
|
@ -756,7 +766,7 @@
|
|||
{result, CollSubs} -> subscribed_nodes_by_jid(NotifyType, CollSubs);
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3243,8 +3012,8 @@
|
||||
@@ -3272,8 +3030,8 @@
|
||||
[]
|
||||
end.
|
||||
sub_with_options(JID, NodeId, SubId) ->
|
||||
|
@ -767,7 +777,7 @@
|
|||
_ -> {JID, SubId, []}
|
||||
end.
|
||||
|
||||
@@ -3320,6 +3089,30 @@
|
||||
@@ -3349,6 +3107,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
|
@ -798,7 +808,7 @@
|
|||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3450,7 +3243,7 @@
|
||||
@@ -3479,7 +3261,7 @@
|
||||
end
|
||||
end,
|
||||
case transaction(Host, Node, Action, transaction) of
|
||||
|
@ -807,7 +817,7 @@
|
|||
NodeId = TNode#pubsub_node.id,
|
||||
Type = TNode#pubsub_node.type,
|
||||
Options = TNode#pubsub_node.options,
|
||||
@@ -3716,7 +3509,13 @@
|
||||
@@ -3745,7 +3527,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
|
@ -822,7 +832,7 @@
|
|||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3736,13 +3535,13 @@
|
||||
@@ -3765,13 +3553,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
|
@ -838,7 +848,7 @@
|
|||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3754,13 +3553,19 @@
|
||||
@@ -3783,13 +3571,19 @@
|
||||
Error
|
||||
end
|
||||
end, Trans).
|
||||
|
@ -862,7 +872,7 @@
|
|||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3768,6 +3573,15 @@
|
||||
@@ -3797,6 +3591,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
|
@ -878,7 +888,7 @@
|
|||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@@ -3776,6 +3590,17 @@
|
||||
@@ -3805,6 +3608,17 @@
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user