mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
parent
22d76659c0
commit
5e446d50a8
@ -62,6 +62,7 @@
|
|||||||
connected_users_number/0,
|
connected_users_number/0,
|
||||||
user_resources/2,
|
user_resources/2,
|
||||||
kick_user/2,
|
kick_user/2,
|
||||||
|
kick_user/3,
|
||||||
get_session_pid/3,
|
get_session_pid/3,
|
||||||
get_session_sid/3,
|
get_session_sid/3,
|
||||||
get_session_sids/2,
|
get_session_sids/2,
|
||||||
@ -978,14 +979,23 @@ user_resources(User, Server) ->
|
|||||||
Resources = get_user_resources(User, Server),
|
Resources = get_user_resources(User, Server),
|
||||||
lists:sort(Resources).
|
lists:sort(Resources).
|
||||||
|
|
||||||
|
-spec kick_user(binary(), binary()) -> non_neg_integer().
|
||||||
kick_user(User, Server) ->
|
kick_user(User, Server) ->
|
||||||
Resources = get_user_resources(User, Server),
|
Resources = get_user_resources(User, Server),
|
||||||
lists:foreach(
|
lists:foldl(
|
||||||
fun(Resource) ->
|
fun(Resource, Acc) ->
|
||||||
PID = get_session_pid(User, Server, Resource),
|
case kick_user(User, Server, Resource) of
|
||||||
ejabberd_c2s:route(PID, kick)
|
false -> Acc;
|
||||||
end, Resources),
|
true -> Acc + 1
|
||||||
length(Resources).
|
end
|
||||||
|
end, 0, Resources).
|
||||||
|
|
||||||
|
-spec kick_user(binary(), binary(), binary()) -> boolean().
|
||||||
|
kick_user(User, Server, Resource) ->
|
||||||
|
case get_session_pid(User, Server, Resource) of
|
||||||
|
none -> false;
|
||||||
|
Pid -> ejabberd_c2s:route(Pid, kick)
|
||||||
|
end.
|
||||||
|
|
||||||
make_sid() ->
|
make_sid() ->
|
||||||
{p1_time_compat:unique_timestamp(), self()}.
|
{p1_time_compat:unique_timestamp(), self()}.
|
||||||
|
@ -1552,39 +1552,17 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
|
|||||||
|| {User, Server} <- ASL2],
|
|| {User, Server} <- ASL2],
|
||||||
{result, undefined};
|
{result, undefined};
|
||||||
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
||||||
Lang, XData) ->
|
_Lang, XData) ->
|
||||||
AccountString = get_value(<<"accountjid">>, XData),
|
AccountString = get_value(<<"accountjid">>, XData),
|
||||||
JID = jid:decode(AccountString),
|
JID = jid:decode(AccountString),
|
||||||
LUser = JID#jid.luser,
|
|
||||||
LServer = JID#jid.lserver,
|
LServer = JID#jid.lserver,
|
||||||
true = LServer == Host orelse
|
true = LServer == Host orelse
|
||||||
get_permission_level(From) == global,
|
get_permission_level(From) == global,
|
||||||
Xmlelement = xmpp:serr_policy_violation(<<"has been kicked">>, Lang),
|
|
||||||
case JID#jid.lresource of
|
case JID#jid.lresource of
|
||||||
<<>> ->
|
<<>> ->
|
||||||
SIs = mnesia:dirty_select(session,
|
ejabberd_sm:kick_user(JID#jid.luser, JID#jid.lserver);
|
||||||
[{#session{usr = {LUser, LServer, '_'},
|
|
||||||
sid = '$1',
|
|
||||||
info = '$2',
|
|
||||||
_ = '_'},
|
|
||||||
[], [{{'$1', '$2'}}]}]),
|
|
||||||
Pids = [P || {{_, P}, Info} <- SIs,
|
|
||||||
not proplists:get_bool(offline, Info)],
|
|
||||||
lists:foreach(fun(Pid) ->
|
|
||||||
Pid ! {kick, kicked_by_admin, Xmlelement}
|
|
||||||
end, Pids);
|
|
||||||
R ->
|
R ->
|
||||||
[{{_, Pid}, Info}] = mnesia:dirty_select(
|
ejabberd_sm:kick_user(JID#jid.luser, JID#jid.lserver, R)
|
||||||
session,
|
|
||||||
[{#session{usr = {LUser, LServer, R},
|
|
||||||
sid = '$1',
|
|
||||||
info = '$2',
|
|
||||||
_ = '_'},
|
|
||||||
[], [{{'$1', '$2'}}]}]),
|
|
||||||
case proplists:get_bool(offline, Info) of
|
|
||||||
true -> ok;
|
|
||||||
false -> Pid ! {kick, kicked_by_admin, Xmlelement}
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
{result, undefined};
|
{result, undefined};
|
||||||
set_form(From, Host,
|
set_form(From, Host,
|
||||||
|
Loading…
Reference in New Issue
Block a user