mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
*** empty log message ***
SVN Revision: 21
This commit is contained in:
parent
ae30798efd
commit
6cf63ab17f
@ -279,6 +279,16 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
_ ->
|
_ ->
|
||||||
{true, Attrs, StateData}
|
{true, Attrs, StateData}
|
||||||
end;
|
end;
|
||||||
|
"broadcast" ->
|
||||||
|
?DEBUG("broadcast!!!!!!!!!!!~n~p~n", [Els]),
|
||||||
|
NewSt = case Els of
|
||||||
|
[{item, IJID, ISubscription}] ->
|
||||||
|
roster_change(IJID, ISubscription,
|
||||||
|
StateData);
|
||||||
|
_ ->
|
||||||
|
StateData
|
||||||
|
end,
|
||||||
|
{false, Attrs, NewSt};
|
||||||
_ ->
|
_ ->
|
||||||
{true, Attrs, StateData}
|
{true, Attrs, StateData}
|
||||||
end,
|
end,
|
||||||
@ -560,5 +570,38 @@ remove_element(E, Set) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
roster_change(IJID, ISubscription, StateData) ->
|
||||||
|
LIJID = jlib:jid_tolower(IJID),
|
||||||
|
case StateData#state.pres_last of
|
||||||
|
unknown ->
|
||||||
|
StateData;
|
||||||
|
P ->
|
||||||
|
?DEBUG("roster changed for ~p~n", [StateData#state.user]),
|
||||||
|
From = {StateData#state.user, StateData#state.server, ""},
|
||||||
|
Cond1 = (not StateData#state.pres_invis)
|
||||||
|
and ((ISubscription == both) or (ISubscription == from)),
|
||||||
|
Cond2 = ((ISubscription == none) or (ISubscription == to))
|
||||||
|
and (?SETS:is_element(From, StateData#state.pres_a) or
|
||||||
|
?SETS:is_element(From, StateData#state.pres_i)),
|
||||||
|
if
|
||||||
|
Cond1 ->
|
||||||
|
?DEBUG("C1: ~p~n", [LIJID]),
|
||||||
|
ejabberd_router:route(From, IJID, P),
|
||||||
|
A = ?SETS:add_element(LIJID,
|
||||||
|
StateData#state.pres_a),
|
||||||
|
StateData#state{pres_a = A};
|
||||||
|
Cond2 ->
|
||||||
|
?DEBUG("C2: ~p~n", [LIJID]),
|
||||||
|
ejabberd_router:route(From, IJID, P),
|
||||||
|
I = remove_element(LIJID,
|
||||||
|
StateData#state.pres_i),
|
||||||
|
A = remove_element(LIJID,
|
||||||
|
StateData#state.pres_a),
|
||||||
|
StateData#state{pres_i = I,
|
||||||
|
pres_a = A};
|
||||||
|
true ->
|
||||||
|
StateData
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,6 +214,14 @@ do_route(From, To, Packet) ->
|
|||||||
"iq" ->
|
"iq" ->
|
||||||
% TODO
|
% TODO
|
||||||
ok;
|
ok;
|
||||||
|
"broadcast" ->
|
||||||
|
lists:foreach(
|
||||||
|
fun(R) ->
|
||||||
|
ejabberd_sm ! {route,
|
||||||
|
From,
|
||||||
|
{User, Server, R},
|
||||||
|
Packet}
|
||||||
|
end, get_user_resources(User));
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
@ -221,15 +229,7 @@ do_route(From, To, Packet) ->
|
|||||||
case mnesia:transaction(F) of
|
case mnesia:transaction(F) of
|
||||||
{atomic, {local, Pid}} ->
|
{atomic, {local, Pid}} ->
|
||||||
?DEBUG("sending to process ~p~n", [Pid]),
|
?DEBUG("sending to process ~p~n", [Pid]),
|
||||||
% TODO
|
|
||||||
Pid ! {route, From, To, Packet},
|
Pid ! {route, From, To, Packet},
|
||||||
%NewAttrs =
|
|
||||||
% jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
|
||||||
% jlib:jid_to_string(To),
|
|
||||||
% Attrs),
|
|
||||||
%ejabberd_c2s:send_element(
|
|
||||||
% Pid, {xmlelement, Name, NewAttrs, Els}),
|
|
||||||
%?DEBUG("sended~n", []),
|
|
||||||
ok;
|
ok;
|
||||||
{atomic, {remote, Node}} ->
|
{atomic, {remote, Node}} ->
|
||||||
?DEBUG("sending to node ~p~n", [Node]),
|
?DEBUG("sending to node ~p~n", [Node]),
|
||||||
|
@ -310,12 +310,10 @@ in_subscription(User, From, Type) ->
|
|||||||
S = I#roster.subscription,
|
S = I#roster.subscription,
|
||||||
if
|
if
|
||||||
(S == both) or (S == from) ->
|
(S == both) or (S == from) ->
|
||||||
ejabberd_router:route(
|
{update,
|
||||||
{User, ?MYNAME, ""}, {FU, FS, ""},
|
{xmlelement, "presence",
|
||||||
{xmlelement, "presence",
|
[{"type", "subscribed"}], []},
|
||||||
[{"type", "subscribed"}], []}),
|
I};
|
||||||
% TODO: update presence
|
|
||||||
false;
|
|
||||||
true ->
|
true ->
|
||||||
true
|
true
|
||||||
end;
|
end;
|
||||||
@ -323,12 +321,10 @@ in_subscription(User, From, Type) ->
|
|||||||
S = I#roster.subscription,
|
S = I#roster.subscription,
|
||||||
if
|
if
|
||||||
(S == none) or (S == to) ->
|
(S == none) or (S == to) ->
|
||||||
ejabberd_router:route(
|
{update,
|
||||||
{User, ?MYNAME, ""}, {FU, FS, ""},
|
{xmlelement, "presence",
|
||||||
{xmlelement, "presence",
|
[{"type", "unsubscribed"}], []},
|
||||||
[{"type", "unsubscribed"}], []}),
|
I};
|
||||||
% TODO: update presence
|
|
||||||
false;
|
|
||||||
true ->
|
true ->
|
||||||
true
|
true
|
||||||
end;
|
end;
|
||||||
@ -360,6 +356,14 @@ in_subscription(User, From, Type) ->
|
|||||||
true;
|
true;
|
||||||
{atomic, false} ->
|
{atomic, false} ->
|
||||||
false;
|
false;
|
||||||
|
{atomic, {update, Presence, Item}} ->
|
||||||
|
ejabberd_router:route({User, ?MYNAME, ""}, {FU, FS, ""}, Presence),
|
||||||
|
ejabberd_sm ! {route, {"", "", ""}, {User, "", ""},
|
||||||
|
{xmlelement, "broadcast", [],
|
||||||
|
[{item,
|
||||||
|
Item#roster.jid,
|
||||||
|
Item#roster.subscription}]}},
|
||||||
|
false;
|
||||||
{atomic, {push, Item}} ->
|
{atomic, {push, Item}} ->
|
||||||
push_item(User, {"", ?MYNAME, ""}, Item),
|
push_item(User, {"", ?MYNAME, ""}, Item),
|
||||||
true;
|
true;
|
||||||
@ -387,12 +391,12 @@ out_subscription(User, JID, Type) ->
|
|||||||
if Item == false ->
|
if Item == false ->
|
||||||
ok;
|
ok;
|
||||||
true ->
|
true ->
|
||||||
NewItem =
|
{NewItem, Update} =
|
||||||
case Type of
|
case Type of
|
||||||
subscribe ->
|
subscribe ->
|
||||||
Item#roster{ask = subscribe};
|
{Item#roster{ask = subscribe}, false};
|
||||||
unsubscribe ->
|
unsubscribe ->
|
||||||
Item#roster{ask = unsubscribe};
|
{Item#roster{ask = unsubscribe}, false};
|
||||||
subscribed ->
|
subscribed ->
|
||||||
S = Item#roster.subscription,
|
S = Item#roster.subscription,
|
||||||
NS = case S of
|
NS = case S of
|
||||||
@ -401,8 +405,9 @@ out_subscription(User, JID, Type) ->
|
|||||||
_ -> S
|
_ -> S
|
||||||
end,
|
end,
|
||||||
% TODO: update presence
|
% TODO: update presence
|
||||||
Item#roster{subscription = NS,
|
{Item#roster{subscription = NS,
|
||||||
ask = none};
|
ask = none},
|
||||||
|
true};
|
||||||
unsubscribed ->
|
unsubscribed ->
|
||||||
S = Item#roster.subscription,
|
S = Item#roster.subscription,
|
||||||
NS = case S of
|
NS = case S of
|
||||||
@ -411,19 +416,29 @@ out_subscription(User, JID, Type) ->
|
|||||||
_ -> S
|
_ -> S
|
||||||
end,
|
end,
|
||||||
% TODO: update presence
|
% TODO: update presence
|
||||||
Item#roster{subscription = NS,
|
{Item#roster{subscription = NS,
|
||||||
ask = none}
|
ask = none},
|
||||||
|
true}
|
||||||
end,
|
end,
|
||||||
mnesia:write(NewItem),
|
mnesia:write(NewItem),
|
||||||
{push, NewItem}
|
{push, NewItem, Update}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case mnesia:transaction(F) of
|
case mnesia:transaction(F) of
|
||||||
{atomic, ok} ->
|
{atomic, ok} ->
|
||||||
ok;
|
ok;
|
||||||
{atomic, {push, Item}} ->
|
{atomic, {push, Item, Update}} ->
|
||||||
push_item(User, {"", ?MYNAME, ""}, Item),
|
push_item(User, {"", ?MYNAME, ""}, Item),
|
||||||
true;
|
if
|
||||||
|
Update ->
|
||||||
|
ejabberd_sm ! {route, {"", "", ""}, {User, "", ""},
|
||||||
|
{xmlelement, "broadcast", [],
|
||||||
|
[{item,
|
||||||
|
Item#roster.jid,
|
||||||
|
Item#roster.subscription}]}};
|
||||||
|
true ->
|
||||||
|
ok
|
||||||
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
false
|
false
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user