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,
|
||||
user_resources/2,
|
||||
kick_user/2,
|
||||
kick_user/3,
|
||||
get_session_pid/3,
|
||||
get_session_sid/3,
|
||||
get_session_sids/2,
|
||||
@ -978,14 +979,23 @@ user_resources(User, Server) ->
|
||||
Resources = get_user_resources(User, Server),
|
||||
lists:sort(Resources).
|
||||
|
||||
-spec kick_user(binary(), binary()) -> non_neg_integer().
|
||||
kick_user(User, Server) ->
|
||||
Resources = get_user_resources(User, Server),
|
||||
lists:foreach(
|
||||
fun(Resource) ->
|
||||
PID = get_session_pid(User, Server, Resource),
|
||||
ejabberd_c2s:route(PID, kick)
|
||||
end, Resources),
|
||||
length(Resources).
|
||||
lists:foldl(
|
||||
fun(Resource, Acc) ->
|
||||
case kick_user(User, Server, Resource) of
|
||||
false -> Acc;
|
||||
true -> Acc + 1
|
||||
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() ->
|
||||
{p1_time_compat:unique_timestamp(), self()}.
|
||||
|
@ -1552,39 +1552,17 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
|
||||
|| {User, Server} <- ASL2],
|
||||
{result, undefined};
|
||||
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
|
||||
Lang, XData) ->
|
||||
_Lang, XData) ->
|
||||
AccountString = get_value(<<"accountjid">>, XData),
|
||||
JID = jid:decode(AccountString),
|
||||
LUser = JID#jid.luser,
|
||||
LServer = JID#jid.lserver,
|
||||
true = LServer == Host orelse
|
||||
get_permission_level(From) == global,
|
||||
Xmlelement = xmpp:serr_policy_violation(<<"has been kicked">>, Lang),
|
||||
case JID#jid.lresource of
|
||||
<<>> ->
|
||||
SIs = mnesia:dirty_select(session,
|
||||
[{#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);
|
||||
ejabberd_sm:kick_user(JID#jid.luser, JID#jid.lserver);
|
||||
R ->
|
||||
[{{_, Pid}, Info}] = mnesia:dirty_select(
|
||||
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
|
||||
ejabberd_sm:kick_user(JID#jid.luser, JID#jid.lserver, R)
|
||||
end,
|
||||
{result, undefined};
|
||||
set_form(From, Host,
|
||||
|
Loading…
Reference in New Issue
Block a user