mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
add pubsub#purge_offline (EJAB-1186) (thanks karim)
This commit is contained in:
parent
3c36cd64e3
commit
fe40651b0d
@ -63,6 +63,7 @@
|
|||||||
-export([presence_probe/3,
|
-export([presence_probe/3,
|
||||||
in_subscription/6,
|
in_subscription/6,
|
||||||
out_subscription/4,
|
out_subscription/4,
|
||||||
|
on_user_offline/3,
|
||||||
remove_user/2,
|
remove_user/2,
|
||||||
feature_check_packet/6,
|
feature_check_packet/6,
|
||||||
disco_local_identity/5,
|
disco_local_identity/5,
|
||||||
@ -200,6 +201,7 @@ init([ServerHost, Opts]) ->
|
|||||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
|
||||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {ignore_pep_from_offline, PepOffline}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {ignore_pep_from_offline, PepOffline}),
|
||||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
||||||
|
ejabberd_hooks:add(sm_remove_connection_hook, ServerHostB, ?MODULE, on_user_offline, 75),
|
||||||
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
||||||
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
||||||
ejabberd_hooks:add(disco_sm_items, ServerHostB, ?MODULE, disco_sm_items, 75),
|
ejabberd_hooks:add(disco_sm_items, ServerHostB, ?MODULE, disco_sm_items, 75),
|
||||||
@ -876,6 +878,7 @@ terminate(_Reason, #state{host = Host,
|
|||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
ejabberd_hooks:delete(sm_remove_connection_hook, ServerHostB, ?MODULE, on_user_offline, 75),
|
||||||
ejabberd_hooks:delete(disco_local_identity, ServerHostB, ?MODULE, disco_local_identity, 75),
|
ejabberd_hooks:delete(disco_local_identity, ServerHostB, ?MODULE, disco_local_identity, 75),
|
||||||
ejabberd_hooks:delete(disco_local_features, ServerHostB, ?MODULE, disco_local_features, 75),
|
ejabberd_hooks:delete(disco_local_features, ServerHostB, ?MODULE, disco_local_features, 75),
|
||||||
ejabberd_hooks:delete(disco_local_items, ServerHostB, ?MODULE, disco_local_items, 75),
|
ejabberd_hooks:delete(disco_local_items, ServerHostB, ?MODULE, disco_local_items, 75),
|
||||||
@ -3390,6 +3393,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) ->
|
|||||||
?LISTM_CONFIG_FIELD("Roster groups allowed to subscribe", roster_groups_allowed, Groups),
|
?LISTM_CONFIG_FIELD("Roster groups allowed to subscribe", roster_groups_allowed, Groups),
|
||||||
?ALIST_CONFIG_FIELD("Specify the publisher model", publish_model,
|
?ALIST_CONFIG_FIELD("Specify the publisher model", publish_model,
|
||||||
[publishers, subscribers, open]),
|
[publishers, subscribers, open]),
|
||||||
|
?BOOL_CONFIG_FIELD("Purge all items when the relevant publisher goes offline", purge_offline),
|
||||||
?ALIST_CONFIG_FIELD("Specify the event message type", notification_type,
|
?ALIST_CONFIG_FIELD("Specify the event message type", notification_type,
|
||||||
[headline, normal]),
|
[headline, normal]),
|
||||||
?INTEGER_CONFIG_FIELD("Max payload size in bytes", max_payload_size),
|
?INTEGER_CONFIG_FIELD("Max payload size in bytes", max_payload_size),
|
||||||
@ -3533,6 +3537,8 @@ set_xoption(Host, [{"pubsub#send_last_published_item", [Val]} | Opts], NewOpts)
|
|||||||
?SET_ALIST_XOPT(send_last_published_item, Val, [never, on_sub, on_sub_and_presence]);
|
?SET_ALIST_XOPT(send_last_published_item, Val, [never, on_sub, on_sub_and_presence]);
|
||||||
set_xoption(Host, [{"pubsub#presence_based_delivery", [Val]} | Opts], NewOpts) ->
|
set_xoption(Host, [{"pubsub#presence_based_delivery", [Val]} | Opts], NewOpts) ->
|
||||||
?SET_BOOL_XOPT(presence_based_delivery, Val);
|
?SET_BOOL_XOPT(presence_based_delivery, Val);
|
||||||
|
set_xoption(Host, [{"pubsub#purge_offline", [Val]} | Opts], NewOpts) ->
|
||||||
|
?SET_BOOL_XOPT(purge_offline, Val);
|
||||||
set_xoption(Host, [{"pubsub#title", Value} | Opts], NewOpts) ->
|
set_xoption(Host, [{"pubsub#title", Value} | Opts], NewOpts) ->
|
||||||
?SET_STRING_XOPT(title, Value);
|
?SET_STRING_XOPT(title, Value);
|
||||||
set_xoption(Host, [{"pubsub#type", Value} | Opts], NewOpts) ->
|
set_xoption(Host, [{"pubsub#type", Value} | Opts], NewOpts) ->
|
||||||
@ -3866,3 +3872,68 @@ is_feature_supported({xmlelement, "presence", _, Els}, Feature) ->
|
|||||||
nothing -> false;
|
nothing -> false;
|
||||||
Caps -> lists:member(Feature ++ "+notify", mod_caps:get_features(Caps))
|
Caps -> lists:member(Feature ++ "+notify", mod_caps:get_features(Caps))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
on_user_offline(_, JID, _) ->
|
||||||
|
{User, Server, Resource} = jlib:short_prepd_jid(JID),
|
||||||
|
case ejabberd_sm:get_user_resources(User, Server) of
|
||||||
|
[] -> purge_offline({User, Server, Resource});
|
||||||
|
_ -> true
|
||||||
|
end.
|
||||||
|
|
||||||
|
purge_offline({User, Server, _} = LJID) ->
|
||||||
|
Host = host(Server),
|
||||||
|
Plugins = plugins(Host),
|
||||||
|
Result = lists:foldl(
|
||||||
|
fun(Type, {Status, Acc}) ->
|
||||||
|
case lists:member("retrieve-affiliations", features(Type)) of
|
||||||
|
false ->
|
||||||
|
{{error, extended_error('feature-not-implemented', unsupported, "retrieve-affiliations")}, Acc};
|
||||||
|
true ->
|
||||||
|
{result, Affiliations} = node_action(Host, Type, get_entity_affiliations, [Host, LJID]),
|
||||||
|
{Status, [Affiliations|Acc]}
|
||||||
|
end
|
||||||
|
end, {ok, []}, Plugins),
|
||||||
|
case Result of
|
||||||
|
{ok, Affiliations} ->
|
||||||
|
lists:foreach(
|
||||||
|
fun({#pubsub_node{nodeid = {_, NodeId}, options = Options, type = Type}, Affiliation})
|
||||||
|
when Affiliation == 'owner' orelse Affiliation == 'publisher' ->
|
||||||
|
Action = fun(#pubsub_node{type = NType, id = NodeIdx}) ->
|
||||||
|
node_call(NType, get_items, [NodeIdx, service_jid(Host)])
|
||||||
|
end,
|
||||||
|
case transaction(Host, NodeId, Action, sync_dirty) of
|
||||||
|
{result, {_, []}} ->
|
||||||
|
true;
|
||||||
|
{result, {_, Items}} ->
|
||||||
|
Features = features(Type),
|
||||||
|
case
|
||||||
|
{lists:member("retract-items", Features),
|
||||||
|
lists:member("persistent-items", Features),
|
||||||
|
get_option(Options, persist_items),
|
||||||
|
get_option(Options, purge_offline)}
|
||||||
|
of
|
||||||
|
{true, true, true, true} ->
|
||||||
|
ForceNotify = get_option(Options, notify_retract),
|
||||||
|
lists:foreach(
|
||||||
|
fun(#pubsub_item{itemid = {ItemId, _}, modification = {_, Modification}}) ->
|
||||||
|
case Modification of
|
||||||
|
{User, Server, _} ->
|
||||||
|
delete_item(Host, NodeId, LJID, ItemId, ForceNotify);
|
||||||
|
_ ->
|
||||||
|
true
|
||||||
|
end;
|
||||||
|
(_) ->
|
||||||
|
true
|
||||||
|
end, Items);
|
||||||
|
_ ->
|
||||||
|
true
|
||||||
|
end;
|
||||||
|
Error ->
|
||||||
|
Error
|
||||||
|
end;
|
||||||
|
(_) ->
|
||||||
|
true
|
||||||
|
end, lists:usort(lists:flatten(Affiliations)));
|
||||||
|
{Error, _} ->
|
||||||
|
?DEBUG("on_user_offline ~p", [Error])
|
||||||
|
end.
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
-export([presence_probe/3,
|
-export([presence_probe/3,
|
||||||
in_subscription/6,
|
in_subscription/6,
|
||||||
out_subscription/4,
|
out_subscription/4,
|
||||||
|
on_user_offline/3,
|
||||||
remove_user/2,
|
remove_user/2,
|
||||||
feature_check_packet/6,
|
feature_check_packet/6,
|
||||||
disco_local_identity/5,
|
disco_local_identity/5,
|
||||||
@ -200,6 +201,7 @@ init([ServerHost, Opts]) ->
|
|||||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
|
||||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {ignore_pep_from_offline, PepOffline}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {ignore_pep_from_offline, PepOffline}),
|
||||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
||||||
|
ejabberd_hooks:add(sm_remove_connection_hook, ServerHostB, ?MODULE, on_user_offline, 75),
|
||||||
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
||||||
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
||||||
ejabberd_hooks:add(disco_sm_items, ServerHostB, ?MODULE, disco_sm_items, 75),
|
ejabberd_hooks:add(disco_sm_items, ServerHostB, ?MODULE, disco_sm_items, 75),
|
||||||
@ -681,6 +683,7 @@ terminate(_Reason, #state{host = Host,
|
|||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
ejabberd_hooks:delete(sm_remove_connection_hook, ServerHostB, ?MODULE, on_user_offline, 75),
|
||||||
ejabberd_hooks:delete(disco_local_identity, ServerHostB, ?MODULE, disco_local_identity, 75),
|
ejabberd_hooks:delete(disco_local_identity, ServerHostB, ?MODULE, disco_local_identity, 75),
|
||||||
ejabberd_hooks:delete(disco_local_features, ServerHostB, ?MODULE, disco_local_features, 75),
|
ejabberd_hooks:delete(disco_local_features, ServerHostB, ?MODULE, disco_local_features, 75),
|
||||||
ejabberd_hooks:delete(disco_local_items, ServerHostB, ?MODULE, disco_local_items, 75),
|
ejabberd_hooks:delete(disco_local_items, ServerHostB, ?MODULE, disco_local_items, 75),
|
||||||
@ -3225,6 +3228,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) ->
|
|||||||
?LISTM_CONFIG_FIELD("Roster groups allowed to subscribe", roster_groups_allowed, Groups),
|
?LISTM_CONFIG_FIELD("Roster groups allowed to subscribe", roster_groups_allowed, Groups),
|
||||||
?ALIST_CONFIG_FIELD("Specify the publisher model", publish_model,
|
?ALIST_CONFIG_FIELD("Specify the publisher model", publish_model,
|
||||||
[publishers, subscribers, open]),
|
[publishers, subscribers, open]),
|
||||||
|
?BOOL_CONFIG_FIELD("Purge all items when the relevant publisher goes offline", purge_offline),
|
||||||
?ALIST_CONFIG_FIELD("Specify the event message type", notification_type,
|
?ALIST_CONFIG_FIELD("Specify the event message type", notification_type,
|
||||||
[headline, normal]),
|
[headline, normal]),
|
||||||
?INTEGER_CONFIG_FIELD("Max payload size in bytes", max_payload_size),
|
?INTEGER_CONFIG_FIELD("Max payload size in bytes", max_payload_size),
|
||||||
@ -3368,6 +3372,8 @@ set_xoption(Host, [{"pubsub#send_last_published_item", [Val]} | Opts], NewOpts)
|
|||||||
?SET_ALIST_XOPT(send_last_published_item, Val, [never, on_sub, on_sub_and_presence]);
|
?SET_ALIST_XOPT(send_last_published_item, Val, [never, on_sub, on_sub_and_presence]);
|
||||||
set_xoption(Host, [{"pubsub#presence_based_delivery", [Val]} | Opts], NewOpts) ->
|
set_xoption(Host, [{"pubsub#presence_based_delivery", [Val]} | Opts], NewOpts) ->
|
||||||
?SET_BOOL_XOPT(presence_based_delivery, Val);
|
?SET_BOOL_XOPT(presence_based_delivery, Val);
|
||||||
|
set_xoption(Host, [{"pubsub#purge_offline", [Val]} | Opts], NewOpts) ->
|
||||||
|
?SET_BOOL_XOPT(purge_offline, Val);
|
||||||
set_xoption(Host, [{"pubsub#title", Value} | Opts], NewOpts) ->
|
set_xoption(Host, [{"pubsub#title", Value} | Opts], NewOpts) ->
|
||||||
?SET_STRING_XOPT(title, Value);
|
?SET_STRING_XOPT(title, Value);
|
||||||
set_xoption(Host, [{"pubsub#type", Value} | Opts], NewOpts) ->
|
set_xoption(Host, [{"pubsub#type", Value} | Opts], NewOpts) ->
|
||||||
@ -3733,3 +3739,68 @@ is_feature_supported({xmlelement, "presence", _, Els}, Feature) ->
|
|||||||
nothing -> false;
|
nothing -> false;
|
||||||
Caps -> lists:member(Feature ++ "+notify", mod_caps:get_features(Caps))
|
Caps -> lists:member(Feature ++ "+notify", mod_caps:get_features(Caps))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
on_user_offline(_, JID, _) ->
|
||||||
|
{User, Server, Resource} = jlib:short_prepd_jid(JID),
|
||||||
|
case ejabberd_sm:get_user_resources(User, Server) of
|
||||||
|
[] -> purge_offline({User, Server, Resource});
|
||||||
|
_ -> true
|
||||||
|
end.
|
||||||
|
|
||||||
|
purge_offline({User, Server, _} = LJID) ->
|
||||||
|
Host = host(Server),
|
||||||
|
Plugins = plugins(Host),
|
||||||
|
Result = lists:foldl(
|
||||||
|
fun(Type, {Status, Acc}) ->
|
||||||
|
case lists:member("retrieve-affiliations", features(Type)) of
|
||||||
|
false ->
|
||||||
|
{{error, extended_error('feature-not-implemented', unsupported, "retrieve-affiliations")}, Acc};
|
||||||
|
true ->
|
||||||
|
{result, Affiliations} = node_action(Host, Type, get_entity_affiliations, [Host, LJID]),
|
||||||
|
{Status, [Affiliations|Acc]}
|
||||||
|
end
|
||||||
|
end, {ok, []}, Plugins),
|
||||||
|
case Result of
|
||||||
|
{ok, Affiliations} ->
|
||||||
|
lists:foreach(
|
||||||
|
fun({#pubsub_node{nodeid = {_, NodeId}, options = Options, type = Type}, Affiliation})
|
||||||
|
when Affiliation == 'owner' orelse Affiliation == 'publisher' ->
|
||||||
|
Action = fun(#pubsub_node{type = NType, id = NodeIdx}) ->
|
||||||
|
node_call(NType, get_items, [NodeIdx, service_jid(Host)])
|
||||||
|
end,
|
||||||
|
case transaction(Host, NodeId, Action, sync_dirty) of
|
||||||
|
{result, {_, []}} ->
|
||||||
|
true;
|
||||||
|
{result, {_, Items}} ->
|
||||||
|
Features = features(Type),
|
||||||
|
case
|
||||||
|
{lists:member("retract-items", Features),
|
||||||
|
lists:member("persistent-items", Features),
|
||||||
|
get_option(Options, persist_items),
|
||||||
|
get_option(Options, purge_offline)}
|
||||||
|
of
|
||||||
|
{true, true, true, true} ->
|
||||||
|
ForceNotify = get_option(Options, notify_retract),
|
||||||
|
lists:foreach(
|
||||||
|
fun(#pubsub_item{itemid = {ItemId, _}, modification = {_, Modification}}) ->
|
||||||
|
case Modification of
|
||||||
|
{User, Server, _} ->
|
||||||
|
delete_item(Host, NodeId, LJID, ItemId, ForceNotify);
|
||||||
|
_ ->
|
||||||
|
true
|
||||||
|
end;
|
||||||
|
(_) ->
|
||||||
|
true
|
||||||
|
end, Items);
|
||||||
|
_ ->
|
||||||
|
true
|
||||||
|
end;
|
||||||
|
Error ->
|
||||||
|
Error
|
||||||
|
end;
|
||||||
|
(_) ->
|
||||||
|
true
|
||||||
|
end, lists:usort(lists:flatten(Affiliations)));
|
||||||
|
{Error, _} ->
|
||||||
|
?DEBUG("on_user_offline ~p", [Error])
|
||||||
|
end.
|
||||||
|
@ -80,6 +80,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -86,6 +86,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -85,6 +85,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -83,6 +83,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -76,6 +76,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -77,6 +77,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -139,6 +139,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
@ -350,9 +351,9 @@ subscribe_node(NodeId, Sender, {U,S,R} = Subscriber, AccessModel,
|
|||||||
%% SubId = mod_pubsub:subid()
|
%% SubId = mod_pubsub:subid()
|
||||||
%% Reason = mod_pubsub:stanzaError()
|
%% Reason = mod_pubsub:stanzaError()
|
||||||
%% @doc <p>Unsubscribe the <tt>Subscriber</tt> from the <tt>Node</tt>.</p>
|
%% @doc <p>Unsubscribe the <tt>Subscriber</tt> from the <tt>Node</tt>.</p>
|
||||||
unsubscribe_node(NodeId, Sender, {User, Server, Resource} = Subscriber, SubId) ->
|
unsubscribe_node(NodeId, Sender, {U, S, R} = Subscriber, SubId) ->
|
||||||
SubKey = {User, Server, Resource},
|
SubKey = {U, S, R},
|
||||||
GenKey = {User, Server, undefined},
|
GenKey = {U, S, undefined},
|
||||||
Authorized = (jlib:short_prepd_bare_jid(Sender) == GenKey),
|
Authorized = (jlib:short_prepd_bare_jid(Sender) == GenKey),
|
||||||
GenState = get_state(NodeId, GenKey),
|
GenState = get_state(NodeId, GenKey),
|
||||||
SubState = case SubKey of
|
SubState = case SubKey of
|
||||||
@ -382,15 +383,12 @@ unsubscribe_node(NodeId, Sender, {User, Server, Resource} = Subscriber, SubId) -
|
|||||||
{error, ?ERR_EXTENDED('unexpected-request', "not-subscribed")};
|
{error, ?ERR_EXTENDED('unexpected-request', "not-subscribed")};
|
||||||
%% Subid supplied, so use that.
|
%% Subid supplied, so use that.
|
||||||
SubIdExists ->
|
SubIdExists ->
|
||||||
Sub = first_in_list(fun(S) ->
|
Sub = first_in_list(fun({_, Id}) when Id == SubId -> true;
|
||||||
case S of
|
(_) -> false
|
||||||
{_Sub, SubId} -> true;
|
end, Subscriptions),
|
||||||
_ -> false
|
|
||||||
end
|
|
||||||
end, SubState#pubsub_state.subscriptions),
|
|
||||||
case Sub of
|
case Sub of
|
||||||
{value, S} ->
|
{value, S} ->
|
||||||
delete_subscriptions(SubKey, NodeId, [S], SubState),
|
delete_subscriptions(Subscriber, NodeId, [S], SubState),
|
||||||
{result, default};
|
{result, default};
|
||||||
false ->
|
false ->
|
||||||
{error, ?ERR_EXTENDED('unexpected-request', "not-subscribed")}
|
{error, ?ERR_EXTENDED('unexpected-request', "not-subscribed")}
|
||||||
|
@ -141,6 +141,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -89,6 +89,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, false},
|
{notify_retract, false},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -84,6 +84,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, false},
|
{notify_retract, false},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, false},
|
{persist_items, false},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -91,6 +91,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, false},
|
{notify_retract, false},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, false},
|
{persist_items, false},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -86,6 +86,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -87,6 +87,7 @@ options() ->
|
|||||||
{notify_config, false},
|
{notify_config, false},
|
||||||
{notify_delete, false},
|
{notify_delete, false},
|
||||||
{notify_retract, true},
|
{notify_retract, true},
|
||||||
|
{purge_offline, false},
|
||||||
{persist_items, true},
|
{persist_items, true},
|
||||||
{max_items, ?MAXITEMS},
|
{max_items, ?MAXITEMS},
|
||||||
{subscribe, true},
|
{subscribe, true},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--- mod_pubsub.erl 2010-03-05 15:44:11.000000000 +0100
|
--- mod_pubsub.erl 2010-03-05 16:08:38.000000000 +0100
|
||||||
+++ mod_pubsub_odbc.erl 2010-03-05 15:45:00.000000000 +0100
|
+++ mod_pubsub_odbc.erl 2010-03-05 16:08:56.000000000 +0100
|
||||||
@@ -42,7 +42,7 @@
|
@@ -42,7 +42,7 @@
|
||||||
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
|
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
|
||||||
%%% XEP-0060 section 12.18.
|
%%% XEP-0060 section 12.18.
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
%% exports for hooks
|
%% exports for hooks
|
||||||
-export([presence_probe/3,
|
-export([presence_probe/3,
|
||||||
@@ -104,7 +104,7 @@
|
@@ -105,7 +105,7 @@
|
||||||
string_to_affiliation/1,
|
string_to_affiliation/1,
|
||||||
extended_error/2,
|
extended_error/2,
|
||||||
extended_error/3,
|
extended_error/3,
|
||||||
@ -31,7 +31,7 @@
|
|||||||
]).
|
]).
|
||||||
|
|
||||||
%% API and gen_server callbacks
|
%% API and gen_server callbacks
|
||||||
@@ -123,7 +123,7 @@
|
@@ -124,7 +124,7 @@
|
||||||
-export([send_loop/1
|
-export([send_loop/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
@ -40,7 +40,7 @@
|
|||||||
-define(LOOPNAME, ejabberd_mod_pubsub_loop).
|
-define(LOOPNAME, ejabberd_mod_pubsub_loop).
|
||||||
-define(PLUGIN_PREFIX, "node_").
|
-define(PLUGIN_PREFIX, "node_").
|
||||||
-define(TREE_PREFIX, "nodetree_").
|
-define(TREE_PREFIX, "nodetree_").
|
||||||
@@ -223,8 +223,6 @@
|
@@ -225,8 +225,6 @@
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ejabberd_router:register_route(Host),
|
ejabberd_router:register_route(Host),
|
||||||
@ -49,7 +49,7 @@
|
|||||||
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
||||||
State = #state{host = Host,
|
State = #state{host = Host,
|
||||||
server_host = ServerHost,
|
server_host = ServerHost,
|
||||||
@@ -283,206 +281,15 @@
|
@@ -285,206 +283,15 @@
|
||||||
|
|
||||||
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
||||||
%% TODO, this call should be done plugin side
|
%% TODO, this call should be done plugin side
|
||||||
@ -260,7 +260,7 @@
|
|||||||
|
|
||||||
send_loop(State) ->
|
send_loop(State) ->
|
||||||
receive
|
receive
|
||||||
@@ -494,17 +301,15 @@
|
@@ -496,17 +303,15 @@
|
||||||
%% for each node From is subscribed to
|
%% for each node From is subscribed to
|
||||||
%% and if the node is so configured, send the last published item to From
|
%% and if the node is so configured, send the last published item to From
|
||||||
lists:foreach(fun(PType) ->
|
lists:foreach(fun(PType) ->
|
||||||
@ -284,7 +284,7 @@
|
|||||||
true ->
|
true ->
|
||||||
% resource not concerned about that subscription
|
% resource not concerned about that subscription
|
||||||
ok
|
ok
|
||||||
@@ -656,8 +461,7 @@
|
@@ -658,8 +463,7 @@
|
||||||
end;
|
end;
|
||||||
|
|
||||||
disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
||||||
@ -294,7 +294,7 @@
|
|||||||
%% TODO, use iq_disco_items(Host, Node, From)
|
%% TODO, use iq_disco_items(Host, Node, From)
|
||||||
Host = exmpp_jid:prep_domain_as_list(To),
|
Host = exmpp_jid:prep_domain_as_list(To),
|
||||||
LJID = jlib:short_prepd_bare_jid(To),
|
LJID = jlib:short_prepd_bare_jid(To),
|
||||||
@@ -691,6 +495,7 @@
|
@@ -693,6 +497,7 @@
|
||||||
%% -------
|
%% -------
|
||||||
%% presence hooks handling functions
|
%% presence hooks handling functions
|
||||||
%%
|
%%
|
||||||
@ -302,7 +302,7 @@
|
|||||||
presence_probe(Peer, JID, Pid) ->
|
presence_probe(Peer, JID, Pid) ->
|
||||||
case exmpp_jid:full_compare(Peer, JID) of
|
case exmpp_jid:full_compare(Peer, JID) of
|
||||||
true -> %% JID are equals
|
true -> %% JID are equals
|
||||||
@@ -757,10 +562,10 @@
|
@@ -759,10 +564,10 @@
|
||||||
lists:foreach(fun(PType) ->
|
lists:foreach(fun(PType) ->
|
||||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
|
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
|
||||||
lists:foreach(fun
|
lists:foreach(fun
|
||||||
@ -315,7 +315,7 @@
|
|||||||
true ->
|
true ->
|
||||||
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
||||||
false ->
|
false ->
|
||||||
@@ -932,10 +737,11 @@
|
@@ -935,10 +740,11 @@
|
||||||
end,
|
end,
|
||||||
ejabberd_router:route(To, From, Res);
|
ejabberd_router:route(To, From, Res);
|
||||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||||
@ -329,7 +329,7 @@
|
|||||||
{result, IQRes} ->
|
{result, IQRes} ->
|
||||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
||||||
name = 'query', attrs = QAttrs,
|
name = 'query', attrs = QAttrs,
|
||||||
@@ -1055,7 +861,7 @@
|
@@ -1058,7 +864,7 @@
|
||||||
[] ->
|
[] ->
|
||||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||||
_ ->
|
_ ->
|
||||||
@ -338,7 +338,7 @@
|
|||||||
{result, []} -> ["collection"];
|
{result, []} -> ["collection"];
|
||||||
{result, _} -> ["leaf", "collection"];
|
{result, _} -> ["leaf", "collection"];
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -1071,8 +877,9 @@
|
@@ -1074,8 +880,9 @@
|
||||||
[];
|
[];
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||||
@ -350,7 +350,7 @@
|
|||||||
end, features(Type))]
|
end, features(Type))]
|
||||||
end,
|
end,
|
||||||
%% TODO: add meta-data info (spec section 5.4)
|
%% TODO: add meta-data info (spec section 5.4)
|
||||||
@@ -1101,8 +908,9 @@
|
@@ -1104,8 +911,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_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_ADHOC_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||||
@ -362,7 +362,7 @@
|
|||||||
end, features(Host, Node))};
|
end, features(Host, Node))};
|
||||||
?NS_ADHOC_b ->
|
?NS_ADHOC_b ->
|
||||||
command_disco_info(Host, Node, From);
|
command_disco_info(Host, Node, From);
|
||||||
@@ -1112,7 +920,7 @@
|
@@ -1115,7 +923,7 @@
|
||||||
node_disco_info(Host, Node, From)
|
node_disco_info(Host, Node, From)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -371,7 +371,7 @@
|
|||||||
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
||||||
Nodes when is_list(Nodes) ->
|
Nodes when is_list(Nodes) ->
|
||||||
{result, lists:map(
|
{result, lists:map(
|
||||||
@@ -1129,7 +937,7 @@
|
@@ -1132,7 +940,7 @@
|
||||||
Other ->
|
Other ->
|
||||||
Other
|
Other
|
||||||
end;
|
end;
|
||||||
@ -380,7 +380,7 @@
|
|||||||
%% TODO: support localization of this string
|
%% TODO: support localization of this string
|
||||||
CommandItems = [
|
CommandItems = [
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
||||||
@@ -1138,10 +946,10 @@
|
@@ -1141,10 +949,10 @@
|
||||||
?XMLATTR('name', "Get Pending")
|
?XMLATTR('name', "Get Pending")
|
||||||
]}],
|
]}],
|
||||||
{result, CommandItems};
|
{result, CommandItems};
|
||||||
@ -393,7 +393,7 @@
|
|||||||
case string:tokens(Item, "!") of
|
case string:tokens(Item, "!") of
|
||||||
[_SNode, _ItemID] ->
|
[_SNode, _ItemID] ->
|
||||||
{result, []};
|
{result, []};
|
||||||
@@ -1149,10 +957,10 @@
|
@@ -1152,10 +960,10 @@
|
||||||
Node = string_to_node(SNode),
|
Node = string_to_node(SNode),
|
||||||
Action =
|
Action =
|
||||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||||
@ -407,7 +407,7 @@
|
|||||||
end,
|
end,
|
||||||
Nodes = lists:map(
|
Nodes = lists:map(
|
||||||
fun(#pubsub_node{nodeid = {_, SubNode}, options = Options}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}, options = Options}) ->
|
||||||
@@ -1168,9 +976,10 @@
|
@@ -1171,9 +979,10 @@
|
||||||
Items = lists:map(
|
Items = lists:map(
|
||||||
fun(#pubsub_item{itemid = {RN, _}}) ->
|
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||||
@ -420,7 +420,7 @@
|
|||||||
end,
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {_, Result}} -> {result, Result};
|
{result, {_, Result}} -> {result, Result};
|
||||||
@@ -1301,7 +1110,8 @@
|
@@ -1304,7 +1113,8 @@
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
Acc
|
Acc
|
||||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||||
@ -430,7 +430,7 @@
|
|||||||
{get, 'subscriptions'} ->
|
{get, 'subscriptions'} ->
|
||||||
get_subscriptions(Host, Node, From, Plugins);
|
get_subscriptions(Host, Node, From, Plugins);
|
||||||
{get, 'affiliations'} ->
|
{get, 'affiliations'} ->
|
||||||
@@ -1323,8 +1133,9 @@
|
@@ -1326,8 +1136,9 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||||
@ -442,7 +442,7 @@
|
|||||||
case Action of
|
case Action of
|
||||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||||
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
||||||
@@ -1458,7 +1269,8 @@
|
@@ -1461,7 +1272,8 @@
|
||||||
_ -> []
|
_ -> []
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -452,7 +452,7 @@
|
|||||||
sync_dirty) of
|
sync_dirty) of
|
||||||
{result, Res} -> Res;
|
{result, Res} -> Res;
|
||||||
Err -> Err
|
Err -> Err
|
||||||
@@ -1502,7 +1314,7 @@
|
@@ -1505,7 +1317,7 @@
|
||||||
|
|
||||||
%%% authorization handling
|
%%% authorization handling
|
||||||
|
|
||||||
@ -461,7 +461,7 @@
|
|||||||
Lang = "en", %% TODO fix
|
Lang = "en", %% TODO fix
|
||||||
{U, S, R} = Subscriber,
|
{U, S, R} = Subscriber,
|
||||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||||
@@ -1532,7 +1344,7 @@
|
@@ -1535,7 +1347,7 @@
|
||||||
lists:foreach(fun(Owner) ->
|
lists:foreach(fun(Owner) ->
|
||||||
{U, S, R} = Owner,
|
{U, S, R} = Owner,
|
||||||
ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza)
|
ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza)
|
||||||
@ -470,7 +470,7 @@
|
|||||||
|
|
||||||
find_authorization_response(Packet) ->
|
find_authorization_response(Packet) ->
|
||||||
Els = Packet#xmlel.children,
|
Els = Packet#xmlel.children,
|
||||||
@@ -1574,7 +1386,7 @@
|
@@ -1577,7 +1389,7 @@
|
||||||
end,
|
end,
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
||||||
@ -479,7 +479,7 @@
|
|||||||
}]),
|
}]),
|
||||||
ejabberd_router:route(service_jid(Host), JID, Stanza).
|
ejabberd_router:route(service_jid(Host), JID, Stanza).
|
||||||
|
|
||||||
@@ -1585,14 +1397,14 @@
|
@@ -1588,14 +1400,14 @@
|
||||||
{{value, {_, [SNode]}}, {value, {_, [SSubscriber]}},
|
{{value, {_, [SNode]}}, {value, {_, [SSubscriber]}},
|
||||||
{value, {_, [SAllow]}}} ->
|
{value, {_, [SAllow]}}} ->
|
||||||
Node = string_to_node(SNode),
|
Node = string_to_node(SNode),
|
||||||
@ -497,7 +497,7 @@
|
|||||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||||
if
|
if
|
||||||
not IsApprover ->
|
not IsApprover ->
|
||||||
@@ -1787,7 +1599,7 @@
|
@@ -1790,7 +1602,7 @@
|
||||||
end,
|
end,
|
||||||
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
||||||
@ -506,7 +506,7 @@
|
|||||||
{result, {Result, broadcast}} ->
|
{result, {Result, broadcast}} ->
|
||||||
%%Lang = "en", %% TODO: fix
|
%%Lang = "en", %% TODO: fix
|
||||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||||
@@ -1896,7 +1708,7 @@
|
@@ -1899,7 +1711,7 @@
|
||||||
%%<li>The node does not exist.</li>
|
%%<li>The node does not exist.</li>
|
||||||
%%</ul>
|
%%</ul>
|
||||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||||
@ -515,7 +515,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -1906,7 +1718,7 @@
|
@@ -1909,7 +1721,7 @@
|
||||||
_:_ ->
|
_:_ ->
|
||||||
{undefined, undefined, undefined}
|
{undefined, undefined, undefined}
|
||||||
end,
|
end,
|
||||||
@ -524,7 +524,7 @@
|
|||||||
Features = features(Type),
|
Features = features(Type),
|
||||||
SubscribeFeature = lists:member("subscribe", Features),
|
SubscribeFeature = lists:member("subscribe", Features),
|
||||||
OptionsFeature = lists:member("subscription-options", Features),
|
OptionsFeature = lists:member("subscription-options", Features),
|
||||||
@@ -1925,9 +1737,13 @@
|
@@ -1928,9 +1740,13 @@
|
||||||
{"", "", ""} ->
|
{"", "", ""} ->
|
||||||
{false, false};
|
{false, false};
|
||||||
_ ->
|
_ ->
|
||||||
@ -541,7 +541,7 @@
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
@@ -2260,7 +2076,7 @@
|
@@ -2263,7 +2079,7 @@
|
||||||
%% <p>The permission are not checked in this function.</p>
|
%% <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
|
%% @todo We probably need to check that the user doing the query has the right
|
||||||
%% to read the items.
|
%% to read the items.
|
||||||
@ -550,7 +550,7 @@
|
|||||||
MaxItems =
|
MaxItems =
|
||||||
if
|
if
|
||||||
SMaxItems == "" -> get_max_items_node(Host);
|
SMaxItems == "" -> get_max_items_node(Host);
|
||||||
@@ -2299,11 +2115,11 @@
|
@@ -2302,11 +2118,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From,
|
[NodeId, From,
|
||||||
AccessModel, PresenceSubscription, RosterGroup,
|
AccessModel, PresenceSubscription, RosterGroup,
|
||||||
@ -564,7 +564,7 @@
|
|||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] ->
|
[] ->
|
||||||
Items;
|
Items;
|
||||||
@@ -2316,7 +2132,7 @@
|
@@ -2319,7 +2135,7 @@
|
||||||
%% number of items sent to MaxItems:
|
%% number of items sent to MaxItems:
|
||||||
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
||||||
@ -573,7 +573,7 @@
|
|||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
@@ -2348,17 +2164,29 @@
|
@@ -2351,17 +2167,29 @@
|
||||||
%% @doc <p>Resend the items of a node to the user.</p>
|
%% @doc <p>Resend the items of a node to the user.</p>
|
||||||
%% @todo use cache-last-item feature
|
%% @todo use cache-last-item feature
|
||||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||||
@ -610,7 +610,7 @@
|
|||||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
||||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||||
{result, []} ->
|
{result, []} ->
|
||||||
@@ -2488,29 +2316,12 @@
|
@@ -2491,29 +2319,12 @@
|
||||||
error ->
|
error ->
|
||||||
{error, 'bad-request'};
|
{error, 'bad-request'};
|
||||||
_ ->
|
_ ->
|
||||||
@ -643,7 +643,7 @@
|
|||||||
end, Entities),
|
end, Entities),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2565,11 +2376,11 @@
|
@@ -2568,11 +2379,11 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||||
@ -657,7 +657,7 @@
|
|||||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||||
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
||||||
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
||||||
@@ -2596,7 +2407,7 @@
|
@@ -2599,7 +2410,7 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||||
@ -666,7 +666,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -2626,7 +2437,7 @@
|
@@ -2629,7 +2440,7 @@
|
||||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||||
{error, extended_error('bad-request', "invalid-options")};
|
{error, extended_error('bad-request', "invalid-options")};
|
||||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||||
@ -675,7 +675,7 @@
|
|||||||
{error, notfound} ->
|
{error, notfound} ->
|
||||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
@@ -2799,8 +2610,8 @@
|
@@ -2802,8 +2613,8 @@
|
||||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||||
ejabberd_router:route(service_jid(Host), JID, Stanza)
|
ejabberd_router:route(service_jid(Host), JID, Stanza)
|
||||||
end,
|
end,
|
||||||
@ -686,7 +686,7 @@
|
|||||||
true ->
|
true ->
|
||||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
|
|
||||||
@@ -3089,7 +2900,7 @@
|
@@ -3092,7 +2903,7 @@
|
||||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||||
end,
|
end,
|
||||||
@ -695,7 +695,7 @@
|
|||||||
{result, CollSubs} -> CollSubs;
|
{result, CollSubs} -> CollSubs;
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
@@ -3103,9 +2914,9 @@
|
@@ -3106,9 +2917,9 @@
|
||||||
|
|
||||||
get_options_for_subs(NodeID, Subs) ->
|
get_options_for_subs(NodeID, Subs) ->
|
||||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||||
@ -707,7 +707,7 @@
|
|||||||
_ -> Acc
|
_ -> Acc
|
||||||
end;
|
end;
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@@ -3113,7 +2924,7 @@
|
@@ -3116,7 +2927,7 @@
|
||||||
end, [], Subs).
|
end, [], Subs).
|
||||||
|
|
||||||
% TODO: merge broadcast code that way
|
% TODO: merge broadcast code that way
|
||||||
@ -716,7 +716,7 @@
|
|||||||
%broadcast(Host, Node, NodeId, Type, NodeOptions, Feature, Force, ElName, SubEls) ->
|
%broadcast(Host, Node, NodeId, Type, NodeOptions, Feature, Force, ElName, SubEls) ->
|
||||||
% case (get_option(NodeOptions, Feature) or Force) of
|
% case (get_option(NodeOptions, Feature) or Force) of
|
||||||
% true ->
|
% true ->
|
||||||
@@ -3312,6 +3123,30 @@
|
@@ -3315,6 +3126,30 @@
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -747,7 +747,7 @@
|
|||||||
%% @spec (Host, Options) -> MaxItems
|
%% @spec (Host, Options) -> MaxItems
|
||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Options = [Option]
|
%% Options = [Option]
|
||||||
@@ -3707,7 +3542,13 @@
|
@@ -3713,7 +3548,13 @@
|
||||||
tree_action(Host, Function, Args) ->
|
tree_action(Host, Function, Args) ->
|
||||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||||
@ -762,7 +762,7 @@
|
|||||||
|
|
||||||
%% @doc <p>node plugin call.</p>
|
%% @doc <p>node plugin call.</p>
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
@@ -3727,13 +3568,13 @@
|
@@ -3733,13 +3574,13 @@
|
||||||
|
|
||||||
node_action(Host, Type, Function, Args) ->
|
node_action(Host, Type, Function, Args) ->
|
||||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||||
@ -778,7 +778,7 @@
|
|||||||
case tree_call(Host, get_node, [Host, Node]) of
|
case tree_call(Host, get_node, [Host, Node]) of
|
||||||
N when is_record(N, pubsub_node) ->
|
N when is_record(N, pubsub_node) ->
|
||||||
case Action(N) of
|
case Action(N) of
|
||||||
@@ -3746,8 +3587,15 @@
|
@@ -3752,8 +3593,15 @@
|
||||||
end
|
end
|
||||||
end, Trans).
|
end, Trans).
|
||||||
|
|
||||||
@ -796,7 +796,7 @@
|
|||||||
{result, Result} -> {result, Result};
|
{result, Result} -> {result, Result};
|
||||||
{error, Error} -> {error, Error};
|
{error, Error} -> {error, Error};
|
||||||
{atomic, {result, Result}} -> {result, Result};
|
{atomic, {result, Result}} -> {result, Result};
|
||||||
@@ -3755,6 +3603,15 @@
|
@@ -3761,6 +3609,15 @@
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||||
{error, 'internal-server-error'};
|
{error, 'internal-server-error'};
|
||||||
@ -812,7 +812,7 @@
|
|||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||||
{error, 'internal-server-error'};
|
{error, 'internal-server-error'};
|
||||||
@@ -3763,6 +3620,16 @@
|
@@ -3769,6 +3626,16 @@
|
||||||
{error, 'internal-server-error'}
|
{error, 'internal-server-error'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user