mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
enable pubsub#deliver_notification checking (thanks to Karim Gemayel)(EJAB-1453)
This commit is contained in:
parent
917d1be994
commit
75fc431fb8
@ -2064,13 +2064,20 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
||||
NodeId = TNode#pubsub_node.id,
|
||||
Type = TNode#pubsub_node.type,
|
||||
Options = TNode#pubsub_node.options,
|
||||
BroadcastPayload = case Broadcast of
|
||||
default -> Payload;
|
||||
broadcast -> 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, Publisher, Payload),
|
||||
case get_option(Options, deliver_notifications) of
|
||||
true ->
|
||||
BroadcastPayload = case Broadcast of
|
||||
default -> Payload;
|
||||
broadcast -> Payload;
|
||||
PluginPayload -> PluginPayload
|
||||
end,
|
||||
broadcast_publish_item(Host, Node, NodeId, Type, Options,
|
||||
Removed, ItemId, jlib:jid_tolower(Publisher),
|
||||
BroadcastPayload);
|
||||
false ->
|
||||
ok
|
||||
end,
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
case Result of
|
||||
default -> {result, Reply};
|
||||
_ -> {result, Result}
|
||||
|
@ -1877,12 +1877,19 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
||||
NodeId = TNode#pubsub_node.id,
|
||||
Type = TNode#pubsub_node.type,
|
||||
Options = TNode#pubsub_node.options,
|
||||
BroadcastPayload = case Broadcast of
|
||||
default -> Payload;
|
||||
broadcast -> Payload;
|
||||
PluginPayload -> PluginPayload
|
||||
end,
|
||||
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:jid_tolower(Publisher), BroadcastPayload),
|
||||
case get_option(Options, deliver_notifications) of
|
||||
true ->
|
||||
BroadcastPayload = case Broadcast of
|
||||
default -> Payload;
|
||||
broadcast -> Payload;
|
||||
PluginPayload -> PluginPayload
|
||||
end,
|
||||
broadcast_publish_item(Host, Node, NodeId, Type, Options,
|
||||
Removed, ItemId, jlib:jid_tolower(Publisher),
|
||||
BroadcastPayload);
|
||||
false ->
|
||||
ok
|
||||
end,
|
||||
set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
case Result of
|
||||
default -> {result, Reply};
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2010-12-07 13:54:26.000000000 +0100
|
||||
+++ mod_pubsub_odbc.erl 2010-12-07 13:59:56.000000000 +0100
|
||||
--- mod_pubsub.erl 2011-08-31 16:08:42.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2011-08-31 16:08:42.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.
|
||||
@ -531,7 +531,30 @@
|
||||
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups),
|
||||
if
|
||||
not SubscribeFeature ->
|
||||
@@ -2231,7 +2047,7 @@
|
||||
@@ -2021,12 +1837,9 @@
|
||||
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),
|
||||
@@ -2077,7 +1890,7 @@
|
||||
false ->
|
||||
ok
|
||||
end,
|
||||
- set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
+ set_cached_item(Host, NodeId, ItemId, Publisher, Payload),
|
||||
case Result of
|
||||
default -> {result, Reply};
|
||||
_ -> {result, Result}
|
||||
@@ -2241,7 +2054,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.
|
||||
@ -540,7 +563,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2245,12 +2061,13 @@
|
||||
@@ -2255,12 +2068,13 @@
|
||||
{error, Error} ->
|
||||
{error, Error};
|
||||
_ ->
|
||||
@ -555,7 +578,7 @@
|
||||
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
|
||||
if
|
||||
not RetreiveFeature ->
|
||||
@@ -2263,11 +2080,11 @@
|
||||
@@ -2273,11 +2087,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -569,7 +592,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2280,7 +2097,8 @@
|
||||
@@ -2290,7 +2104,8 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
@ -579,7 +602,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2302,10 +2120,15 @@
|
||||
@@ -2312,10 +2127,15 @@
|
||||
Error -> Error
|
||||
end.
|
||||
get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
|
||||
@ -596,11 +619,13 @@
|
||||
|
||||
|
||||
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
|
||||
@@ -2318,16 +2141,27 @@
|
||||
@@ -2327,31 +2147,29 @@
|
||||
%% 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) ->
|
||||
- case get_cached_item(Host, NodeId) of
|
||||
+send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||
+ Stanza = case get_cached_item(Host, NodeId) of
|
||||
undefined ->
|
||||
- send_items(Host, Node, NodeId, Type, LJID, 1);
|
||||
@ -622,15 +647,52 @@
|
||||
+ event_stanza_with_delay(
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
- itemsEls([LastItem])}], ModifNow, ModifUSR),
|
||||
- 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
|
||||
- end;
|
||||
-send_items(Host, Node, NodeId, Type, {U,S,R} = LJID, Number) ->
|
||||
+ itemsEls([LastItem])}], ModifNow, ModifUSR)
|
||||
+ end,
|
||||
+ ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
+send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2453,7 +2287,8 @@
|
||||
[];
|
||||
@@ -2374,20 +2192,7 @@
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
itemsEls(ToSend)}])
|
||||
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
|
||||
- end.
|
||||
+ ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza).
|
||||
|
||||
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
|
||||
%% Host = host()
|
||||
@@ -2489,7 +2294,8 @@
|
||||
error ->
|
||||
{error, ?ERR_BAD_REQUEST};
|
||||
_ ->
|
||||
@ -640,7 +702,7 @@
|
||||
case lists:member(Owner, Owners) of
|
||||
true ->
|
||||
OwnerJID = jlib:make_jid(Owner),
|
||||
@@ -2463,24 +2298,7 @@
|
||||
@@ -2499,24 +2305,7 @@
|
||||
end,
|
||||
lists:foreach(
|
||||
fun({JID, Affiliation}) ->
|
||||
@ -666,7 +728,7 @@
|
||||
end, FilteredEntities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2533,11 +2351,11 @@
|
||||
@@ -2569,11 +2358,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -680,7 +742,7 @@
|
||||
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
||||
{"subid", SubID}|nodeAttr(Node)],
|
||||
[XdataEl]},
|
||||
@@ -2563,7 +2381,7 @@
|
||||
@@ -2599,7 +2388,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -689,7 +751,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2592,7 +2410,7 @@
|
||||
@@ -2628,7 +2417,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -698,7 +760,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2760,8 +2578,8 @@
|
||||
@@ -2796,8 +2585,8 @@
|
||||
{"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza)
|
||||
end,
|
||||
@ -709,7 +771,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3116,7 +2934,7 @@
|
||||
@@ -3152,7 +2941,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -718,7 +780,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3130,9 +2948,9 @@
|
||||
@@ -3166,9 +2955,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -730,7 +792,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3321,6 +3139,30 @@
|
||||
@@ -3357,6 +3146,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -761,7 +823,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3717,7 +3559,13 @@
|
||||
@@ -3753,7 +3566,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -776,7 +838,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3737,13 +3585,13 @@
|
||||
@@ -3773,13 +3592,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -792,7 +854,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3755,13 +3603,19 @@
|
||||
@@ -3791,13 +3610,19 @@
|
||||
Error
|
||||
end
|
||||
end, Trans).
|
||||
@ -816,7 +878,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3769,6 +3623,15 @@
|
||||
@@ -3805,6 +3630,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@ -832,7 +894,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@@ -3777,6 +3640,17 @@
|
||||
@@ -3813,6 +3647,17 @@
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user