mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Remove usage of #jid record introduced in 2787.
Replace explicit references to #jid with exmpp_jid API calls. SVN Revision: 2794
This commit is contained in:
parent
929022bc0f
commit
573ff2564b
@ -727,22 +727,27 @@ disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
||||
%% -------
|
||||
%% presence hooks handling functions
|
||||
%%
|
||||
|
||||
presence_probe(JID, JID, Pid) ->
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(JID),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, JID, Pid}),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID});
|
||||
presence_probe(#jid{luser = User, lserver = Server}, #jid{luser = User, lserver = Server}, _Pid) ->
|
||||
%% ignore presence_probe from other ressources for the current user
|
||||
%% this way, we do not send duplicated last items if user already connected with other clients
|
||||
ok;
|
||||
presence_probe(Peer, JID, _Pid) ->
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(Peer),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID}).
|
||||
presence_probe(Peer, JID, Pid) ->
|
||||
case exmpp_jid:full_compare(Peer, JID) of
|
||||
true -> %% JID are equals
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(Peer),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, JID, Pid}),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID});
|
||||
false ->
|
||||
case exmpp_jid:bare_compare(Peer, JID) of
|
||||
true ->
|
||||
%% ignore presence_probe from other ressources for the current user
|
||||
%% this way, we do not send duplicated last items if user already connected with other clients
|
||||
ok;
|
||||
false ->
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(Peer),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID})
|
||||
end
|
||||
end.
|
||||
|
||||
%% -------
|
||||
%% subscription hooks handling functions
|
||||
|
@ -532,21 +532,27 @@ disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
||||
%% presence hooks handling functions
|
||||
%%
|
||||
|
||||
presence_probe(JID, JID, Pid) ->
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(JID),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, JID, Pid}),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID});
|
||||
presence_probe(#jid{luser = User, lserver = Server}, #jid{luser = User, lserver = Server}, _Pid) ->
|
||||
%% ignore presence_probe from other ressources for the current user
|
||||
%% this way, we do not send duplicated last items if user already connected with other clients
|
||||
ok;
|
||||
presence_probe(Peer, JID, _Pid) ->
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(Peer),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID}).
|
||||
presence_probe(Peer, JID, Pid) ->
|
||||
case exmpp_jid:full_compare(Peer, JID) of
|
||||
true -> %% JID are equals
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(Peer),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, JID, Pid}),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID});
|
||||
false ->
|
||||
case exmpp_jid:bare_compare(Peer, JID) of
|
||||
true ->
|
||||
%% ignore presence_probe from other ressources for the current user
|
||||
%% this way, we do not send duplicated last items if user already connected with other clients
|
||||
ok;
|
||||
false ->
|
||||
{User, Server, Resource} = jlib:short_prepd_jid(Peer),
|
||||
Host = exmpp_jid:prep_domain_as_list(JID),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
gen_server:cast(Proc, {presence, User, Server, [Resource], JID})
|
||||
end
|
||||
end.
|
||||
|
||||
%% -------
|
||||
%% subscription hooks handling functions
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2009-12-07 00:21:33.000000000 +0100
|
||||
+++ mod_pubsub_odbc.erl 2009-12-07 00:21:40.000000000 +0100
|
||||
--- mod_pubsub.erl 2009-12-08 15:52:01.000000000 -0300
|
||||
+++ mod_pubsub_odbc.erl 2009-12-08 15:53:12.000000000 -0300
|
||||
@@ -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.
|
||||
@ -294,7 +294,15 @@
|
||||
%% TODO, use iq_disco_items(Host, Node, From)
|
||||
Host = exmpp_jid:prep_domain_as_list(To),
|
||||
LJID = jlib:short_prepd_bare_jid(To),
|
||||
@@ -845,10 +649,10 @@
|
||||
@@ -727,6 +531,7 @@
|
||||
%% -------
|
||||
%% presence hooks handling functions
|
||||
%%
|
||||
+
|
||||
presence_probe(Peer, JID, Pid) ->
|
||||
case exmpp_jid:full_compare(Peer, JID) of
|
||||
true -> %% JID are equals
|
||||
@@ -850,10 +655,10 @@
|
||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
||||
lists:foreach(fun
|
||||
({Node, subscribed, _, JID}) ->
|
||||
@ -307,7 +315,7 @@
|
||||
true ->
|
||||
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
||||
false ->
|
||||
@@ -967,11 +771,12 @@
|
||||
@@ -972,11 +777,12 @@
|
||||
end,
|
||||
ejabberd_router:route(To, From, Res);
|
||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||
@ -322,7 +330,7 @@
|
||||
{result, IQRes} ->
|
||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
||||
name = 'query', attrs = QAttrs,
|
||||
@@ -1089,7 +894,7 @@
|
||||
@@ -1094,7 +900,7 @@
|
||||
[] ->
|
||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||
_ ->
|
||||
@ -331,7 +339,7 @@
|
||||
{result, []} -> ["collection"];
|
||||
{result, _} -> ["leaf", "collection"];
|
||||
_ -> []
|
||||
@@ -1105,8 +910,9 @@
|
||||
@@ -1110,8 +916,9 @@
|
||||
[];
|
||||
true ->
|
||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||
@ -343,7 +351,7 @@
|
||||
end, features(Type))]
|
||||
end,
|
||||
%% TODO: add meta-data info (spec section 5.4)
|
||||
@@ -1135,8 +941,9 @@
|
||||
@@ -1140,8 +947,9 @@
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]},
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||
@ -355,7 +363,7 @@
|
||||
end, features(Host, Node))};
|
||||
?NS_ADHOC_b ->
|
||||
command_disco_info(Host, Node, From);
|
||||
@@ -1146,7 +953,7 @@
|
||||
@@ -1151,7 +959,7 @@
|
||||
node_disco_info(Host, Node, From)
|
||||
end.
|
||||
|
||||
@ -364,7 +372,7 @@
|
||||
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
||||
Nodes when is_list(Nodes) ->
|
||||
{result, lists:map(
|
||||
@@ -1159,7 +966,7 @@
|
||||
@@ -1164,7 +972,7 @@
|
||||
Other ->
|
||||
Other
|
||||
end;
|
||||
@ -373,7 +381,7 @@
|
||||
%% TODO: support localization of this string
|
||||
CommandItems = [
|
||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
||||
@@ -1168,10 +975,10 @@
|
||||
@@ -1173,10 +981,10 @@
|
||||
?XMLATTR('name', "Get Pending")
|
||||
]}],
|
||||
{result, CommandItems};
|
||||
@ -386,7 +394,7 @@
|
||||
case string:tokens(Item, "!") of
|
||||
[_SNode, _ItemID] ->
|
||||
{result, []};
|
||||
@@ -1179,10 +986,10 @@
|
||||
@@ -1184,10 +992,10 @@
|
||||
Node = string_to_node(SNode),
|
||||
Action =
|
||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
@ -400,7 +408,7 @@
|
||||
end,
|
||||
Nodes = lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||
@@ -1193,9 +1000,10 @@
|
||||
@@ -1198,9 +1006,10 @@
|
||||
Items = lists:map(
|
||||
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||
@ -413,7 +421,7 @@
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, Result}} -> {result, Result};
|
||||
@@ -1326,7 +1134,8 @@
|
||||
@@ -1331,7 +1140,8 @@
|
||||
(_, Acc) ->
|
||||
Acc
|
||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||
@ -423,7 +431,7 @@
|
||||
{get, 'subscriptions'} ->
|
||||
get_subscriptions(Host, Node, From, Plugins);
|
||||
{get, 'affiliations'} ->
|
||||
@@ -1348,8 +1157,9 @@
|
||||
@@ -1353,8 +1163,9 @@
|
||||
end.
|
||||
|
||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||
@ -435,7 +443,7 @@
|
||||
case Action of
|
||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
||||
@@ -1483,7 +1293,8 @@
|
||||
@@ -1488,7 +1299,8 @@
|
||||
_ -> []
|
||||
end
|
||||
end,
|
||||
@ -445,7 +453,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1527,7 +1338,7 @@
|
||||
@@ -1532,7 +1344,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -454,7 +462,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
{U, S, R} = Subscriber,
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||
@@ -1557,7 +1368,7 @@
|
||||
@@ -1562,7 +1374,7 @@
|
||||
lists:foreach(fun(Owner) ->
|
||||
{U, S, R} = Owner,
|
||||
ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza)
|
||||
@ -463,7 +471,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
Els = Packet#xmlel.children,
|
||||
@@ -1599,7 +1410,7 @@
|
||||
@@ -1604,7 +1416,7 @@
|
||||
end,
|
||||
Stanza = event_stanza(
|
||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
||||
@ -472,7 +480,7 @@
|
||||
}]),
|
||||
ejabberd_router:route(service_jid(Host), JID, Stanza).
|
||||
|
||||
@@ -1610,14 +1421,14 @@
|
||||
@@ -1615,14 +1427,14 @@
|
||||
{{value, {_, [SNode]}}, {value, {_, [SSubscriber]}},
|
||||
{value, {_, [SAllow]}}} ->
|
||||
Node = string_to_node(SNode),
|
||||
@ -490,7 +498,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1812,7 +1623,7 @@
|
||||
@@ -1817,7 +1629,7 @@
|
||||
end,
|
||||
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
||||
@ -499,7 +507,7 @@
|
||||
{result, {Result, broadcast}} ->
|
||||
%%Lang = "en", %% TODO: fix
|
||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@@ -1921,7 +1732,7 @@
|
||||
@@ -1926,7 +1738,7 @@
|
||||
%%<li>The node does not exist.</li>
|
||||
%%</ul>
|
||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
@ -508,7 +516,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -1932,7 +1743,7 @@
|
||||
@@ -1937,7 +1749,7 @@
|
||||
{undefined, undefined, undefined}
|
||||
end,
|
||||
SubId = uniqid(),
|
||||
@ -517,7 +525,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1951,9 +1762,13 @@
|
||||
@@ -1956,9 +1768,13 @@
|
||||
{"", "", ""} ->
|
||||
{false, false};
|
||||
_ ->
|
||||
@ -534,7 +542,7 @@
|
||||
end
|
||||
end,
|
||||
if
|
||||
@@ -2286,7 +2101,7 @@
|
||||
@@ -2291,7 +2107,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.
|
||||
@ -543,7 +551,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2325,11 +2140,11 @@
|
||||
@@ -2330,11 +2146,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -557,7 +565,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2342,7 +2157,7 @@
|
||||
@@ -2347,7 +2163,7 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
||||
@ -566,7 +574,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2374,17 +2189,29 @@
|
||||
@@ -2379,17 +2195,29 @@
|
||||
%% @doc <p>Resend the items of a node to the user.</p>
|
||||
%% @todo use cache-last-item feature
|
||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||
@ -603,7 +611,7 @@
|
||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2513,29 +2340,12 @@
|
||||
@@ -2518,29 +2346,12 @@
|
||||
error ->
|
||||
{error, 'bad-request'};
|
||||
_ ->
|
||||
@ -636,7 +644,7 @@
|
||||
end, Entities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2590,11 +2400,11 @@
|
||||
@@ -2595,11 +2406,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -650,7 +658,7 @@
|
||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
||||
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
||||
@@ -2621,7 +2431,7 @@
|
||||
@@ -2626,7 +2437,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -659,7 +667,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2651,7 +2461,7 @@
|
||||
@@ -2656,7 +2467,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error('bad-request', "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -668,7 +676,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2824,8 +2634,8 @@
|
||||
@@ -2829,8 +2640,8 @@
|
||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||
ejabberd_router:route(service_jid(Host), JID, Stanza)
|
||||
end,
|
||||
@ -679,7 +687,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3114,7 +2924,7 @@
|
||||
@@ -3119,7 +2930,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -688,7 +696,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3128,9 +2938,9 @@
|
||||
@@ -3133,9 +2944,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -700,7 +708,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3138,7 +2948,7 @@
|
||||
@@ -3143,7 +2954,7 @@
|
||||
end, [], Subs).
|
||||
|
||||
% TODO: merge broadcast code that way
|
||||
@ -709,7 +717,7 @@
|
||||
%broadcast(Host, Node, NodeId, Type, NodeOptions, Feature, Force, ElName, SubEls) ->
|
||||
% case (get_option(NodeOptions, Feature) or Force) of
|
||||
% true ->
|
||||
@@ -3330,6 +3140,30 @@
|
||||
@@ -3335,6 +3146,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -740,7 +748,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3719,7 +3553,13 @@
|
||||
@@ -3724,7 +3559,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -755,7 +763,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3739,13 +3579,13 @@
|
||||
@@ -3744,13 +3585,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -771,7 +779,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3758,8 +3598,15 @@
|
||||
@@ -3763,8 +3604,15 @@
|
||||
end
|
||||
end, Trans).
|
||||
|
||||
@ -789,7 +797,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3767,6 +3614,15 @@
|
||||
@@ -3772,6 +3620,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@ -805,7 +813,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@@ -3775,6 +3631,16 @@
|
||||
@@ -3780,6 +3637,16 @@
|
||||
{error, 'internal-server-error'}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user