mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
*** empty log message ***
SVN Revision: 42
This commit is contained in:
parent
23e1914e94
commit
c060093e84
@ -186,8 +186,6 @@ session_established({xmlstreamelement, El}, StateData) ->
|
|||||||
presence_update(FromJID, El, StateData);
|
presence_update(FromJID, El, StateData);
|
||||||
_ ->
|
_ ->
|
||||||
presence_track(FromJID, ToJID, El, StateData)
|
presence_track(FromJID, ToJID, El, StateData)
|
||||||
%ejabberd_router:route(FrJID, ToJID, El),
|
|
||||||
%NewSt
|
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_router:route(FromJID, ToJID, El),
|
ejabberd_router:route(FromJID, ToJID, El),
|
||||||
@ -264,14 +262,8 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
process_presence_probe(From, To, StateData),
|
process_presence_probe(From, To, StateData),
|
||||||
{false, Attrs, StateData};
|
{false, Attrs, StateData};
|
||||||
"error" ->
|
"error" ->
|
||||||
case ?SETS:is_element(From, StateData#state.pres_a) of
|
NewA = remove_element(From, StateData#state.pres_a),
|
||||||
true ->
|
{true, Attrs, StateData#state{pres_a = NewA}};
|
||||||
A = ?SETS:del_element(From,
|
|
||||||
StateData#state.pres_a),
|
|
||||||
{true, Attrs, StateData#state{pres_a = A}};
|
|
||||||
_ ->
|
|
||||||
{true, Attrs, StateData}
|
|
||||||
end;
|
|
||||||
"invisible" ->
|
"invisible" ->
|
||||||
Attrs1 = lists:keydelete("type", 1, Attrs),
|
Attrs1 = lists:keydelete("type", 1, Attrs),
|
||||||
{true, [{"type", "unavailable"} | Attrs1], StateData};
|
{true, [{"type", "unavailable"} | Attrs1], StateData};
|
||||||
@ -467,12 +459,12 @@ presence_update(From, Packet, StateData) ->
|
|||||||
S1 = StateData#state{pres_last = undefined,
|
S1 = StateData#state{pres_last = undefined,
|
||||||
pres_a = ?SETS:new(),
|
pres_a = ?SETS:new(),
|
||||||
pres_i = ?SETS:new(),
|
pres_i = ?SETS:new(),
|
||||||
pres_invis = false},
|
pres_invis = true},
|
||||||
presence_broadcast_first(From, S1, Packet);
|
presence_broadcast_first(From, S1, Packet);
|
||||||
true ->
|
true ->
|
||||||
StateData
|
StateData
|
||||||
end,
|
end,
|
||||||
StateData;
|
NewState;
|
||||||
"error" ->
|
"error" ->
|
||||||
StateData;
|
StateData;
|
||||||
"subscribe" ->
|
"subscribe" ->
|
||||||
@ -495,18 +487,20 @@ presence_update(From, Packet, StateData) ->
|
|||||||
|
|
||||||
mod_offline:resend_offline_messages(
|
mod_offline:resend_offline_messages(
|
||||||
StateData#state.user),
|
StateData#state.user),
|
||||||
presence_broadcast_first(From, StateData, Packet);
|
presence_broadcast_first(
|
||||||
|
From, StateData#state{pres_last = Packet,
|
||||||
|
pres_invis = false
|
||||||
|
}, Packet);
|
||||||
true ->
|
true ->
|
||||||
presence_broadcast_to_trusted(From,
|
presence_broadcast_to_trusted(From,
|
||||||
StateData#state.pres_f,
|
StateData#state.pres_f,
|
||||||
StateData#state.pres_a,
|
StateData#state.pres_a,
|
||||||
Packet),
|
Packet),
|
||||||
StateData
|
StateData#state{pres_last = Packet,
|
||||||
|
pres_invis = false
|
||||||
|
}
|
||||||
end,
|
end,
|
||||||
|
NewState
|
||||||
NewState#state{pres_last = Packet,
|
|
||||||
pres_invis = false
|
|
||||||
}
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
presence_track(From, To, Packet, StateData) ->
|
presence_track(From, To, Packet, StateData) ->
|
||||||
|
@ -98,40 +98,6 @@ loop() ->
|
|||||||
loop()
|
loop()
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
%do_route(From, To, Packet) ->
|
|
||||||
% ?DEBUG("route~n\tfrom ~p~n\tto ~p~n\tpacket ~p~n", [From, To, Packet]),
|
|
||||||
% {DstNode, DstDomain, DstResourse} = To,
|
|
||||||
% F = fun() ->
|
|
||||||
% case mnesia:read({local_route, DstDomain}) of
|
|
||||||
% [] ->
|
|
||||||
% case mnesia:read({route, DstDomain}) of
|
|
||||||
% [] ->
|
|
||||||
% false;
|
|
||||||
% [R] ->
|
|
||||||
% {ok, R#route.node, R#route.pid}
|
|
||||||
% end;
|
|
||||||
% [R] ->
|
|
||||||
% {ok, node(), R#local_route.pid}
|
|
||||||
% end
|
|
||||||
% end,
|
|
||||||
% case mnesia:transaction(F) of
|
|
||||||
% {atomic, false} ->
|
|
||||||
% ejabberd_s2s ! {route, From, To, Packet};
|
|
||||||
% {atomic, {ok, Node, Pid}} ->
|
|
||||||
% case node() of
|
|
||||||
% Node ->
|
|
||||||
% ?DEBUG("routed to process ~p~n", [Pid]),
|
|
||||||
% Pid ! {route, From, To, Packet};
|
|
||||||
% _ ->
|
|
||||||
% ?DEBUG("routed to node ~p~n", [Node]),
|
|
||||||
% {ejabberd_router, Node} ! {route, From, To, Packet}
|
|
||||||
% end;
|
|
||||||
% _ ->
|
|
||||||
% % TODO
|
|
||||||
% error
|
|
||||||
% end.
|
|
||||||
|
|
||||||
do_route(From, To, Packet) ->
|
do_route(From, To, Packet) ->
|
||||||
?DEBUG("route~n\tfrom ~p~n\tto ~p~n\tpacket ~p~n", [From, To, Packet]),
|
?DEBUG("route~n\tfrom ~p~n\tto ~p~n\tpacket ~p~n", [From, To, Packet]),
|
||||||
{DstNode, DstDomain, DstResourse} = To,
|
{DstNode, DstDomain, DstResourse} = To,
|
||||||
|
@ -165,110 +165,6 @@ clean_table_from_bad_node(Node) ->
|
|||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
%do_route(From, To, Packet) ->
|
|
||||||
% ?DEBUG("session manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
|
||||||
% [From, To, Packet, 8]),
|
|
||||||
% {User, Server, Resource} = To,
|
|
||||||
% F = fun() ->
|
|
||||||
% UR = {User, Resource},
|
|
||||||
% Sess = mnesia:read({session, UR}),
|
|
||||||
% case Sess of
|
|
||||||
% [] ->
|
|
||||||
% not_exists;
|
|
||||||
% [Ses] ->
|
|
||||||
% case mnesia:read({mysession, UR}) of
|
|
||||||
% [] ->
|
|
||||||
% {remote, Ses#session.node};
|
|
||||||
% [El] ->
|
|
||||||
% {local, El#mysession.pid}
|
|
||||||
% end
|
|
||||||
% end
|
|
||||||
% end,
|
|
||||||
% {xmlelement, Name, Attrs, Els} = Packet,
|
|
||||||
% case Resource of
|
|
||||||
% "" ->
|
|
||||||
% % TODO
|
|
||||||
% case Name of
|
|
||||||
% "presence" ->
|
|
||||||
% {FU, FS, FR} = From,
|
|
||||||
% Pass = case xml:get_attr_s("type", Attrs) of
|
|
||||||
% "subscribe" ->
|
|
||||||
% mod_roster:in_subscription(User,
|
|
||||||
% {FU, FS, ""},
|
|
||||||
% subscribe);
|
|
||||||
% "subscribed" ->
|
|
||||||
% mod_roster:in_subscription(User,
|
|
||||||
% {FU, FS, ""},
|
|
||||||
% subscribed);
|
|
||||||
% "unsubscribe" ->
|
|
||||||
% mod_roster:in_subscription(User,
|
|
||||||
% {FU, FS, ""},
|
|
||||||
% unsubscribe);
|
|
||||||
% "unsubscribed" ->
|
|
||||||
% mod_roster:in_subscription(User,
|
|
||||||
% {FU, FS, ""},
|
|
||||||
% unsubscribed);
|
|
||||||
% _ ->
|
|
||||||
% true
|
|
||||||
% end,
|
|
||||||
% if Pass ->
|
|
||||||
% LFrom = jlib:jid_tolower(From),
|
|
||||||
% LUser = jlib:tolower(User),
|
|
||||||
% LServer = jlib:tolower(Server),
|
|
||||||
% lists:foreach(
|
|
||||||
% fun(R) ->
|
|
||||||
% if LFrom /= {LUser, LServer, R} ->
|
|
||||||
% ejabberd_sm ! {route,
|
|
||||||
% From,
|
|
||||||
% {User, Server, R},
|
|
||||||
% Packet};
|
|
||||||
% true ->
|
|
||||||
% ok
|
|
||||||
% end
|
|
||||||
% end, get_user_resources(User));
|
|
||||||
% true ->
|
|
||||||
% ok
|
|
||||||
% end;
|
|
||||||
% "message" ->
|
|
||||||
% route_message(From, To, Packet);
|
|
||||||
% "iq" ->
|
|
||||||
% process_iq(From, To, Packet);
|
|
||||||
% "broadcast" ->
|
|
||||||
% lists:foreach(
|
|
||||||
% fun(R) ->
|
|
||||||
% ejabberd_sm ! {route,
|
|
||||||
% From,
|
|
||||||
% {User, Server, R},
|
|
||||||
% Packet}
|
|
||||||
% end, get_user_resources(User));
|
|
||||||
% _ ->
|
|
||||||
% ok
|
|
||||||
% end;
|
|
||||||
% _ ->
|
|
||||||
% case mnesia:transaction(F) of
|
|
||||||
% {atomic, {local, Pid}} ->
|
|
||||||
% ?DEBUG("sending to process ~p~n", [Pid]),
|
|
||||||
% Pid ! {route, From, To, Packet},
|
|
||||||
% ok;
|
|
||||||
% {atomic, {remote, Node}} ->
|
|
||||||
% ?DEBUG("sending to node ~p~n", [Node]),
|
|
||||||
% {ejabberd_sm, Node} ! {route, From, To, Packet},
|
|
||||||
% ok;
|
|
||||||
% {atomic, not_exists} ->
|
|
||||||
% if
|
|
||||||
% Name == "message" ->
|
|
||||||
% route_message(From, To, Packet);
|
|
||||||
% true ->
|
|
||||||
% ?DEBUG("packet droped~n", [])
|
|
||||||
% end,
|
|
||||||
% ok;
|
|
||||||
% {aborted, Reason} ->
|
|
||||||
% ?DEBUG("delivery failed: ~p~n", [Reason]),
|
|
||||||
% false
|
|
||||||
% end
|
|
||||||
% end.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
do_route(From, To, Packet) ->
|
do_route(From, To, Packet) ->
|
||||||
?DEBUG("session manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
?DEBUG("session manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
|
||||||
@ -281,41 +177,60 @@ do_route(From, To, Packet) ->
|
|||||||
case Name of
|
case Name of
|
||||||
"presence" ->
|
"presence" ->
|
||||||
{FU, FS, FR} = From,
|
{FU, FS, FR} = From,
|
||||||
Pass = case xml:get_attr_s("type", Attrs) of
|
{Pass, Subsc} =
|
||||||
"subscribe" ->
|
case xml:get_attr_s("type", Attrs) of
|
||||||
mod_roster:in_subscription(User,
|
"subscribe" ->
|
||||||
{FU, FS, ""},
|
{mod_roster:in_subscription(User,
|
||||||
subscribe);
|
{FU, FS, ""},
|
||||||
"subscribed" ->
|
subscribe),
|
||||||
mod_roster:in_subscription(User,
|
true};
|
||||||
{FU, FS, ""},
|
"subscribed" ->
|
||||||
subscribed);
|
{mod_roster:in_subscription(User,
|
||||||
"unsubscribe" ->
|
{FU, FS, ""},
|
||||||
mod_roster:in_subscription(User,
|
subscribed),
|
||||||
{FU, FS, ""},
|
true};
|
||||||
unsubscribe);
|
"unsubscribe" ->
|
||||||
"unsubscribed" ->
|
{mod_roster:in_subscription(User,
|
||||||
mod_roster:in_subscription(User,
|
{FU, FS, ""},
|
||||||
{FU, FS, ""},
|
unsubscribe),
|
||||||
unsubscribed);
|
true};
|
||||||
_ ->
|
"unsubscribed" ->
|
||||||
true
|
{mod_roster:in_subscription(User,
|
||||||
end,
|
{FU, FS, ""},
|
||||||
|
unsubscribed),
|
||||||
|
true};
|
||||||
|
_ ->
|
||||||
|
{true, false}
|
||||||
|
end,
|
||||||
if Pass ->
|
if Pass ->
|
||||||
LFrom = jlib:jid_tolower(From),
|
LFrom = jlib:jid_tolower(From),
|
||||||
LUser = jlib:tolower(User),
|
LUser = jlib:tolower(User),
|
||||||
LServer = jlib:tolower(Server),
|
LServer = jlib:tolower(Server),
|
||||||
lists:foreach(
|
Resources = get_user_resources(User),
|
||||||
fun(R) ->
|
if
|
||||||
if LFrom /= {LUser, LServer, R} ->
|
Resources /= [] ->
|
||||||
ejabberd_sm ! {route,
|
lists:foreach(
|
||||||
From,
|
fun(R) ->
|
||||||
{User, Server, R},
|
if LFrom /=
|
||||||
Packet};
|
{LUser, LServer, R} ->
|
||||||
true ->
|
ejabberd_sm !
|
||||||
ok
|
{route,
|
||||||
end
|
From,
|
||||||
end, get_user_resources(User));
|
{User, Server, R},
|
||||||
|
Packet};
|
||||||
|
true ->
|
||||||
|
ok
|
||||||
|
end
|
||||||
|
end, Resources);
|
||||||
|
true ->
|
||||||
|
if
|
||||||
|
Subsc ->
|
||||||
|
mod_offline:store_packet(
|
||||||
|
From, To, Packet);
|
||||||
|
true ->
|
||||||
|
ok
|
||||||
|
end
|
||||||
|
end;
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
|
@ -139,10 +139,10 @@ item_to_xml(Item) ->
|
|||||||
process_iq_set(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
process_iq_set(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
|
||||||
{User, _, _} = From,
|
{User, _, _} = From,
|
||||||
{xmlelement, Name, Attrs, Els} = SubEl,
|
{xmlelement, Name, Attrs, Els} = SubEl,
|
||||||
lists:foreach(fun(El) -> process_item_set(User, To, El) end, Els),
|
lists:foreach(fun(El) -> process_item_set(User, From, To, El) end, Els),
|
||||||
{iq, ID, result, XMLNS, []}.
|
{iq, ID, result, XMLNS, []}.
|
||||||
|
|
||||||
process_item_set(User, To, XItem) ->
|
process_item_set(User, From, To, XItem) ->
|
||||||
{xmlelement, Name, Attrs, Els} = XItem,
|
{xmlelement, Name, Attrs, Els} = XItem,
|
||||||
% TODO: load existing item
|
% TODO: load existing item
|
||||||
JID = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)),
|
JID = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)),
|
||||||
@ -175,12 +175,43 @@ process_item_set(User, To, XItem) ->
|
|||||||
_ ->
|
_ ->
|
||||||
mnesia:write(Item2)
|
mnesia:write(Item2)
|
||||||
end,
|
end,
|
||||||
Item2
|
{Item, Item2}
|
||||||
end,
|
end,
|
||||||
case mnesia:transaction(F) of
|
case mnesia:transaction(F) of
|
||||||
{atomic, Item} ->
|
{atomic, {OldItem, Item}} ->
|
||||||
push_item(User, To, Item),
|
push_item(User, To, Item),
|
||||||
ok;
|
case Item#roster.subscription of
|
||||||
|
remove ->
|
||||||
|
IsTo = case OldItem#roster.subscription of
|
||||||
|
both -> true;
|
||||||
|
to -> true;
|
||||||
|
_ -> false
|
||||||
|
end,
|
||||||
|
IsFrom = case OldItem#roster.subscription of
|
||||||
|
both -> true;
|
||||||
|
from -> true;
|
||||||
|
_ -> false
|
||||||
|
end,
|
||||||
|
if IsTo ->
|
||||||
|
ejabberd_router:route(
|
||||||
|
From, OldItem#roster.jid,
|
||||||
|
{xmlelement, "presence",
|
||||||
|
[{"type", "unsubscribe"}],
|
||||||
|
[]});
|
||||||
|
true -> ok
|
||||||
|
end,
|
||||||
|
if IsFrom ->
|
||||||
|
ejabberd_router:route(
|
||||||
|
From, OldItem#roster.jid,
|
||||||
|
{xmlelement, "presence",
|
||||||
|
[{"type", "unsubscribed"}],
|
||||||
|
[]});
|
||||||
|
true -> ok
|
||||||
|
end,
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
E ->
|
E ->
|
||||||
?DEBUG("ROSTER: roster item set error: ~p~n", [E]),
|
?DEBUG("ROSTER: roster item set error: ~p~n", [E]),
|
||||||
ok
|
ok
|
||||||
@ -410,7 +441,6 @@ out_subscription(User, JID, Type) ->
|
|||||||
none -> from;
|
none -> from;
|
||||||
_ -> S
|
_ -> S
|
||||||
end,
|
end,
|
||||||
% TODO: update presence
|
|
||||||
{Item#roster{subscription = NS,
|
{Item#roster{subscription = NS,
|
||||||
ask = none},
|
ask = none},
|
||||||
true};
|
true};
|
||||||
@ -421,7 +451,6 @@ out_subscription(User, JID, Type) ->
|
|||||||
from -> none;
|
from -> none;
|
||||||
_ -> S
|
_ -> S
|
||||||
end,
|
end,
|
||||||
% TODO: update presence
|
|
||||||
{Item#roster{subscription = NS,
|
{Item#roster{subscription = NS,
|
||||||
ask = none},
|
ask = none},
|
||||||
true}
|
true}
|
||||||
|
Loading…
Reference in New Issue
Block a user